#include <stdio.h>
void func1(){
printf("func1\n");
}
void func2(){
printf("func2\n");
}
class TraitsBase{
protected:
typedef void (*fptr)();
fptr ptr;
TraitsBase(fptr p) : ptr(p){}
public:
void call(){
ptr();
}
};
template<class T> class Traits;
template<> class Traits<int> : public TraitsBase{
public:
Traits<int>() : TraitsBase(&func1){};
};
template<> class Traits<float>: public TraitsBase{
public:
Traits<float>() : TraitsBase(&func2){}
};
int main(){
Traits<int> i;
i.call();
Traits<float> f;
f.call();
}
I2luY2x1ZGUgPHN0ZGlvLmg+Cgp2b2lkIGZ1bmMxKCl7CiAgICBwcmludGYoImZ1bmMxXG4iKTsKfQp2b2lkIGZ1bmMyKCl7CiAgICBwcmludGYoImZ1bmMyXG4iKTsKfQpjbGFzcyBUcmFpdHNCYXNlewpwcm90ZWN0ZWQ6CiAgICB0eXBlZGVmIHZvaWQgKCpmcHRyKSgpOwogICAgZnB0ciBwdHI7CiAgICBUcmFpdHNCYXNlKGZwdHIgcCkgOiBwdHIocCl7fQpwdWJsaWM6CiAgICB2b2lkIGNhbGwoKXsKICAgICAgICBwdHIoKTsKICAgIH0KfTsKdGVtcGxhdGU8Y2xhc3MgVD4gY2xhc3MgVHJhaXRzOwp0ZW1wbGF0ZTw+IGNsYXNzIFRyYWl0czxpbnQ+IDogcHVibGljIFRyYWl0c0Jhc2V7CnB1YmxpYzoKICAgIFRyYWl0czxpbnQ+KCkgOiBUcmFpdHNCYXNlKCZmdW5jMSl7fTsKICAgIAp9Owp0ZW1wbGF0ZTw+IGNsYXNzIFRyYWl0czxmbG9hdD46IHB1YmxpYyBUcmFpdHNCYXNlewpwdWJsaWM6CiAgICBUcmFpdHM8ZmxvYXQ+KCkgOiBUcmFpdHNCYXNlKCZmdW5jMil7fQp9OwppbnQgbWFpbigpewogICAgVHJhaXRzPGludD4gaTsKICAgIGkuY2FsbCgpOwogICAgVHJhaXRzPGZsb2F0PiBmOwogICAgZi5jYWxsKCk7CiAgICAKfQ==