Boost logo

Boost :

From: Douglas Gregor (gregod_at_[hidden])
Date: 2002-09-21 23:20:16


On Monday 02 September 2002 04:46 am, Brunen, Johannes wrote:
> Finally, I found time to make the SlotFunctor CopyConstructible.
>
> class A
> {
> void somefun(X& x);
> public:
> struct SlotFunctor
> {
> SlotFunctor() : _a(NULL) {}
> SlotFunctor(A* a) : _a(a) {}
> SlotFunctor(const SlotFunctor& r) : _a(r._a) {}
> void operator() () const
> { ... }
>
> A* _a;
> };
>
> However, with the same result i.e. error message:

I've finally investigated this, and tried to get a workaround in place, but
VC6's quirkiness has bested me in this arena. It's clearly a bug in overload
resolution, because the version of get_invocable_slot it picks is _always_
the wrong one in this case (in fact, the one it picks can't ever work, so it
complains). Of course, it magically works if SlotFunctor is declared outside
of A, but fails when SlotFunction is a member in A. Maybe this works in VC7?
(test program below)

        Doug

#include <boost/signal.hpp>

class X {
public:
  void connect(boost::signal0<void>::slot_type slot) { my_sig.connect(slot); }

private:
  boost::signal0<void> my_sig;
};

class A
{
        void somefun(X& x);
public:
    struct SlotFunctor
    {
        SlotFunctor() : _a(NULL) {}
        SlotFunctor(A* a) : _a(a) {}
        SlotFunctor(const SlotFunctor& r) : _a(r._a) {}
        void operator() () const
        { }

        A* _a;
    };
};

int main()
{
  X x;
  A a;
  x.connect(A::SlotFunctor(&a));
  return 0;
}


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk