Modelling Functions in C++ - Duffy, Daniel J (Financial Instrument Pricing Using C++, 2018)
This chapter first defines what a function is and then discusses the various ways to model functions in C++. The new features are to be found in the C++ standard and are essentially based on the functional programming model, allowing the developers to write code that is more flexible than code based exclusively on subtype polymorphism. The chapter shows examples of these features. The developers can integrate functions, data types and data containers to form generic and reusable structures for numerical applications. A callable object is a general name given to different ways to define functions in C++: A free function; a pointer to a member function; a function object; a lambda function; and a static member function. From a design point of view, the developers wish to write code once by using std::function as the most general way to declare callable objects. The chapter further focuses on the function adapters and binders.