<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/104569>104569</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            suggest `modernize-use-auto` for predicate arguments
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang-tidy,
            c++14
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          firewave
      </td>
    </tr>
</table>

<pre>
    ```cpp
#include <algorithm>
#include <map>
#include <string>

void f()
{
 const std::map<int, std::string> m;
    
    auto it = std::find_if(m.cbegin(), m.cend(), [&](const std::pair<const int, std::string>& p){
        return p.second.empty();
    });
    it = std::find_if(m.cbegin(), m.cend(), [&](const decltype(m.cbegin())::value_type& p){
        return p.second.empty();
 });
 (void)it;
}
```

https://godbolt.org/z/4jea1G55e

Starting with C++14 you can use `auto` for the argument in the predicate. This might also prevent issues where a wrong argument might lead to unexpected behavior (like omitting `const` on the first part of the pair leading to the pair being copied for each invocation).

It should probably only be suggested if the existing expression match the result of `decltype(<first>)::value_type` as starting with C++11 by-value is allowed "for VT a move is equivalent to a copy" according to https://en.cppreference.com/w/cpp/algorithm/find.

I think this should be opt-in as it might not desirable in some code bases.

This might be out of scope of the check though based on the current documentation which states it is about "using the auto type specifier for variable declarations". As the check has a very generic name I think this extension would be valid.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVcGSozYQ_Rr50mUKC4zNgcOMHadyzlauW0JqQ-8KiUgCj_frUxL22DPZPSVTUwy0pKfXr1_3CO-pM4gN276y7XElptBb15zJ4UXMuGqtujasypdfOY4sP7L8hfGCjNSTQmDFQejOOgr9wIrffrY-iPEXKz44Mt1jMT1nSwrOjO8Zr2_x3evyAtIaH8AHxYoXVrwk5AOZwPjhEX1HhYEV95MA8HgTU7BAAVhxfBw7k1FfKV48ZLLFjsyNAz_AkEk06vEd5eIV2x4Z33_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