Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F67282461
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
Fri, Jun 21, 11:27
Size
702 B
Mime Type
text/x-c
Expires
Sun, Jun 23, 11:27 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
18361673
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