Boost logo

Boost Users :

Subject: [Boost-users] Equality comparison of boost::function<>
From: Zachary Turner (divisortheory_at_[hidden])
Date: 2009-08-08 01:30:25


Is this possible? I always get ambiguities when I try it. Here's
some sample code:

class foo
{
public:
   typedef enum { lost, reset } device_event;
   typedef boost::function<void (window&, device_event)> device_listener;

   void add_listener(const device_listener& listener)
   {
      std::list<device_listener>::const_iterator iter =
std::find(listeners_.begin(), listeners_.end(), listener);
      if (iter == listeners_.end())
         listeners_.push_back(listener);
   }

private:
   std::list<device_listener> listeners_;
};

The above is slightly simplified from my actual code, but when I do
this I get the following:

I'm using Visual C++ 9.0 SP1

1>f:\dev\testing\window.h(42) : error C2666: 'operator ==' : 4
overloads have similar conversions
1> q:\include\boost\1.39.0\boost\function\function_template.hpp(995):
could be 'void boost::operator ==<R,T0,T1>(const
boost::function2<R,T0,T1> &,const boost::function2<R,T0,T1> &)' [found
using argument-dependent lookup]
1> with
1> [
1> R=void,
1> T0=zg::window &,
1> T1=zg::window::device_event
1> ]
1> q:\include\boost\1.39.0\boost\function\function_base.hpp(791):
or 'bool boost::operator
==<zg::window::device_listener>(Functor,const boost::function_base &)'
[found using argument-dependent lookup]
1> with
1> [
1> Functor=zg::window::device_listener
1> ]
1> q:\include\boost\1.39.0\boost\function\function_base.hpp(782):
or 'bool boost::operator ==<zg::window::device_listener>(const
boost::function_base &,Functor)' [found using argument-dependent
lookup]
1> with
1> [
1> Functor=zg::window::device_listener
1> ]
1> or 'built-in C++ operator==(void (__thiscall
boost::function2<R,T0,T1>::dummy::* )(void), void (__thiscall
boost::function2<R,T0,T1>::dummy::* )(void))'
1> with
1> [
1> R=void,
1> T0=zg::window &,
1> T1=zg::window::device_event
1> ]
1> while trying to match the argument list '(const
zg::window::device_listener, const zg::window::device_listener)'
1


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