What is the simplest way to “cast” a member function pointer to a function pointer in C++?
问题 I want to provide a member function for the "comp" parameter of an STL algorithm like lower_bound( ..., Compare comp ). The comp() function accesses a non-static member field so it must itself be a non-static member but the type of a non-static member function pointer is different from that of an ordinary function pointer. What is the best way around this problem? 回答1: This is the most common use of std::mem_fun and std::mem_fun_ref . They're templates that create functors that invoke the