On Fri, 25 Aug 2023 09:45:09 GMT, Johan Sjölen <jsjo...@openjdk.org> wrote:
>> This code looks similar to a capturing lambda. Would an alternative be to >> use that instead and let the calling code be changed to: >> >> >> int i = lgrp_spaces()->find([&](LGRPSpace* space) { >> return space->lgrp_id() == lgrp_id; >> }); >> >> >> Alternatively: >> >> auto matches_lgrp_id = [&](LGRPSpace* space) { >> return space->lgrp_id() == lgrp_id; >> }; >> >> int i = lgrp_spaces()->find(matches_lgrp_id); > > We could just as well do a capturing lambda here, yes. Then we'd have: > > ```c++ > template<F> > int find(F finder); > > > It'd be a template instead of function pointer since it's a capturing lambda > and `std::function` is not permitted in Hotspot AFAIK. > > As an aside, to clarify for readers: There's a `&` missing in the capture > list of your examples. Updated in-place ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/15418#discussion_r1305517877