
"Jonathan Turkanis" <technews@kangaroologic.com> wrote in message news:cg0tk6$98j$1@sea.gmane.org...
"Peter Dimov" <pdimov@mmltd.net> wrote in message news:002301c4857d$234e3270$0600a8c0@pdimov...
Did you know that it already works? ;-)
Yes, naturally. ;-)
Jonathan
If I'm interpretting this correctly, this means that arity isn't an issue. In that case, maybe this implementation will work: template<typename P, typename C, typename R> boost::function<R (C *, P)> overload_select(R (C::* f)(P)) { return boost::bind(f, _1, _2); } template<typename P1, typename P2, typename C, typename R> boost::function<R (C *, P1, P2)> overload_select(R (C::* f)(P1, P2)) { return boost::bind(f, _1, _2, _3); } ...etc. And for free functions: template<typename P, typename R> boost::function<R (P)> overload_select(R (*f)(P)) { return boost::bind(f, _1); } template<typename P1, typename P2, typename R> boost::function<R (P1, P2)> overload_select(R (*f)(P1, P2)) { return boost::bind(f, _1, _2); } ...etc. This would break this: struct V { void f(void){} void f(char){} }; int main() { V o; bind(overload_select<void>(&V::f), &o); } But so what? Just do this: bind(&V::f, &o);