Surya Kiran Gullapalli wrote:
template <class T> class TemplatedClass { TemplatedClass () { member = shared_ptr<T> (CreateA()) ; }
private: shared_ptr<T> member ;
operator->() { return T.get() ; } } ;
class BasePlugin { virtual void foo (void) = 0 ; }
class DerivedPlugin_A : public BasePlugin { virtual void foo (void) { cout << "FOO in derived A" << endl ;} } ;
DerivedPlugin_A* CreateA () { return new DerivedPlugin_A ; }
TemplatedClass <BasePlugin> t ; t->foo() ;
How do i write a boost::function wrapper for t->foo() ;
As far as I understand it you need to double nest the binds. Using Boost.Lambda it would be something like this: boost::lambda::bind( &BasePlugin::foo, boost::lambda::bind( &TemplatedClass< BasePlugin >::operator->, t ) ) This expression should give you a boost::function< void ( void ) >. K