Boost logo

Boost Users :

From: Roman Perepelitsa (roman.perepelitsa_at_[hidden])
Date: 2007-09-07 02:20:48


Surya Kiran Gullapalli <suryakiran.gullapalli <at> gmail.com> writes:
>
> > 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
>
> That doesn't seem to be working. I'm getting lot of errors and its
> next to impossible to comprehend those errors.
>
> I've attached sample files to what I'm trying to do.
>
> Please Help.
>
> Thanks in advance,
> Surya

You can do it hard way and easy way.

1. Hard way.
fp = boost::lambda::bind
(
    &BaseClass::foo,
    boost::lambda::bind(&TemplateClass<BaseClass>::operator->, t),
    boost::lambda::_1
);

2. Easy way.

a) Add the following to template.h.

namespace boost
{
    template<class T>
    T * get_pointer(const TemplateClass<T> & p)
    {
        return p.operator->();
    }
}

b) Use boost::bind instead of boost::lambda.

//#include <boost/lambda/lambda.hpp>
//#include <boost/lambda/bind.hpp>
#include <boost/bind.hpp>

fp = bind(&BaseClass::foo, t, _1);

Roman Perepelitsa.


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