Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

Reference
PrevUpHomeNext

Reference

Definitions

  • A function object f is compatible if for the given set of argument types Arg1, Arg2, ..., ArgN and a return type ResultType, the appropriate following function is well-formed:

      // if ResultType is not void
      ResultType foo(Arg1 arg1, Arg2 arg2, ..., ArgN argN)
      {
        return f(arg1, arg2, ..., argN);
      }
    
      // if ResultType is void
      ResultType foo(Arg1 arg1, Arg2 arg2, ..., ArgN argN)
      {
        f(arg1, arg2, ..., argN);
      }
    

    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:

      template<typename P>
      R operator()(cv-quals P& x, Arg1 arg1, Arg2 arg2, ..., ArgN argN) const
      {
        return (*x).*mf(arg1, arg2, ..., argN);
      }
    

  • A function object f of type F is stateless if it is a function pointer or if boost::is_stateless is true. The construction of or copy to a Boost.Function object from a stateless function object will not cause exceptions to be thrown and will not allocate any storage.

namespace boost {
  class bad_function_call;
  class function_base;
  template<typename R, typename T1, typename T2, ..., typename TN> 
    class functionN;
  template<typename T1, typename T2, ..., typename TN> 
    void swap(functionN&, functionN&);
  template<typename T1, typename T2, ..., typename TN, typename Functor> 
    bool operator==(const functionN&, Functor);
  template<typename T1, typename T2, ..., typename TN, typename Functor> 
    bool operator==(Functor, const functionN&);
  template<typename T1, typename T2, ..., typename TN, typename Functor> 
    bool operator==(const functionN&, 
                    reference_wrapper);
  template<typename T1, typename T2, ..., typename TN, typename Functor> 
    bool operator==(reference_wrapper, 
                    const functionN&);
  template<typename T1, typename T2, ..., typename TN, typename U1, 
           typename U2, ..., typename UN> 
    void operator==(const functionN&, 
                    const functionN&);
  template<typename T1, typename T2, ..., typename TN, typename Functor> 
    bool operator!=(const functionN&, Functor);
  template<typename T1, typename T2, ..., typename TN, typename Functor> 
    bool operator!=(Functor, const functionN&);
  template<typename T1, typename T2, ..., typename TN, typename Functor> 
    bool operator!=(const functionN&, 
                    reference_wrapper);
  template<typename T1, typename T2, ..., typename TN, typename Functor> 
    bool operator!=(reference_wrapper, 
                    const functionN&);
  template<typename T1, typename T2, ..., typename TN, typename U1, 
           typename U2, ..., typename UN> 
    void operator!=(const functionN&, 
                    const functionN&);
  template<typename Signature> class function;
  template<typename Signature> 
    void swap(function&, function&);
  template<typename Signature, typename Functor> 
    bool operator==(const function&, Functor);
  template<typename Signature, typename Functor> 
    bool operator==(Functor, const function&);
  template<typename Signature, typename Functor> 
    bool operator==(const function&, reference_wrapper);
  template<typename Signature, typename Functor> 
    bool operator==(reference_wrapper, const function&);
  template<typename Signature1, typename Signature2> 
    void operator==(const function&, const function&);
  template<typename Signature, typename Functor> 
    bool operator!=(const function&, Functor);
  template<typename Signature, typename Functor> 
    bool operator!=(Functor, const function&);
  template<typename Signature, typename Functor> 
    bool operator!=(const function&, reference_wrapper);
  template<typename Signature, typename Functor> 
    bool operator!=(reference_wrapper, const function&);
  template<typename Signature1, typename Signature2> 
    void operator!=(const function&, const function&);
}
namespace boost {
  template<typename F, typename G> bool function_equal(const F&, const G&);
}

PrevUpHomeNext