30/09/2018, 18:11

What does assignment operator mean in Lambda expression C++ 14

Let’s see the picture above, it illustrate the part of lambda expression.
I know [ ] is capture clause used for captured local variable, we can capture a variable either by value or by reference (&). But what does ‘=’ operator in capture clause mean?

viết 20:21 ngày 30/09/2018

capture by value. In this case it makes copy of x and y (so x = y and y = n will have no effect)

The capture-list is a comma-separated list of zero or more captures, optionally beginning with the capture-default. The only capture defaults are & (implicitly catch the odr-used automatic variables and this by reference) and = (implicitly catch the odr-used automatic variables and this by value).

and the symbol ‘=’ in this context is called “capture-default”, not “operator”

Bài liên quan
0