Boost logo

Boost Users :

From: Duane Murphy (duanemurphy_at_[hidden])
Date: 2002-09-19 21:37:50


--- At Fri, 20 Sep 2002 01:28:18 +0000, someuserat wrote:
>I actually ended up figuring out how to write a function object class
>to do something similar. This has been a good learning experience!
>Is there a down side to the function object approach over the helper
>function? From what I could tell, the helper function had to be a
>global function, which just didn't seem right.

I recall reading an article a few months ago that seemed to indicate that
under some circumstances function objects provide more of an opportunity
for inlining.

Depending on how the function is used, the compiler may need to pass the
reference as a pointer to a function. In this case, the function will
likely not be inlined. With a function object, the function "pointer" is
really a reference to a zero-length object that has a function method.
Calling this method will likely be inlined.

As I recall the opportunities became significant using the binding
functions. I think under many circumstances this is also true for boost::bind.

 ...Duane


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