Created
January 4, 2015 14:57
-
-
Save catchouli/2cb39715209df0da7866 to your computer and use it in GitHub Desktop.
a relic from the deepest darkest corners of c++
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 <typename T, typename F> | |
size_t offset(F T::* ptr) | |
{ | |
T* typePtr = (T*)nullptr; | |
F* memberPtr = &(typePtr->*ptr); | |
uintptr_t offset = (uintptr_t)memberPtr - (uintptr_t)typePtr; | |
return offset; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment