Is it possilbe to get a pointer to a generic lambda explicit instantiation?
Solution 1:
Yes, and you can omit the template arguments if they can be deduced from the type being initialized (or the result type of a cast) but since the lambda isn’t mutable
the member function is const
and so must be the pointer-to-member.
Solution 2:
Is it possible to get a (member) function pointer to a specific instantiation of a generic lambda?
Lambda's operator()
is const
-qualified by default, you need to add const
to the member function pointer type
void (generic_type::*pf3)(int) const = &generic_type::operator();
And since pf3
is a member function pointer, please note that it need a specific lambda object and uses .*
or ->*
to invoke.
(generic_template.*pf3)(42);
Demo