#include #include struct from_float { from_float(float x) {} }; template TR (TC::* select_overload(TR (TC::* Func)(void), int = 0))(void) { return Func; } template TR (TC::* select_overload0(TR (TC::* Func)(void)))(void) { return Func; } template TR (TC::* select_overload(TR (TC::* Func)(TP), float = 0))(TP) { return Func; } template TR (TC::* select_overload1(TR (TC::* Func)(TP)))(TP) { return Func; } template TR (TC::* select_overload(TR (TC::* Func)(TP1, TP2), from_float = from_float(0)))(TP1, TP2) { return Func; } template TR (TC::* select_overload2(TR (TC::* Func)(TP1, TP2)))(TP1, TP2) { return Func; } template TR (* select_overload(TR (* Func)(void), int = 0))(void) { return Func; } template TR (* select_overload0(TR (* Func)(void)))(void) { return Func; } template TR (* select_overload(TR (* Func)(TP), float = 0))(TP) { return Func; } template TR (* select_overload1(TR (* Func)(TP)))(TP) { return Func; } template TR (* select_overload(TR (* Func)(TP1, TP2), from_float = from_float(0)))(TP1, TP2) { return Func; } template TR (* select_overload2(TR (* Func)(TP1, TP2)))(TP1, TP2) { return Func; } using namespace boost; struct C { void F(char x1, char x2){ std::cout<<"F("<(&C::F), &o, _1)(c); bind(select_overload(&C::F), &o, _1, _2)(c, i); bind(select_overload(&C::F), &o, _1, _2)(c, c); bind(select_overload(&C::F), &o, _1, _2)(i, i); bind(select_overload(G), _1)(c); bind(select_overload(G), _1, _2)(c, i); bind(select_overload(G), _1, _2)(c, c); bind(select_overload(G), _1, _2)(i, i); select_overload(G)(c); select_overload(G)(c, i); select_overload(G)(c, c); select_overload(G)(i, i); (o.*select_overload(&C::H))(c, i); // This doesn't work, could by C::H(char) or C::H(char, int) (o.*select_overload(&C::H))(c, 0); (o.*select_overload1(&C::H))(c); select_overload(H)(c, i); // This one doesn't work, could be: H(char) or H(char, int). //select_overload(H)(c); select_overload1(H)(c); // This one also doesn't work, could be int I(char) or void I(char, int). //select_overload(I)(c); //select_overload(I)(c, i); select_overload1(I)(c); select_overload2(I)(c, i); (o.*select_overload1(&C::I))(c); (o.*select_overload(&C::I))(c, i); }