Although I'm not 100% sure, I understand the question, the following code may fit your purpose:
template< class R > struct FCreateBind { typedef boost::function< R() > result_type; template< class T, class U > result_type operator()( T const& x, U const& y ) const { return boost::bind( x, y ); } }; int main() { BOOST_AUTO( generate, boost::bind( FCreateBind< bool >(), Callable(), _1 ) ); BOOST_AUTO( fn, generate( Arg() ) ); bool b = fn(); }
Saying maybe this is not as pretty as the questionnaire expects ...
As you mentioned, if we specify one of boost::bind overloads explicitly, FCreateBind not needed. However, as far as I have seen, there seems to be no portable way to indicate overload. So, in this case, probably we should depend on the internal value of boost .
For your information, when testing, you can compile the following code:
int main() { namespace bb = boost::_bi; // Sorry, for brevity bb::bind_t< bb::unspecified, Callable, bb::list1< bb::value< Arg > > > (*bi)( Callable, Arg ) = boost::bind< bb::unspecified, Callable, Arg >; BOOST_AUTO( generate, boost::bind( bi, Callable(), _1 ) ); BOOST_AUTO( fn, generate( Arg() ) ); bool b = fn(); }
Hope this helps
source share