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

Simplifying the function notation using a Lambda expression

The Lambda expression is an anonymous notation that represents something that performs an operation or calculation. In functional programming, the Lambda expression is useful to produce the first class and pure function, which we will discuss in separate chapters in this book. For now, let's familiarize ourselves with this new feature introduced in C++11 by investigating three basic parts of the Lambda expression:

  • capturing list: []
  • parameter list: ()
  • body: {}

The order of these three basic parts is as follows:

    [](){} 

The capturing list part is also used as a mark to identify the Lambda expression. It is a placeholder to value to be involved in the expression. The only capture defaults are the ampersand symbol (&), which will implicitly capture the automatic variables by reference, and the equal sign (=), which will implicitly capture the automatic variables by copy (we will discuss it further in the upcoming section). The parameter list is similar to the capturing list in every function where we can pass the value to it. The body is the implementation of the function itself.

主站蜘蛛池模板: 陇南市| 九龙城区| 阆中市| 五大连池市| 霞浦县| 富源县| 深泽县| 沙湾县| 鄯善县| 革吉县| 九寨沟县| 理塘县| 昆明市| 闵行区| 岚皋县| 永靖县| 清远市| 蒙山县| 双柏县| 南川市| 苍梧县| 柏乡县| 克东县| 呼和浩特市| 阿拉善左旗| 黔西县| 新余市| 延边| 淅川县| 南丹县| 交城县| 张家口市| 台山市| 攀枝花市| 汽车| 邵武市| 高陵县| 突泉县| 锦州市| 寿光市| 济源市|