Boost logo

Boost Users :

From: Kirit Sælensminde (kirit.saelensminde_at_[hidden])
Date: 2007-09-05 01:02:05


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


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net