id summary reporter owner description type status milestone component version severity resolution keywords cc 288 adapters for smart_ptr? nobody Peter Dimov "{{{ Hello, May be I just can't find this, but... I would like to use the STL algorithms on STL containers of smart_ptrs. So I need an adapter that adapts a member function of a class that is pointed to by a smart_ptr. The standard boost::mem_fun does not do this. So, I wrote this class: template class PTR, typename S, typename T> class mem_fun_ptr_t : public std::unary_function { public: explicit mem_fun_ptr_t(S (T::*p)()) : ptr(p) {} S operator()(PTR p) const { return ((*p).*ptr)(); } private: S (T::*ptr)(); }; template class PTR, typename S, typename T> inline mem_fun_ptr_t mem_fun_ptr(S (T::*f)()) { return mem_fun_ptr_t(f); } //============================ // // usage (e.g.): // ============= // class MyClass { // public: // void method() { /* Do something */ } // }; // //... // std::vector > myVector; // //... (fill myVector) // // std::for_each(myVector.begin(),myVector.end(), // simon::mem_fun_ptr(&MyClass::method)); // May be I am re-inventing the wheel? (If so please tell me :^) If not, could something like this be added to boost? Thanks, Simon Robbins. robbins@physik.uni-wuppertal.de }}}" Feature Requests closed smart_ptr None None