Boost Testing :
Subject: Re: [Boost-testing] boost::function Small Buffer Optimization (SBO) and allocators
From: Emil Dotchevski (emil_at_[hidden])
Date: 2009-12-03 14:11:25
On Thu, Dec 3, 2009 at 9:56 AM, Chris Hite <C.Hite_at_[hidden]> wrote:
> 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*)>
> class function;
The small buffer optimization is an implementation detail, you
shouldn't know about it. What would you do if you wanted to customize
the size for the small buffer optimization in std::string? :)
> 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
> template<typename Allocator>
> functionN(const functionN&, Allocator);
It's tricky, but yours seems like a typical use case for allocators.
> This is also not such a wonderful solution, because the SBO is wasted.
It has been some time since I last looked at that code but I can't
think of any reason why the SBO would be wasted. In principle, the
allocator object and the buffer can overlap, since they're never used
Reverge Studios, Inc.