Opened 12 years ago

Last modified 12 years ago

#4720 new Feature Requests

[function][patch] function wrapper with no exception safety guarantee

Reported by: Daniel Walker Owned by: Douglas Gregor
Milestone: To Be Determined Component: function
Version: Boost 1.44.0 Severity: Problem
Keywords: Cc:

Description

boost::function provides a strong exception safety guarantee. However, in certain circumstances, such as some embedded systems, no exception safety guarantee is desirable. I request that function object wrappers with no exception safety guarantee be added to the Boost.Function family. The attached patch implements boost::unsafe_function (with both preferred syntax and portable syntax), which has no exception safety guarantee when invoked with no target and has no dependency on boost::throw_exception. The patch includes tests and documentation updates. It addresses the same issue identified in #4646.

Attachments (1)

djw_unsafe_function.patch (36.4 KB ) - added by Daniel Walker 12 years ago.
Implements boost::unsafe_function with tests and docs.

Download all attachments as: .zip

Change History (2)

by Daniel Walker, 12 years ago

Attachment: djw_unsafe_function.patch added

Implements boost::unsafe_function with tests and docs.

comment:1 by peter.myerscough-jackopson@…, 12 years ago

I like the concept of an entirely separate unsafe_function, but I am also aware that the patch of #4646 would also enable benefits when the normal function object is used, for example a common idiom of using function objects is

if( funcObj )
{ 
   funcObj(); // could be funcObj->unchecked_invoke();
}

which would benefit from being an unchecked_invoke(), but I suppose that it may be simpler / cleaner to maintain the calling operator and allow an optimizer to remove the repeated checking of the funcObj's validity, but this does rely on the optimiser, which both gcc and msvc++ do.

I think it would be worth placing some boost assertions in place of the previous checks so that debug code will catch and highlight the failure point.

Note: See TracTickets for help on using tickets.