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

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.

主站蜘蛛池模板: 慈利县| 望都县| 峨眉山市| 文成县| 浙江省| 江源县| 微博| 盐津县| 五华县| 昔阳县| 金阳县| 安福县| 玉屏| 尼玛县| 龙山县| 许昌县| 阜平县| 江门市| 西宁市| 吴桥县| 惠安县| 重庆市| 安顺市| 延边| 巩留县| 闻喜县| 读书| 子长县| 紫阳县| 安塞县| 吉林市| 高阳县| 南充市| 饶河县| 客服| 崇州市| 鄂伦春自治旗| 三亚市| 广宗县| 兴海县| 济阳县|