C++ lambda and operator syntax -




i last used c++ in 2003, , trying revisit, , learn new stuff. have been working in java while, , learning lambda syntax. saw example in c++, , wondering if explain it:

#include "stdafx.h" #include <iostream> #include <string>  using namespace std;  int = 42; char code = 'c';  [=, &i]() mutable {     i++;     code = 'd';     std::cout << "i: " << << "code " << code << std::endl; }();   void wait() {     cin.clear();     cin.ignore();     cin.get(); }  int main() {     std::cout << "i: " << << "code " << code << endl;       // hold output window open     wait();     return 0; } 

is new lambda syntax operator= overload? i'd write test function, not sure how invoke it.

i can't reply comments still don't have 50 rep points (my previous answer automatically moved comments link).

i found simple way of testing lambda expressions quite don't understand purpose of code sample posting raw here. hope helps, book sfml game development, , uses std::functions

int add(int a, int b) { return + b }; // assign lambda expression function std::function<int(int, int)> adder1 = [] (int a, int b) { return + b; };  int sum = adder1(3, 5); // same add(3, 5) 




wiki

Comments

Popular posts from this blog

python - Read npy file directly from S3 StreamingBody -

python - Minimize function with Scipy minimize -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -