#include <functional>
#include <boost/bind.hpp>
class test {
public:
template<class t> void jopa(t);
void doit();
};
template<class t>
class base {
public:
typedef std::function<void(t)> handler;
void send(handler h);
};
class x {};
class y {};
class derived_x: public base<x> {};
class derived_y: public base<y> {};
void test::doit()
{
derived_x X;
derived_y Y;
X.send(boost::bind(&test::jopa, this, _1));
Y.send(boost::bind(&test::jopa, this, _1));
}
I2luY2x1ZGUgPGZ1bmN0aW9uYWw+CiNpbmNsdWRlIDxib29zdC9iaW5kLmhwcD4KCmNsYXNzIHRlc3QgewogcHVibGljOgogICAgdGVtcGxhdGU8Y2xhc3MgdD4gdm9pZCBqb3BhKHQpOwoJdm9pZCBkb2l0KCk7Cn07Cgp0ZW1wbGF0ZTxjbGFzcyB0PgpjbGFzcyBiYXNlIHsKIHB1YmxpYzoKCXR5cGVkZWYgc3RkOjpmdW5jdGlvbjx2b2lkKHQpPiBoYW5kbGVyOwoJdm9pZCBzZW5kKGhhbmRsZXIgaCk7Cn07CgpjbGFzcyB4IHt9OwpjbGFzcyB5IHt9OwoKY2xhc3MgZGVyaXZlZF94OiBwdWJsaWMgYmFzZTx4PiB7fTsKY2xhc3MgZGVyaXZlZF95OiBwdWJsaWMgYmFzZTx5PiB7fTsKCnZvaWQgdGVzdDo6ZG9pdCgpCnsKCWRlcml2ZWRfeCBYOyAKCWRlcml2ZWRfeSBZOwoJWC5zZW5kKGJvb3N0OjpiaW5kKCZ0ZXN0Ojpqb3BhLCB0aGlzLCBfMSkpOwoJWS5zZW5kKGJvb3N0OjpiaW5kKCZ0ZXN0Ojpqb3BhLCB0aGlzLCBfMSkpOwp9