Boost logo

Boost Users :

Subject: Re: [Boost-users] boost::bind/boost::function and fast, delegates
From: John M. Dlugosz (mpbecey7gu_at_[hidden])
Date: 2013-01-23 03:16:07


On 1/22/2013 4:34 AM, boost-users-request-at-lists.boost.org |Boost/Allow to home| wrote:
> And if you still wish to write such a lib(s) take a look at this article:
>
> http://www.codeproject.com/Articles/7150/Member-Function-Pointers-and-the-Fastest-Possible

Coincedentely, that article references my project that I cited on another thread (shared
pointers):

> For Microsoft's (and Intel's) ugly, non-standard 12 byte |virtual_inheritance| pointers,
> yet another trick is used, based on an idea invented by John Dlugosz.

To pass bound member functions to legacy code (including OS API) that expects a genuine
function pointer, I generated a thunk at run-time and used a compiler trick to get the
information I needed regarding the 'this' adjustment. It is certainly the _fastest_
possible; but I did not elaborate on a full "bind" feature like Boost (and std) eventually
came up with. In fact, I simplified my own code so that all the arguments to pass were
just members of one structure, so I only worried about the case of binding to a member
function with one argument. It didn't automatically capture smart-pointer objects for the
binding, but I handled that separately since it was already being done for "windows" owned
by the OS's reference to raw pointers; I had my own fake +1 count as part of the object,
and Window objects were my primary interest.

As I recall, the C++11 lambda spec provides for a primitive C function pointer to be
coughed up, but I've not yet used a compiler that can do that.



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