On 2020/04/19 11:03:35, hahnjo wrote: > On 2020/04/19 10:55:52, dak wrote: > I have the vague > > impression that the ability to do template specialisation on typedefs would > also > > be able to solve part of the job here in a more elegant manner but right now > my > > brain objects to more C++ style. > > Yes, I had the same feeling. However I think that the current solution works > because the template arguments are deduced from the function argument. I don't > currently see a way to make this work with template <> using type =, but that > would certainly be nice (and remove the need of using decltype and > remove_pointer).
The principal problem is that the trampoline instantiation requires the member function pointer as a non-type template parameter, and the type of the non-type template parameter is not known in general. So this becomes a hen-and-egg problem. Template specialisation could possibly weasel around it but I am not sure about it. It certainly is suspicious that the otherwise rather comprehensive <type_traits> relying on such techniques has nothing in its toolbox for that task. https://codereview.appspot.com/551780043/