Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the point of using boost::mem_fn if we have boost::bind?

I'm having a look at the Boost libraries that were included in C++'s Technical Report 1 and trying to understand what each does.

I've just finished running an example for boost::mem_fn and now I'm wondering what's the point of using it instead of the better boost::bind. As far as I understand, both of them return a function object pointing to a member function. I find mem_fn so limited that I can't find a scenario where using it would be better than bind.

Am I missing something? Is there any case in which bind cannot replace mem_fn?

like image 764
José Tomás Tocino Avatar asked Jun 21 '10 19:06

José Tomás Tocino


1 Answers

mem_fn is much smaller than bind, so if you only need the functionality of mem_fn it's a lot less code to pull in.

like image 130
Jeff Hardy Avatar answered Sep 30 '22 03:09

Jeff Hardy