[Boost-bugs] [Boost C++ Libraries] #4646: [function][patch] adding an unchecked_invoke method to function objects

Subject: [Boost-bugs] [Boost C++ Libraries] #4646: [function][patch] adding an unchecked_invoke method to function objects
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2010-09-13 15:56:10

#4646: [function][patch] adding an unchecked_invoke method to function objects
 Reporter: peter.myerscough-jackopson@… | Owner: dgregor
     Type: Feature Requests | Status: new
Milestone: To Be Determined | Component: function
  Version: Boost 1.44.0 | Severity: Problem
 Keywords: function unchecked |
 A common idiom for using boost::function objects is as follows :

 boost::function<...> func1;


 if( !func1.empty() )

 Internally to boost::function::operator()(...) there is then a subsequent
 call to empty(), which if fails calls a boost::throw_exception.

 In developing a library that makes use of boost::function, and calling the
 contained function I am forced to define boost::throw_exception, OR
 require my users to do so. The library in question is for an embedded
 platform (without exception support), and so I have also defined
 imperative that I check the function is valid prior to calling it, because
 I have no exception support. The current implementation of boost::function
 however does not allow me to work around this call, and requres me to
 defnie a function that will never be called, and conflict with my library
 users should they wish to define an alternative boost::throw_exception for
 the aspects of boost they may use.

 I am proposing the addition of ''unchecked_invoke(...)'' that allows users
 of boost::function to call a function object without this checking on
 every call. This will not only allow my scenario to work, but also allow
 the common test before use to benefit, especially in the case where a
 function object is called within a loop.

 As reference this topic was discussed in this thread :


 and the proposed patch is for function_template.hpp :

 Insert around line 767

     // MSVC 6.0 and prior require all definitions to be inline, but
     // these definitions can become very costly.
     result_type unchecked_invoke(BOOST_FUNCTION_PARMS) const
       return get_vtable()->invoker
                (this->functor BOOST_FUNCTION_COMMA BOOST_FUNCTION_ARGS);
     result_type unchecked_invoke(BOOST_FUNCTION_PARMS) const;


 and later around line 1015

   ::unchecked_invoke(BOOST_FUNCTION_PARMS) const
     return get_vtable()->invoker
              (this->functor BOOST_FUNCTION_COMMA BOOST_FUNCTION_ARGS);


Ticket URL: <https://svn.boost.org/trac/boost/ticket/4646>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:04 UTC