Skip to content

Instantly share code, notes, and snippets.

@wackoisgod
Created October 18, 2014 06:37
Show Gist options
  • Save wackoisgod/058b92ed9c03bf52765d to your computer and use it in GitHub Desktop.
Save wackoisgod/058b92ed9c03bf52765d to your computer and use it in GitHub Desktop.
class PrivateClass{
private:
void SomeFunction() { printf("Hello World"); };
};
template <class Tag>
struct touch
{
static typename Tag::type value;
};
template <class Tag>
typename Tag::type touch<Tag>::value;
template <class Tag, typename Tag::type x>
struct touch_private
{
touch_private() { touch<Tag>::value = x; }
static touch_private instance;
};
template <class Tag, typename Tag::type x>
touch_private<Tag, x> touch_private<Tag, x>::instance;
//// OH MAN WTF!!!! HACKS!!!!
struct AS { typedef void(PrivateClass::*type)(); };
template struct touch_private < AS, &PrivateClass::SomeFunction >;
int _tmain(int argc, _TCHAR* argv[])
{
PrivateClass c;
(c.*touch<AS>::value)();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment