|
Boost : |
Subject: Re: [boost] [function] function wrappingwithnoexceptionsafetyguarantee
From: Peter Dimov (pdimov_at_[hidden])
Date: 2010-11-06 19:53:49
Daniel Walker wrote:
On Sat, Nov 6, 2010 at 2:08 PM, Emil Dotchevski <emil_at_[hidden]>
wrote:
>> Can someone please explain why does storing the empty state take space
>> per type?
> Storing a target function takes space per type, namely, the static
> stored_vtable on line 912 of boost/function/function_template.hpp, which
> is dependent on both the type of boost::funciton's signature and the type
> of the target function.
It doesn't have to.
void throw_bad_function_call()
{
throw bad_function_call();
}
function<void()> f( &throw_bad_function_call );
doesn't take up any additional space per type, unless of course the program
never stores a function pointer into function<>. You just need one "empty"
bit to avoid the DLL problems with the function not having an unique
address. It doesn't take up any additional space in the code segment either,
because this "throw_bad_function_call" function ought to be present in the
current implementation somewhere; either that, or it's being inlined per
every function<> call, which is even worse.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk