I'm in the process of implementing a platform independent wrapper for dynamically loaded libraries. Of course when I load functions from the libraries I need to store them as pointers for future use. I thought of using boost::function's for that instead of normal function pointers. Sure, that will increase compile time, but that's not what I am afraid of. Rather:
What is the overhead introduced by boost::function when calling the stored function? Is there one? How big is it?
I guess I won't have much overhead when calling such functions from time to time, however, how about functions that get called a lot? (extreme example, glVertex
on a loaded GL library). How much would it hurt performance?
Source-diving boost didn't answer much :>.
Also if it's compiler dependant, I'm mainly interested in GCC and MSVC.
As stated in the Boost documentation, invoking a boost::function
incurs the cost of one call through a function pointer in most cases. In other words, if you were going to have to use function pointers anyhow, it's a wash, and you get a bunch of enhanced functionality for free.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With