Boost Testing :
Subject: [Boost-testing] boost::function Small Buffer Optimization (SBO) and allocators
From: Chris Hite (C.Hite_at_[hidden])
Date: 2009-12-03 12:56:43
I would really like to specify the SBO size on boost::function! How
about changing the signature to?:
template<typename Signature,std::size_t SBOSize=3*sizeof(void*)>
I've been trying to do a work around using the constructor with the
allocator. I was going to define my own function class derived from the
boost one, with a private one time allocator using a private buffer.
This approach works find as long as constructors where the Functor type
The copy constructor and equals operators require serious hackery, since
these constructors on boost function don't allow you to pass a new allow
you to pass a new allocator. There's no
functionN(const functionN&, Allocator);
This means that the Function constructor has to affect data underlying
the const Function instance it's copying such that when the allocator is
copied over it mutates into one that points at the private buffer of the
new constructing instance.
This is doable, but kind of scary since I'm making assumptions about
when and how the Allocator is copied.
This is also not such a wonderful solution, because the SBO is wasted.
Any chance of just parameterizing the SBO size?