[bind] static member function binding
Hi, does Boost.Bind contain anything to create a function object that is statically bound to a member function? IIUC all function objects created by bind contain a function pointer, so they have overhead compared to a manual function object. something like: struct A{ void f(); } A *a; bind<void (A::*)(),&A::f>(a); -> function object bound to "a", calling A::f
Zitat von Stefan Strasser <strasser@uni-bremen.de>:
does Boost.Bind contain anything to create a function object that is statically bound to a member function?
since I haven't found anything, I think this would be a useful addition to boost.MemFn. (although it might be performance nitpicking...) template<class F> __declspec(noinline) void dispatch(F f){ f(); } int main(){ A a; //compiler inlines A::f into dispatch() dispatch(boost::bind(smem_fun<void (A::*)(),&A::f>(),&a)); //compiler can't inline A::f into dispatch(). indirect function //call is used. dispatch(boost::bind(std::mem_fun(&A::f),&a)); }
participants (1)
-
Stefan Strasser