|
Boost : |
Subject: Re: [boost] [bind] virtual function pointer woes
From: Eric Niebler (eric_at_[hidden])
Date: 2009-01-09 12:24:18
Jon Biggar wrote:
> Chris wrote:
>> As far as I know, no. If you find a true answer, please tell me.
>> I had this problem once as well and looked into it on the
>> newsgroups. There may be a non-portable way with the vtable and asm,
>> but not generally. My suggestion would be to make a split
>>
>> _nv function that does the call
>>
>> struct B { virtual void f() { f_nv(); } void f_nv()
>> {std::printf("B\n"); } };
>> struct D : B { virtual void f() { f_nv(); } void f_nv() {
>> std::printf("D\n"); } };
>>
>> And then bind _nv;
This is not an option as the classes B and D are not modifiable.
> Or just create a new free function:
>
> inline void call_B_f(D &d)
> {
> d->B::f();
> }
>
> boost::bind(&call_B_f, _1)(d);
Sure, but I'm going to need a lot of these little functions and it's a
pain. C++ has what I want (the member function I want to bind to), but
it's not giving it to me. Very frustrating.
-- Eric Niebler BoostPro Computing http://www.boostpro.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk