Boost logo

Boost :

From: William E. Kempf (wekempf_at_[hidden])
Date: 2003-01-31 06:51:57


Peter Dimov said:
> From: "DudeSan" <dudesan_at_[hidden]>
>> > No, this won't work. boost::bind returns a function object, an
>> object
>> with
>> > operator() defined, not a function pointer. You can't use bind() to
>> create
>> > a function pointer.
>>
>> So, are there any suggestions or ideas that I could use?
>>
>> I'm trying to make the wndProc point at a member function. I've got it
>> too work with functors but I figured boost might get handy since I'm
>> converting a class::function to a function.
>
> A wndProc is a function pointer. It can't be made to point to a
> nonstatic member function; these need a pointer to the object ("this")
> as an implicit first argument.
>
> Are you sure you got it to work with functors?
>
> The usual solutions are either using Set/GetWindowLong(hWnd,
> GWL_USERDATA) to store a pointer to the object, or using a std::map<
> HWND,
> boost::function<HWND, UINT, WPARAM, LPARAM> >.

Another interesting solution is to use a "thunk", much like is done in
ATL. This technique could be trivially used to invoke functors.

William E. Kempf
wekempf_at_[hidden]


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