Re: SigC::bind - binding reference arguments?



Murray Cumming wrote:
>On Tue, 2005-05-24 at 15:46 +0100, Caspar MacRae wrote:
>  
>>Hi,
>>
>>
>>This is not urgent as I have a work around,
>>but I'd still like to know how to do this properly...
>>
>>
>>Trying to bind a Gtk::Menu reference as an argument:
>>
>>        instanceA.my_signal_changed.connect( SigC::bind<Gtk::Menu&>(
>>SigC::slot(instanceA, &ClassA::fill_menu), m_Menu) );
>>
>>Produces the following error:
>>
>>        /opt/gnome/include/sigc++-1.2/sigc++/bind.h:116: error:
>>destructor name `~
>>           Gtk::Menu&' does not match type `Gtk::Menu' of expression
>>        make: *** [mainwindow.o] Error 1
>>
>>However if the Gtk::Menu& argument is changed for Gtk::Menu* (in the
>>bind<template> and fill_menu definition) everything compiles and runs fine.
>>    
>
>I guess it's saying that it can't copy, and later delete, a reference.
>sigc::ref() might solve this. A pointer would be simpler though.
>
>  
OK, thanks Murray. 

I'll have to spend a while longer exploring Libsigc++...

In the code it wasn't strictly necessary to use a reference - but I did
want to make it implicit that the menu pointer wasn't to be reassigned.
Achieved the same kind of reference 'security'  with a constant pointer:

        instanceA.my_signal_changed.connect( SigC::bind<Gtk::Menu * const>(
SigC::slot(instanceA, &ClassA::fill_menu), m_Menu) );


begin:vcard
fn:Caspar MacRae
n:MacRae;Caspar
email;internet:caspar earcam co uk
x-mozilla-html:TRUE
version:2.1
end:vcard



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