Boost logo

Boost :

Subject: Re: [boost] [function] functionwrappingwithnoexceptionsafetyguarantee
From: Peter Dimov (pdimov_at_[hidden])
Date: 2010-11-07 16:14:04

Daniel Walker wrote:
On Sat, Nov 6, 2010 at 7:53 PM, Peter Dimov <pdimov_at_[hidden]> wrote:
> > 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<>.
> This is a special case: all targets are function pointers of the same
> type, right?

No. It's enough for one of them to be.

> On my system, the text segment grows by up to 14% when boost::function(
> &throw_bad_function_call ) is used for empty wrappers.

It's very uncommon for real code to not already contain the necessary
instantiations or the equivalent of throw_bad_function_call itself. As soon
as you put a function pointer into boost::function, you ought to get the
instantiations; and as soon as you call it, you ought to get code that
throws bad_function_call. Or I may be missing something.

Boost list run by bdawes at, gregod at, cpdaniel at, john at