|
Boost : |
From: Aleksey Gurtovoy (alexy_at_[hidden])
Date: 2002-01-28 14:12:52
Peter Dimov wrote:
> > I had that same idea for a while as well. FWIW, if
> > 'boost::function<>' didn't perform dynamic allocation on
> > something as simple as 'f = boost::bind(&my::foo, this)'
> > (and provided a non-throw guarantee for such operations),
> > we would have switched to it long time ago :).
>
> The "small string" optimization?
Something like this :). That would be a generalization of the idea. Our
current implementation just detects the special case of member function
pointer being bounded to the corresponding object pointer (e.g. 'this'), and
stores these two pointers only, not the function object.
> But how would function<> ensure the proper
> alignment for the function object type?
That shouldn't be hard if we wanted it. After all, we have
'boost::alignment_of', Fernando Cacciola's "aligned_storage.hpp" (somewhere
in the vault, I believe), and Andrei's paper -
http://www.oonumerics.org/tmpw01/alexandrescu.pdf - seems to provide a
solution as well.
Aleksey
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk