| | | | | |

Function Objects -- 3

  • Why function objects instead of functions?
    1. Abstraction -- template parameters
    2. Versatility -- "smart" functions
    3. Performance -- better info for compiler leads to better optimization
  • Most common use in STL: Predicate Classes
    • Function classes that are boolean valued
    • E.g., LessThan<T>, GreaterThan<T>
  • Other examples:
    • Hash objects
    • Wrapper for any function to be applied by generic algorithms (such as makeuppercase -- a wrapper for toupper())
    • IO manipulators
    • Smart functions (have data, will use)

| | Top of Page | 5. Function Classes & - 3 of 11