
Oliver Kowalke:
Hello, how can I support the return type of bind as well as function as function argument in following code.
...
struct Y { template< typename R > void f( boost::function< R() > const& fn) {}
template< typename R > void f( boost::function< R( X &) > const& fn) {} };
You can't; a nullary boost::bind expression can be converted to either function<> and you can't tell with certainty which one the user has meant. For the return type you can do: struct Y { template< typename R > void f1_( boost::function< R() > const& fn) { ... } template<class F> void f1( F f ) { f1_( function<typename F::result_type>( f ) ); } }; but I see no reason to prefer the above over just doing: struct Y { template<class F> void f1( F f ) { ... } }; -- Peter Dimov http://www.pdplayer.com