#include #include #include #include #include void fn_1(int){} void fn_2(int,int){} void fn_3(int,int,int){} void fn_0(){} namespace _bi=boost::_bi; template struct nargs; template struct nargs<_bi::bind_t >{enum {value=0};}; template struct nargs< _bi::bind_t< R, F, _bi::list1 > > > {enum {value=arity};}; template struct max { enum{value=lhs > rhs?lhs:rhs}; }; template struct nargs< _bi::bind_t< R, F, _bi::list2,boost::arg > > > { enum{value=max::value}; }; template void bind_nargs(BindExpr) { std::cout << nargs::value << std::endl; } int main() { bind_nargs(boost::bind(&fn_0)); bind_nargs(boost::bind(&fn_1,_4)); bind_nargs(boost::bind(&fn_2,_8,_9)); bind_nargs(boost::bind(&fn_2,_1,_2)); // bind_nargs(boost::bind(&fn_2,_1,_2)); // won't compile (needs specialization as above) // bind_nargs(boost::bind(&fn_2,_1,_1,_1)); }