function object

function object

Content #

Since C++11, the standard uses the term function object for every object that can be used as a function call. 下面所列均可称为function object:

  1. function pointers
  2. objects of classes with operator ()
  3. objects of classes with a conversion to a point to function
  4. lambdas

C++中的function object比起普通的函数来说,有三个优点,请问是哪三个? #

1.Function objects are “functions with state.” 2.Each function object has its own type. 3.Function objects are usually faster than ordinary functions.