[sigc] how to use signal as slot?
- From: Martin Bickel <martin asc-hq org>
- To: libsigc-list gnome org
- Subject: [sigc] how to use signal as slot?
- Date: Mon, 7 Sep 2015 19:48:43 +0200
Hi all,
I'm currently converting an application from sigc++ 1.2 to sigc++ 2
(tested 2.4.1 and 2.2.10).
In 1.2, I could take a signal as a slot and connect it to another signal:
SigC::Signal0<bool> signal_detected;
SigC::Signal0<bool> alarm;
signal_detected.connect( alarm );
In 2.x , it works for Signals with return type void:
sigc::signal<void> signal_detected;
sigc::signal<void> warning;
signal_detected.connect( warning ) ;
but changing the return value to bool gives a compiler error:
#include <sigc++/sigc++.h>
#include <iostream>
bool warn_people()
{
std::cout << "There are aliens in the carpark!\n";
return true;
}
int main()
{
sigc::signal<bool> signal_detected;
sigc::signal<bool> warning;
warning.connect( sigc::ptr_fun(warn_people) );
signal_detected.connect( warning ) ;
signal_detected();
return 0;
}
/home/martin/software/libsigc++-2.4.1/sigc++/functors/slot.h:103:36:
error: void value not ignored as it ought to be
return (typed_rep->functor_)();
Is there any way to use signals as slots without writing an adaptor
function that emits the second signal?
Regards
Martin
[Date Prev][
Date Next] [Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]