Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F120696114
lambda.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sun, Jul 6, 09:38
Size
702 B
Mime Type
text/x-c
Expires
Tue, Jul 8, 09:38 (2 d)
Engine
blob
Format
Raw Data
Handle
27232097
Attached To
R7571 SP4E-TB-TL-FR
lambda.cpp
View Options
#include <iostream>
void foo1() { std::cout << "Hey" << std::endl; }
int main() {
// call a standard function
foo1();
auto foo2 = []() { std::cout << "Hey again !" << std::endl; };
foo2();
auto foo3 = [](int a, double b) { std::cout << a << "," << b << std::endl; };
foo3(10, 102.3);
int toto = 2;
// captures 'toto' variable
auto foo4 = [toto]() { std::cout << toto << std::endl; };
foo4();
// captures all in current scope
auto foo5 = [&]() { std::cout << toto << std::endl; };
foo5();
// explicit declaration
auto foo6 = []() -> int { return 19; };
auto res = foo6();
// implicit declaration
auto foo7 = []() { return 19.3; };
auto res2 = foo7();
}
Event Timeline
Log In to Comment