|
Boost Users : |
Subject: [Boost-users] comparing function objects
From: Noah Roberts (roberts.noah_at_[hidden])
Date: 2008-09-24 18:35:16
"Function object wrappers can be compared via == or != against any
function object that can be stored within the wrapper. If the function
object wrapper contains a function object of that type, it will be
compared against the given function object (which must be either be
EqualityComparable or have an overloaded boost::function_equal)."
But how do I compare two boost::functions? This code doesn't work:
#include <boost/function.hpp>
#include <boost/bind.hpp>
double f(double)
{
return 42.0;
}
int main()
{
boost::function<double(double)> f1 = boost::bind(&f, _1);
boost::function<double(double)> f2 = boost::bind(&f, _1);
//if (f1 == f2)
if (boost::function_equal<boost::function<double(double)>,
boost::function<double(double)> >(f1,f2))
;
}
NOTE: tried to specifically instantiate the function_equal template as
attempt3. Previous attempt didn't do that...it also did not work.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net