Summary
- Functor is a template to express calls with up to 15 parameters
- first template parameter is the return type
- second template parameter is TypeList of call parameter types
- third template parameter is threading model, with default setting
- Initialize a Functor with any of:
- function
- functor (aka function object)
- pointer to an object and a pointer to a method
- 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:
- Simple Functor objects: one indirection (call via pointer)
- Each binding: extra virtual call
- Chaining: extra virtual call
- Parameters copied only when conversion is necessary
- FunctorImpl uses small object allocator
|