[bind] function_equal with nested binds

Should function_equal work with nested binds? I expected the following to work but it results in a compiler error: #include <boost/function_equal.hpp> #include <boost/bind.hpp> void f( int ) {} int g( int i ) { return i+5; } template < typename F > bool self_equal( F f_ ) { return function_equal( f_, f_ ); } int main( int argc, char * const argv[] ) { self_equal( boost::bind( f, _1 ) ); // OK self_equal( boost::bind( g, _1 ) ); // OK self_equal( boost::bind( f, boost::bind( g, _1 ) ) ); // compiler error } I made it compile by adding the following: namespace boost { namespace _bi { template<class R, class F, class L> bool ref_compare( bind_t<R,F,L> const & a, bind_t<R,F,L> const & b, long ) { return a.compare(b); } } } Is that OK? Thanks, Gareth ************************************************************************ The information contained in this message or any of its attachments may be confidential and is intended for the exclusive use of the addressee(s). Any disclosure, reproduction, distribution or other dissemination or use of this communication is strictly prohibited without the express permission of the sender. The views expressed in this email are those of the individual and not necessarily those of Sony or Sony affiliated companies. Sony email is for business use only. This email and any response may be monitored by Sony to be in compliance with Sony's global policies and standards

Should function_equal work with nested binds?
I think that it should. You've identified a bug. Can you please file a Trac ticket for it? Your suggested fix looks fine.
Thanks for the quick reply. I've added a Trac ticket (#2127). Is a more general solution (e.g. a ref_compare overload using function_equal) needed/possible to cope with other nested function objects that don't define operator==, or like _bi::bind_t<>, use it for something else? ************************************************************************ The information contained in this message or any of its attachments may be confidential and is intended for the exclusive use of the addressee(s). Any disclosure, reproduction, distribution or other dissemination or use of this communication is strictly prohibited without the express permission of the sender. The views expressed in this email are those of the individual and not necessarily those of Sony or Sony affiliated companies. Sony email is for business use only. This email and any response may be monitored by Sony to be in compliance with Sony's global policies and standards
participants (2)
-
Peter Dimov
-
Sylvester-Bradley, Gareth