#include <iostream>
int add1(int n) { return n+1; }
int add2(int n) { return n+2; }
template<typename Adder>
void AddHandler(int n, Adder adder)
{
int r = adder(n);
std::cout << r << std::endl;
}
int main(void)
{
AddHandler(1, add1);
AddHandler(3, add2);
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKaW50IGFkZDEoaW50IG4pIHsgcmV0dXJuIG4rMTsgfQppbnQgYWRkMihpbnQgbikgeyByZXR1cm4gbisyOyB9CiAKdGVtcGxhdGU8dHlwZW5hbWUgQWRkZXI+CnZvaWQgQWRkSGFuZGxlcihpbnQgbiwgQWRkZXIgYWRkZXIpCnsKICAgIGludCByID0gYWRkZXIobik7CiAgICBzdGQ6OmNvdXQgPDwgciA8PCBzdGQ6OmVuZGw7Cn0KIAppbnQgbWFpbih2b2lkKQp7CiAgICBBZGRIYW5kbGVyKDEsIGFkZDEpOwogICAgQWRkSGFuZGxlcigzLCBhZGQyKTsKIAogICAgcmV0dXJuIDA7Cn0=