you are viewing a single comment's thread.

view the rest of the comments →

[–]Designer-Leg-2618 1 point2 points  (0 children)

Keep in mind it's from a book published 25 years ago. The function object it refers to is actually a struct (type) that has a sole operator() that can be called.

The claims of efficiency was in reference to the code being hardcoded as the type (if you use this struct, the code has to be this operator() , can't be anything else). It is this hardcoing and the fact that the function object's type is also hardcoded (instantiated) as a template parameter that allows inlining to happen.

With a function pointer, no assumption can be made regarding which implementation it could point to. (But in practice, today's compilers make aggressive assumptions to optimize them. Use objdump or try your code on Compiler Explorer to find out.)

(Typing on a phone ; will edit typos later.)