So I recently had a question about using the ranges variant of the std::ranges::find
algorithm and the answer used a projection:
if (auto const it{std::ranges::find(iv, 1, &S::a)}; it != iv.end()) {
std::cout << "Found!\n" << "\n";
}
Specifically the &S::a
part.
Normally I have seen a lambda being used in this place, but here we use a pointer to a class member. Is this transformed into a lambda or is there some overload selection going on?
Can someone break down how this, seemingly magic, works?