binding by value, slot taking reference was Re: [gtkmm] binding arguments to slots



Bonsoir,
Thank you for your help.
Le Lundi 17 Novembre 2003 19:41, Martin Schulze a écrit :
> Am 2003.11.17 15:23 schrieb(en) gtkmm mailing list account:
> > It look like there is a stringent limitation on the number of
> > arguents
> >
> > :-(
>
> The limitation will be lifted in libsigc++-2.0.

Cool !
<snip>
>
> > Is there a way to expand it (recompiling libsigc++1.2 ) ?
>
> Yes. You have to edit sigc++/macros/bind.h.m4. The last "paragraph"
> of the file is of interest. Add ADAPTOR_BIND_DATA(ARGS(C,3)), etc.;
> maybe also some ADAPTOR_BIND_SLOT(...) commands are needed.

Thank you, I'll try, but I think I will wait for libsigc++-2.0.

There is still something I don't understand with slot and bind :

I would like to make a slot for a function taking arguments by 
reference:
program :
"
using namespace std;
using namespace SigC;

void foo1(int& i){++i;}

int main(int argc, char** argv){
int i=1;
Slot0<void>slot1=bind(slot(foo1),i);
 return 0;
}
"
error :
g++ testLibSigC.cxx -lstdc++ `pkg-config gtkmm-2.0 --cflags --libs` -o 
testLibSigC
/usr/include/sigc++-1.2/sigc++/bind.h: In static member function 
`static void   SigC::AdaptorBindData1_<C1>::dtor(void*) [with C1 = 
int&]':
/usr/include/sigc++-1.2/sigc++/bind.h:167:   instantiated from 
`SigC::Slot0<R> SigC::bind(const SigC::Slot1<R, C1>&, A1) [with A1 = 
int, R = void, C1 = int&]'
testLibSigC.cxx:10:   instantiated from here
/usr/include/sigc++-1.2/sigc++/bind.h:116: error: destructor name 
`~int&' does   not match type `int' of expression

I would like bind to make and hold a copy of an int, and every call to 
foo1 should get a reference to this copy.
It should be possible, but I cannot find how :-(

Any hint & advice greatly appreciated.

Bernard



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