Skip to content

Instantly share code, notes, and snippets.

@udaken
Last active February 9, 2019 18:24
Show Gist options
  • Save udaken/cfc6805f1100d9dd0b6d748d42e3d307 to your computer and use it in GitHub Desktop.
Save udaken/cfc6805f1100d9dd0b6d748d42e3d307 to your computer and use it in GitHub Desktop.
#include <stdio.h>
template <class T, void (T::* f)()>
struct Foo
{
void func(T& obj)
{
(obj.*f)();
}
};
struct A
{
template <int n>
void func()
{
printf("%d\n",n);
};
};
int main(int argc, char* argv[])
{
A a;
Foo<A, &A::func<0> > f0;
f0.func(a);
Foo<A, &A::func<1> > f1;
f1.func(a);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment