[sigc] Range over signals



While experimenting a bit with libsigc++, I ran into some issues
regarding the type of a sigc::signal#. The following source shows that
I'd like to be able to range over sigc::signals no matter its specific
type and elaborate on that. I've tried to add explicit type information
regarding the slot (see 'connect(sigc:slot<..'), but without success,
apparently. Can anyone shed some light in this matter?


class SignalManager
{
   public:
      SignalManager() {}

//    sigc::signal<void, int>* get_signal()  // <- OK
      sigc::signal_base* get_signal()        // <- NOT OK
      {
	 return &signal_print;
      }
   private:           
      sigc::signal<void, int> signal_print;
      
};

void on_print(int i)
{
   std::cout << i << std::endl;
}

int main()
{
  SignalManager sm;

  sm.get_signal()->connect(
    sigc::slot<void,int>(sigc::ptr_fun(&on_print)));

  sm.get_signal()->emit(123);

  return 0;
}




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]