Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.lang.c++.moderated    |    Moderated discussion of C++ superhackery    |    33,346 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 32,286 of 33,346    |
|    Seungbeom Kim to Pete Becker    |
|    Re: overload resolution and function poi    |
|    12 May 12 03:10:03    |
      From: musiphil@bawi.org              On 2012-05-11 18:30, Pete Becker wrote:       > On 2012-05-11 19:21:54 +0000, Marc said:       >       >> I have several overloads of a function, I have a set of arguments, and       >> I would like to get a function pointer to the overload the compiler       >> would pick if I called this function on these arguments. I am not       >> interested in applying the function now, I just want to get that       >> pointer.       >>       >> Is this possible? Or is anything vaguely similar possible?       >       > Use a cast to select from a set of overloaded functions:       >       > void f(int);       > void f(double);       >       > typedef void (*f_of_double)(double);       >       > f_of_double fptr = (f_of_double)&f;       >       > The typedef isn't actually needed; I used it here to clarify what's       > going on. Yes, the cast looks wierd, but that's the rule.              You don't actually need the cast either, do you?              void (*f_int)(int) = &f; // points to f(int)       void (*f_double)(double) = &f; // points to f(double)              --       Seungbeom Kim                      [ See http://www.gotw.ca/resources/clcm.htm for info about ]        [ comp.lang.c++.moderated. First time posters: Do this! ]              --- SoupGate-Win32 v1.05        * Origin: you cannot sedate... all the things you hate (1:229/2)    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca