[ create a new paste ] login | about

Link: http://codepad.org/wDBdGvSN    [ raw code | output | fork ]

C++, pasted on Mar 8:
#include <iostream>

using namespace std;

struct foo
{
	void bar() const
	{
		cout << "hey" << endl;
	}
};

template <typename T, void (T::*pf)() /*add const here for clang*/>
void call(T& t)
{
	(t.*pf)();
}

int main()
{
	foo f;
	call<const foo, &foo::bar>(f);
	return 0;
}


Output:
1
hey


Create a new paste based on this one


Comments: