#include <iostream>
using namespace std;
int multiply(int x, int y)
{
return x * y;
}
template <class F>
void foo(int x, int y, F f)
{
cout << f(x, y) << endl;
}
template <int (*F)(int,int)>
void bar(int x, int y)
{
cout << F(x, y) << endl;
}
int main()
{
foo(3, 4, multiply); // works
bar<multiply>(3, 4); //now it works!
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmludCBtdWx0aXBseShpbnQgeCwgaW50IHkpCnsKICAgIHJldHVybiB4ICogeTsKfQoKdGVtcGxhdGUgPGNsYXNzIEY+CnZvaWQgZm9vKGludCB4LCBpbnQgeSwgRiBmKQp7CiAgICBjb3V0IDw8IGYoeCwgeSkgPDwgZW5kbDsKfQoKdGVtcGxhdGUgPGludCAoKkYpKGludCxpbnQpPgp2b2lkIGJhcihpbnQgeCwgaW50IHkpCnsKICAgIGNvdXQgPDwgRih4LCB5KSA8PCBlbmRsOwp9CgppbnQgbWFpbigpCnsKICAgIGZvbygzLCA0LCBtdWx0aXBseSk7IC8vIHdvcmtzCiAgICBiYXI8bXVsdGlwbHk+KDMsIDQpOyAvL25vdyBpdCB3b3JrcyEKCiAgICByZXR1cm4gMDsKfQ==