Can you compare boost::function objects?
I'm not certain (from the documentation) whether see if two
boost::function objects are equal (I tend to think not!). The code
below doesn't compile on VC7.1, raising an error about 4 ambiguous
overloads of operator==
#include
On May 27, 2005, at 6:10 AM, Stuart Dootson wrote:
I'm not certain (from the documentation) whether see if two boost::function objects are equal (I tend to think not!).
Sounds like I need to fix the documentation.
The code below doesn't compile on VC7.1, raising an error about 4 ambiguous overloads of operator==
#include
int Flip() { return 2; }
int main(int,char**) { boost::function
f1 = &Flip; boost::function f2 = &Flip; bool const areTheyEqual = (f1 == f2); } Can someone confirm if this should/should not compile, please?
It should not compile. Comparison of two function<> objects is not implementable in genera (without compiler extensions or significant user pain). Doug
On 5/27/05, Douglas Gregor
On May 27, 2005, at 6:10 AM, Stuart Dootson wrote:
I'm not certain (from the documentation) whether see if two boost::function objects are equal (I tend to think not!).
Sounds like I need to fix the documentation.
The code below doesn't compile on VC7.1, raising an error about 4 ambiguous overloads of operator==
#include
int Flip() { return 2; }
int main(int,char**) { boost::function
f1 = &Flip; boost::function f2 = &Flip; bool const areTheyEqual = (f1 == f2); } Can someone confirm if this should/should not compile, please?
It should not compile. Comparison of two function<> objects is not implementable in genera (without compiler extensions or significant user pain).
Doug
Thanks, Doug - that's pretty much what I thought (just wasn't 100% sure). The tutorial sub-title 'Comparing Boost.Function function objects' kind of implies that you can compare Boost.Function objects with each other. The text under that sub-title does say that you can compare a Boost.Function object with any function object that can be contained in a Boost.Function object (but can a Boost.Function contain a Boost.Function?). There's no explicit statement there, though, that says you can't compare a Boost.Function object with another Boost.Function object. Heh - just looked at the reference - the operator== description does say that functionN objects aren't EqualityComparable. Doh! Stuart
participants (2)
-
Douglas Gregor
-
Stuart Dootson