To bind a reference, you must use sigc::ref() around the reference in 
the sigc::bind() statement. Works perfectly. We use it all the time.

-- 
hpreg

Paul Pogonyshev wrote:
> Apparently f1() _is_ called, but with a reference pointing to a wrong
> place in memory...
> 
> 
> #include <iostream>
> 
> #include <sigc++/sigc++.h>
> 
> 
> namespace
> {
> 
>   void
>   f1 (int& x)
>   {
>     x = 1;
>   }
> 
> 
>   void
>   f2 (int* x)
>   {
>     *x = 1;
>   }
> 
> }
> 
> 
> int
> main ()
> {
>   int  x1 = 0;
> 
>   std::cout << "x1 = " << x1 << '\n';
> 
>   sigc::slot <void>  _f1 = sigc::bind (&f1, x1);
>   _f1 ();
> 
>   std::cout << "x1 = " << x1 << '\n';
> 
>   int  x2 = 0;
> 
>   std::cout << "x2 = " << x2 << '\n';
> 
>   sigc::slot <void>  _f2 = sigc::bind (&f2, &x2);
>   _f2 ();
> 
>   std::cout << "x2 = " << x2 << '\n';
> 
>   return 0;
> }
> _______________________________________________
> libsigc-list mailing list
> libsigc-list@gnome.org
> http://mail.gnome.org/mailman/listinfo/libsigc-list
_______________________________________________
libsigc-list mailing list
libsigc-list@gnome.org
http://mail.gnome.org/mailman/listinfo/libsigc-list

Reply via email to