官术网_书友最值得收藏!

3 Exploring Functions

Functions are a fundamental concept in programming; regardless of the topic we discuss, we end up writing functions. Trying to cover functions in a single chapter is not only hard but also not very rational. Being a fundamental element of the language, functions are encountered in every recipe of this book. This chapter, however, covers modern language features related to functions and callable objects, with a focus on lambda expressions, concepts from functional languages such as higher-order functions, and type-safe functions with a variable number of arguments.

The recipes included in this chapter are as follows:

  • Defaulted and deleted functions
  • Using lambdas with standard algorithms
  • Using generic and template lambdas
  • Writing a recursive lambda
  • Writing a function template with a variable number of arguments
  • Using fold expressions to simplify variadic function templates
  • Implementing the higher-order functions map and fold
  • Composing functions into a higher-order function
  • Uniformly invoking anything callable

We will start this chapter by learning about a feature that makes it easier for us to provide special class member functions or prevent any function (member or non-member) from being invoked.

主站蜘蛛池模板: 宝坻区| 南江县| 讷河市| 永康市| 聊城市| 武城县| 阜城县| 新化县| 蒙城县| 志丹县| 永平县| 大理市| 新田县| 黑龙江省| 赣州市| 甘孜| 清丰县| 九寨沟县| 厦门市| 庄河市| 怀宁县| 枣庄市| 成都市| 监利县| 巨野县| 突泉县| 离岛区| 遂宁市| 长岛县| 依安县| 宁强县| 洮南市| 大安市| 鹤壁市| 类乌齐县| 上林县| 盘山县| 文化| 武城县| 定远县| 潼南县|