Boost logo

Boost Users :

From: Angus Leeming (yg-boost-users_at_[hidden])
Date: 2002-07-17 08:46:12


I currently have a class that exposes a signal but otherwise
hides its internals behind a firewall using the Pimpl idiom:

class Foo {
public:
        boost::signal0<void> statusChanged;
private:
        class Impl;
        boost::scoped_ptr<Impl> const pimpl_;
};

Since all I want to do publicly is allow things to connect to
this signal:
        Foo foo;
        foo.statusChanged.connect(boost::bind(&X::bar, this));

it'd be nice to hide the signal too and replace it with a connect() method:

class Foo {
public:
        boost::signals::connection connect(slot_type const &) const;
private:
        class Impl;
        boost::scoped_ptr<Impl> const pimpl_;
};

My problem is defining slot_type. If I have

boost::signals::connection
Foo::connect(boost::slot<void> const & slot) const
{
        return statusChanged.connect(slot);
}

I get compiler warnings something like this (below).

As you can see, I'm having trouble decyphering the magic that is the
boost header files!

can someone please help!
Kind regards,
Angus

cxx: Error: ../../../devel/boost/boost/signals/slot.hpp, line 122: #250
          reference to void is not allowed
          detected during instantiation of class
                    "boost::slot<SlotFunction> [with SlotFunction=void]" at
                    line 171 of
                    "../../../devel/src/graphics/GraphicsCacheItem.C"
    const SlotFunction& get_slot_function() const { return slot_function; }
----------------------^
cxx: Error: ../../../devel/boost/boost/signals/slot.hpp, line 128: #70
          incomplete type is not allowed
          detected during instantiation of class
                    "boost::slot<SlotFunction> [with SlotFunction=void]" at
                    line 171 of
                    "../../../devel/src/graphics/GraphicsCacheItem.C"
    SlotFunction slot_function;
-----------------^
cxx: Error: ../../../devel/src/graphics/GraphicsCacheItem.C, line 171: #304 no
          instance of overloaded function "boost::signal0<R, Combiner, Group,
          GroupCompare, SlotFunction>::connect [with R=void,
          Combiner=boost::last_value<void>, Group=int,
          GroupCompare=std::less<int>, SlotFunction=boost::function0<void,
          boost::empty_function_policy, boost::empty_function_mixin,
          std::allocator<boost::function_base>>]" matches the argument list
            argument types are: (const boost::slot<void>)
        return statusChanged.connect(slot);
-----------------------------^


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