When you are building a code base, we'd suggest building a namespace (named preds or something similar) of general-purpose predicates to make the code more readable. For example, in the previous example, the predicates could be generalized to this:
auto less_by_size = [](const auto& a, const auto& b){ return a.size() < b.size();};auto equal_by_size = [](auto size){ return [size](const auto& v){ return size == v.size(); };};
With these named predicates, the user code becomes more readable:
std::sort(names.begin(), names.end(), preds::less_by_size);auto x = std::find_if(names.begin(), names.end(), equal_by_size(3));// x points to "Apu"
Candidates for this namespace could be equal_case_insensitive, which compares ...