Re: [boost] [Function] Implemented operator== and operator!=

Douglas Gregor wrote:
On the main branch, I've implemented operator== and operator!= for Boost.Function (but not in the form you expect).
I am getting a C4800 warning from MSVC 7.1 ('int' forced to true/false) in function_template.hpp:299: bool equal = BOOST_FUNCTION_COMPARE_TYPE_ID(typeid(Functor), *type); return (equal? functor_ptr : make_any_pointer(reinterpret_cast<void*>(0))); That's because type_info::operator= returns an int (for ABI reasons, I presume.) This is a regression. The fix is trivial: return BOOST_FUNCTION_COMPARE_TYPE_ID(typeid(Functor), *type)? functor_ptr: make_any_pointer(reinterpret_cast<void*>(0)); The definition of BOOST_FUNCTION_COMPARE_TYPE_ID is: # define BOOST_FUNCTION_COMPARE_TYPE_ID(X,Y) (X==Y) It should be: # define BOOST_FUNCTION_COMPARE_TYPE_ID(X,Y) ((X) == (Y)) Also, I'm not really sure whether we should pre-emptively "fix" type_info::operator= like this. Bugfixes should be in response to actual bug reports.

On Friday 30 January 2004 10:54 am, Peter Dimov wrote:
Douglas Gregor wrote:
On the main branch, I've implemented operator== and operator!= for Boost.Function (but not in the form you expect).
I am getting a C4800 warning from MSVC 7.1 ('int' forced to true/false) in function_template.hpp:299: [snip]
This is a regression. The fix is trivial:
return BOOST_FUNCTION_COMPARE_TYPE_ID(typeid(Functor), *type)? functor_ptr: make_any_pointer(reinterpret_cast<void*>(0));
Fixed.
The definition of BOOST_FUNCTION_COMPARE_TYPE_ID is:
# define BOOST_FUNCTION_COMPARE_TYPE_ID(X,Y) (X==Y)
It should be:
# define BOOST_FUNCTION_COMPARE_TYPE_ID(X,Y) ((X) == (Y))
Fixed.
Also, I'm not really sure whether we should pre-emptively "fix" type_info::operator= like this. Bugfixes should be in response to actual bug reports.
type_info::operator== doesn't work across shared libraries with GCC's new ABI, and this is the accepted way to fix it. I grabbed the fix out of the Python lib (where presumably they've already had this bug report). Nobody's submitted a bug report about operator== not working on MSVC 6.0, but I tried to support that anyway :) Doug

Douglas Gregor <gregod@cs.rpi.edu> writes:
Also, I'm not really sure whether we should pre-emptively "fix" type_info::operator= like this. Bugfixes should be in response to actual bug reports.
type_info::operator== doesn't work across shared libraries with GCC's new ABI, and this is the accepted way to fix it. I grabbed the fix out of the Python lib (where presumably they've already had this bug report).
I fixed it pre-emptively; the bug was found during the prototyping stages of the new version of the library. Without a fix it would've been useless ;-) -- Dave Abrahams Boost Consulting www.boost-consulting.com
participants (3)
-
David Abrahams
-
Douglas Gregor
-
Peter Dimov