4 ms·
Ludicrously complicated syntax being required to refer to something simple, like a pointer to a member function. Python: sort(my_list, key=my_instance.sort)
by abdulhaq 16y ago
Ludicrously complicated syntax being required to refer to something simple, like a pointer to a member function.
Python:
sort(my_list, key=my_instance.sort)
C++/Boost:
sorry, I had only had 2 hours and couldn't work it out (it's 10 years since I did any real C++).
- ismarc 16y agostd::vector<std::string> v = getList(); std::for_each(v.begin(), v.end(), boost::mem_fn(&std::string::sort)); Hadn't used it in, well, forever, but have done something similar. Pretty much stolen straight off of http://live.boost.org/doc/libs/1_34_1/libs/bind/mem_fn.html http://live.boost.org/doc/libs/1_34_1/libs/bind/mem_fn.html . For non-boost solution: http://www.cplusplus.com/reference/std/functional/mem_fun/ http://www.cplusplus.com/reference/std/functional/mem_fun/