I am wondering how does a lambda expression take its arguments?
Usually, when we pass variables into parameters, we need to match the number of arguments and number of variables. for example, for regular function void foo(int a, int b)
we need to pass two int
variables to the functions.
However, with lambda expression we don't need to do it. for example:
sort(intContainer.begin(), intContainer.end(), [](int i, int j){return i>j;});
This function will sort the container in descending order.
I am wondering how the lambda expression takes int j
argument. (when I assume that one iterator holds one int value taking variable for int i is makes sense)
does it related with the way how an iterator works??