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



Le Mardi 18 Novembre 2003 10:26, Martin Schulze a écrit :
> >
> > 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;
> > }
>
> Try to specify the argument type as template parameter, i.e.:
>
>    Slot0<void> slot1 = bind<int&>(slot(foo1), i);

I shoudl have said I already tried that :-(
>
> I'm not sure if it works, though - let us know!

same error:

/usr/include/sigc++-1.2/sigc++/bind.h: Dans 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:9:   instantiated from here 
/usr/include/sigc++-1.2/sigc++/bind.h:116: error: destructor name 
`~int&' does    not match type `int' of expression

>
> BTW in libsigc++-2.0 you will be able to write:
>
>    sigc::slot<void> slot1 = sigc::bind(foo1, sigc::ref(i));
>
> instead.

Cool, I'll be missing my boost libs less :-)
(For the record, I also tried boost::ref(i) to no avail :
/usr/include/sigc++-1.2/sigc++/bind.h: Dans 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 = 
boost::reference_wrapper<int>, R = void, C1 = int&]'
testLibSigC.cxx:11:   instantiated from here
/usr/include/sigc++-1.2/sigc++/bind.h:116: error: destructor name 
`~int&' does not match type `int' of expression

Now I'm really holding my breath for libsigc++-2.0 in gtkmm.

Thanks again for your kind help !

Bernard







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