| | | | | |

Summary

  • Functor is a template to express calls with up to 15 parameters
    1. first template parameter is the return type
    2. second template parameter is TypeList of call parameter types
    3. third template parameter is threading model, with default setting
  • Initialize a Functor with any of:
    1. function
    2. functor (aka function object)
    3. pointer to an object and a pointer to a method
    4. another Functor
  • Initialize a Functor with a std::auto_ptr<FunctorImpl<R,TList>> - enables extensions
  • Supports automatic type conversions for arguments and return values
  • Manual disambiguation required for overloaded functions
  • First class sementics: copy, assignment, pass by value
  • Not polymorphic; derive from FunctorImpl, not from Functor
  • Supports argument binding
  • Supports chaining
  • Cost:
    1. Simple Functor objects: one indirection (call via pointer)
    2. Each binding: extra virtual call
    3. Chaining: extra virtual call
    4. Parameters copied only when conversion is necessary
  • FunctorImpl uses small object allocator

| | Top of Page | 8. Generalized Functors - 25 of 26