Created
January 8, 2017 00:15
-
-
Save Bueddl/dc0e0b8a32db36b9c7fffb141c488b41 to your computer and use it in GitHub Desktop.
cast class member functions to unsigned long (to obtain their addresses in code)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template<class T, class R, class... As> | |
constexpr unsigned long memfn_cast(R(T::*mfnp)(As...)) | |
{ | |
union { | |
unsigned long u_ul; | |
R(T::*u_mfnp)(As...); | |
} addr; | |
addr.u_mfnp = mfnp; | |
return addr.u_ul; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment