Alternative to sigc::mem_fun

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Alternative to sigc::mem_fun

Gtkmm mailing list
The doc of sigc::mem_fun suggest to use something else which takes
arguments as reference instead of pointer and also mem_fun is
deprecated.

What do you suggest to use in place of sigc::mem_fun?

_______________________________________________
gtkmm-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtkmm-list

signature.asc (497 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Alternative to sigc::mem_fun

Gtkmm mailing list
On 19 June 2018 at 13:58, Compro Prasad via gtkmm-list <[hidden email]> wrote:
The doc of sigc::mem_fun suggest to use something else which takes
arguments as reference instead of pointer and also mem_fun is
deprecated.

A link to the docs you're referring to would be useful.

By my reading, it <https://developer.gnome.org/libsigc++/stable/group__mem__fun.html> says
Please use the version that takes the object by reference instead.

which means that it provides alternatives that accept references, and you should use those overloads instead of the older ones taking a pointer.


_______________________________________________
gtkmm-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtkmm-list
Reply | Threaded
Open this post in threaded view
|

Re: Alternative to sigc::mem_fun

Gtkmm mailing list
I still don't see the problem. There is an overload that takes a reference instead and should be in each case.

So, for

sigc::mem_fun ( T_obj *  _A_obj,


T_return(T_obj2::*)(T_arg1, T_arg2)  _A_func 

)

you should substitute

sigc::mem_fun ( T_obj &  _A_obj,


T_return(T_obj2::*)(T_arg1)  _A_func 

)


These are immediately adjacent in the docs:

or did I miss something else and this doesn't work for you somehow?


_______________________________________________
gtkmm-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtkmm-list
Reply | Threaded
Open this post in threaded view
|

Re: Alternative to sigc::mem_fun

Gtkmm mailing list
On Tue, 19 Jun 2018 17:00:35 +0100
Daniel Boles via gtkmm-list <[hidden email]> wrote:

> I still don't see the problem. There is an overload that takes a reference
> instead and should be in each case.
>
> So, for
>
> *sigc::mem_fun * *(* *T_obj * * *_A_obj*,
>
>
> *T_return(T_obj2::*)(T_arg1, T_arg2) * *_A_func*
>
> *)*
>
> you should substitute
>
> *sigc::mem_fun * *(* *T_obj & * *_A_obj*,
>
>
> *T_return(T_obj2::*)(T_arg1) * *_A_func*
>
> *)*
>
>
> These are immediately adjacent in the docs:
> https://developer.gnome.org/libsigc++/stable/group__mem__fun.html#ga0df7af9f32990cc624c4bb60782b4f78
>
> or did I miss something else and this doesn't work for you somehow?

The poster is confusing sigc::mem_fun() with std::mem_fun().

To the OP: from C++11 onwards, in place of std::mem_fun() use either
std::bind or a lambda expression.  None of this affects sigc::mem_fun().
_______________________________________________
gtkmm-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtkmm-list
Reply | Threaded
Open this post in threaded view
|

Re: Alternative to sigc::mem_fun

Gtkmm mailing list
> The poster is confusing sigc::mem_fun() with std::mem_fun().

How do you know? Everything seems like a delberate reference to the sigc:: template so far, just missing the availability of the other overload.

For posterity, I'll point out that the sigc:: one can't always be replaced by some other alternative, since it uses sigc::trackable to auto-disconnect the handler if the object is a trackable and goes out of scope.


_______________________________________________
gtkmm-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtkmm-list