Boost logo

Boost :

From: Robert Jones (robertgbjones_at_[hidden])
Date: 2008-07-21 05:44:09


On Wed, Jul 16, 2008 at 6:20 PM, Steven Watanabe <watanabesj_at_[hidden]>
wrote:

> AMDG
>
> Robert Jones wrote:
>
>> Is it possible to bind to pure virtual methods? Like this
>>
>> <snip>
>>
>> My compiler seems to be complaining that s is abstract, which is
>> surely not a real limitation!
>>
>>
>
> This is a unfortunate problem with Boost.Lambda's return type
> deduction mechanism. See also http://svn.boost.org/trac/boost/ticket/426.
>
> You can work around it by passing a pointer.
>
> #include <boost/lambda/bind.hpp>
> #include <boost/lambda/lambda.hpp>
>
> struct S {
> virtual void methodOfS() = 0;
> };
>
> void f( S & s ) {
> using namespace boost::lambda;
> bind(&S::methodOfS, _1)(&s);
> }
>
>
Thanks for that Steven. That solution has now been used in my real code and
works like a charm! I just can't quite get the hang of Boost's tolerance of
transparently
handling pointers, references or instances without breaking stride. My
thought
paradigm is still stuck in STL-mode rather than Boost-mode.

Cheers, Rob.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk