diff --git a/doc/reference.html b/doc/reference.html index f96bcf1..ba804bf 100644 --- a/doc/reference.html +++ b/doc/reference.html @@ -46,10 +46,12 @@ explicit functionN(const Mixin& = Mixin()); functionN(const functionN&); template<typename F> functionN(const F&, const Mixin& = Mixin()); + template<typename F> functionN(reference_wrapper<F>); // Assignment functionN& operator=(const functionN&); template<typename F> functionN& operator=(const F&); + template<typename F> functionN& operator=(reference_wrapper<F>); void set(const functionN&); template<typename F> void set(const F&); void swap(functionN&); @@ -126,16 +128,6 @@

A special provision is made for pointers to member functions. Though they are not function objects, Boost.Function will adapt them internally to function objects. This requires that a pointer to member function of the form R (X::*mf)(Arg1, Arg2, ..., ArgN) cv-quals be adapted to a function object with the following function call operator overloads:

-  R operator()(cv-quals X& x, Arg1 arg1, Arg2 arg2, ..., ArgN argN) const
-  {
-    return x.*mf(arg1, arg2, ..., argN);
-  }
-
-  R operator()(cv-quals X* x, Arg1 arg1, Arg2 arg2, ..., ArgN argN) const
-  {
-    return x->*mf(arg1, arg2, ..., argN);
-  }
-  
   template<typename P>
   R operator()(cv-quals P& x, Arg1 arg1, Arg2 arg2, ..., ArgN argN) const
   {
@@ -190,6 +182,14 @@
   
  • Rationale: g is a reference-to-const because it is a portable, efficient, and concise way to accept any function object or function pointer. In the case of a function pointer, the type of g is reference-to-const pointer-to-function.
  • +

    template<typename F> functionN(reference_wrapper<F> g); +

    +

    functionN& operator=(const functionN& g);

    +

    template<typename F> functionN& operator=(reference_wrapper<F> g); +

    +

    void set(const functionN& g);

    +

    References to Functions

    +

    In some cases it is expensive (or semantically incorrect) to have +Boost.Function clone a function object. In such cases, it is possible +to request that Boost.Function keep only a reference to the actual +function object. This is done using the ref and cref functions to wrap a +reference to a function object: + +

    +  stateful_type a_function_object;
    +  boost::function<int, int> f;
    +  f = ref(a_function_object);
    +
    +  boost::function<int, int> f2(f);
    +
    + +Here, f will not make a copy of +a_function_object, nor will f2 when it is +targeted to f's reference to +a_function_object. Additionally, when using references to +function objects, Boost.Function will not throw exceptions during assignment. +

    The function family

    The header <boost/function.hpp> defines the primary entry point to the function object wrappers, the class template boost::function. This class template is essentially a thin wrapper around a set of similar numbered function object wrappers, boost::function0, boost::function1, etc., where the number indicates the number of arguments passed to the function object target. The declaration of f above could also be written as: