Boost logo

Boost Users :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2004-12-14 08:53:33


gast128 wrote:
> Dear all,
>
> We all waited for the operator==. Unfortunately it does not compile
> on VC++ 7.1. What do I wrong:
>
> namespace Tstb
> {
> int f0 ();
> int f1 (int a);
> int f2 (int a, int b);
> int f3 (int a, int b, int c);
> }
>
> void Test
> {
> boost::function<int ()> fc1 = &Tstb::f0;
> boost::function<int ()> fc2 = &Tstb::f0;
> boost::function<int ()> fc3 = boost::bind(&Tstb::f1, 2);
>
> bool b = false;
>
> b = (fc1 == fc2);
> b = (fc1 == fc3);
> b = (fc2 == fc3);
> }

You've been mislead by the name. function::operator== is not an operator==.
Here's how it's supposed to be used:

   boost::function<int ()> fc1 = &Tstb::f0;
   boost::function<int ()> fc3 = boost::bind(&Tstb::f1, 2);

   bool b = false;

   b = (fc1 == &Tstb::f0);
   b = (fc3 == &Tstb::f0);
   b = (fc1 == boost::bind(&Tstb::f1, 2));
   b = (fc3 == boost::bind(&Tstb::f1, 2));

> Wkr,
> me

:-(


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