SlideShare a Scribd company logo
[](){}();
Or How I Learned To Stop Worrying and Love the
Lambda
Pat Viafore
HSV.cpp Meetup
3/15/2017
Lambda
Expressions
Lambda Expressions
Lambda Calculus
Church-Turing Thesis
Conversion and Reduction
Complicated Mathematics
Functional Programming
Underpinnings of Computer Science
Lisp?
Lambda Expressions in C++
Anonymous
Functions
[](){}
[](){}
[](){}
Function
Body
void print(std::function<bool()> func)
{
std::string str = func() ? "true" : "false";
std::cout << str << “n”;
}
auto isFiveGreaterThanThree = [](){ return 5 > 3; };
print(isFiveGreaterThanThree);
[](){}
Parameters
Function
Body
void print(int param, std::function<bool(int)> func)
{
std::string str = func(param) ? "true" : "false";
std::cout << str << “n”;
}
auto isGreaterThanThree = [](int num){ return num > 3; };
print(5, isGreaterThanThree);
[](){}
Capture
List
Parameters
Function
Body
void print(int num, std::function<bool(int)> func)
{
std::string str = func(num) ? "true" : "false";
std::cout << str << “n”;
}
int target = 3;
auto isGreaterThan = [target](int n){ return n > target; };
target = 6;
print(5, isGreaterThan);
Capture List
By Value By Reference
[this]
[a,b]
[=]
[&a,&b]
[&]
Prefer Explicit Captures Over
Default Captures
class A {
public:
int x;
A(): x(10) {}
std::function<bool()> getLambda()
{
return [=](){ return x+2; };
}
};
int main()
{
A* a = new A();
auto lambda = a->getLambda();
delete a;
lambda();
}
This is implicitly this->x. The this
parameter is what gets captured, not
x.
class A {
public:
int x;
A(): x(10) {}
std::function<bool()> getLambda()
{
return [copy=x](){ return copy+2; };
}
};
int main()
{
A* a = new A();
auto lambda = a->getLambda();
delete a;
lambda();
}
C++14 gives us init captures,
where we can initialize the
variables we capture (useful for
any non-local captures)
Why?
Dependency Injection
Pass a function to inject a dependency
Functional Programming Styles
Mapping and Filtering just got a whole lot easier
Algorithm Library
auto isSpecial = [](MacAddress& mac){ return MacAddress::ItuAddress == mac; };
any_of(macs.begin(), macs.end(), isSpecial);
count_if(macs.begin(), macs.end(), isSpecial);
replace_if(macs.begin(), macs.end(), isSpecial, MacAddress::BlankMacAddress);
sort(ips.begin(), ips.end(), [](IpAddressV4& ip1, IpAddressV4& ip2)
{ return ip1.getNetworkByteOrder() < ip2.getNetworkByteOrder()); });
[](){}
Capture
List
Parameters
Function
Body
();
Twitter:
@PatViaforever
Ad

More Related Content

What's hot (20)

UM2019 Extended BPF: A New Type of Software
UM2019 Extended BPF: A New Type of SoftwareUM2019 Extended BPF: A New Type of Software
UM2019 Extended BPF: A New Type of Software
Brendan Gregg
 
Operators and Expressions in C#
Operators and Expressions in C#Operators and Expressions in C#
Operators and Expressions in C#
Prasanna Kumar SM
 
Compiler Construction | Lecture 1 | What is a compiler?
Compiler Construction | Lecture 1 | What is a compiler?Compiler Construction | Lecture 1 | What is a compiler?
Compiler Construction | Lecture 1 | What is a compiler?
Eelco Visser
 
Intermediate code
Intermediate codeIntermediate code
Intermediate code
Vishal Agarwal
 
Dynamic memory allocation in c++
Dynamic memory allocation in c++Dynamic memory allocation in c++
Dynamic memory allocation in c++
Tech_MX
 
GCC for ARMv8 Aarch64
GCC for ARMv8 Aarch64GCC for ARMv8 Aarch64
GCC for ARMv8 Aarch64
Yi-Hsiu Hsu
 
Peephole Optimization
Peephole OptimizationPeephole Optimization
Peephole Optimization
United International University
 
Yacc
YaccYacc
Yacc
BBDITM LUCKNOW
 
A2 Computing Reverse Polish Notation Part 2
A2 Computing   Reverse Polish Notation Part 2A2 Computing   Reverse Polish Notation Part 2
A2 Computing Reverse Polish Notation Part 2
pstevens1963
 
Functions in C++
Functions in C++Functions in C++
Functions in C++
Mohammed Sikander
 
Q2.12: Debugging with GDB
Q2.12: Debugging with GDBQ2.12: Debugging with GDB
Q2.12: Debugging with GDB
Linaro
 
Modern c++ (C++ 11/14)
Modern c++ (C++ 11/14)Modern c++ (C++ 11/14)
Modern c++ (C++ 11/14)
Geeks Anonymes
 
File Handling In C++
File Handling In C++File Handling In C++
File Handling In C++
Kulachi Hansraj Model School Ashok Vihar
 
Code Optimization
Code OptimizationCode Optimization
Code Optimization
Akhil Kaushik
 
Java Collections API
Java Collections APIJava Collections API
Java Collections API
Alex Miller
 
Toolchain
ToolchainToolchain
Toolchain
Anil Kumar Pugalia
 
Standard Library Functions
Standard Library FunctionsStandard Library Functions
Standard Library Functions
Praveen M Jigajinni
 
Assignment 3 push down automata final
Assignment 3 push down automata finalAssignment 3 push down automata final
Assignment 3 push down automata final
Pawan Goel
 
The TCP/IP Stack in the Linux Kernel
The TCP/IP Stack in the Linux KernelThe TCP/IP Stack in the Linux Kernel
The TCP/IP Stack in the Linux Kernel
Divye Kapoor
 
Data types, Variables, Expressions & Arithmetic Operators in java
Data types, Variables, Expressions & Arithmetic Operators in javaData types, Variables, Expressions & Arithmetic Operators in java
Data types, Variables, Expressions & Arithmetic Operators in java
Javed Rashid
 
UM2019 Extended BPF: A New Type of Software
UM2019 Extended BPF: A New Type of SoftwareUM2019 Extended BPF: A New Type of Software
UM2019 Extended BPF: A New Type of Software
Brendan Gregg
 
Operators and Expressions in C#
Operators and Expressions in C#Operators and Expressions in C#
Operators and Expressions in C#
Prasanna Kumar SM
 
Compiler Construction | Lecture 1 | What is a compiler?
Compiler Construction | Lecture 1 | What is a compiler?Compiler Construction | Lecture 1 | What is a compiler?
Compiler Construction | Lecture 1 | What is a compiler?
Eelco Visser
 
Dynamic memory allocation in c++
Dynamic memory allocation in c++Dynamic memory allocation in c++
Dynamic memory allocation in c++
Tech_MX
 
GCC for ARMv8 Aarch64
GCC for ARMv8 Aarch64GCC for ARMv8 Aarch64
GCC for ARMv8 Aarch64
Yi-Hsiu Hsu
 
A2 Computing Reverse Polish Notation Part 2
A2 Computing   Reverse Polish Notation Part 2A2 Computing   Reverse Polish Notation Part 2
A2 Computing Reverse Polish Notation Part 2
pstevens1963
 
Q2.12: Debugging with GDB
Q2.12: Debugging with GDBQ2.12: Debugging with GDB
Q2.12: Debugging with GDB
Linaro
 
Modern c++ (C++ 11/14)
Modern c++ (C++ 11/14)Modern c++ (C++ 11/14)
Modern c++ (C++ 11/14)
Geeks Anonymes
 
Java Collections API
Java Collections APIJava Collections API
Java Collections API
Alex Miller
 
Assignment 3 push down automata final
Assignment 3 push down automata finalAssignment 3 push down automata final
Assignment 3 push down automata final
Pawan Goel
 
The TCP/IP Stack in the Linux Kernel
The TCP/IP Stack in the Linux KernelThe TCP/IP Stack in the Linux Kernel
The TCP/IP Stack in the Linux Kernel
Divye Kapoor
 
Data types, Variables, Expressions & Arithmetic Operators in java
Data types, Variables, Expressions & Arithmetic Operators in javaData types, Variables, Expressions & Arithmetic Operators in java
Data types, Variables, Expressions & Arithmetic Operators in java
Javed Rashid
 

Viewers also liked (17)

BDD to the Bone: Using Behave and Selenium to Test-Drive Web Applications
BDD to the Bone: Using Behave and Selenium to Test-Drive Web ApplicationsBDD to the Bone: Using Behave and Selenium to Test-Drive Web Applications
BDD to the Bone: Using Behave and Selenium to Test-Drive Web Applications
Patrick Viafore
 
мадоу № 82
мадоу № 82мадоу № 82
мадоу № 82
Skazka82
 
Presentació pati
Presentació patiPresentació pati
Presentació pati
Esther Dalmau Palomar
 
Magazine front covers 4
Magazine front covers 4Magazine front covers 4
Magazine front covers 4
ah05007283
 
Virus360 supersaiyajinlegendario.exe
Virus360 supersaiyajinlegendario.exeVirus360 supersaiyajinlegendario.exe
Virus360 supersaiyajinlegendario.exe
Mery Noguera
 
la comunicación en la sociedad
la comunicación en la sociedad la comunicación en la sociedad
la comunicación en la sociedad
maria camila suarez betancur
 
Guide hygiene informatique_anssi
Guide hygiene informatique_anssiGuide hygiene informatique_anssi
Guide hygiene informatique_anssi
kabengniga ibrahima soro
 
Industrial Equipment.
Industrial Equipment. Industrial Equipment.
Industrial Equipment.
Elena Vishnevskaya
 
Basic functionalities of ez cast dongle
Basic functionalities of ez cast dongleBasic functionalities of ez cast dongle
Basic functionalities of ez cast dongle
wifi ezcast dongle
 
Dp1
Dp1Dp1
Dp1
Hemer Hadyn Calderon Alvites
 
TRATAMIENTO AGUA EN HEMODIALISIS
TRATAMIENTO AGUA EN HEMODIALISISTRATAMIENTO AGUA EN HEMODIALISIS
TRATAMIENTO AGUA EN HEMODIALISIS
gustavo diaz nuñez
 
PRINCIPIOS BIOFISICOS DE LA HEMODIALISIS
PRINCIPIOS BIOFISICOS DE LA HEMODIALISISPRINCIPIOS BIOFISICOS DE LA HEMODIALISIS
PRINCIPIOS BIOFISICOS DE LA HEMODIALISIS
gustavo diaz nuñez
 
Lagopusで試すFW
Lagopusで試すFWLagopusで試すFW
Lagopusで試すFW
Tomoya Hibi
 
FARMACOCINETICA: ABSORCIÓN Y DISTRIBUCIÓN
FARMACOCINETICA: ABSORCIÓN Y DISTRIBUCIÓN FARMACOCINETICA: ABSORCIÓN Y DISTRIBUCIÓN
FARMACOCINETICA: ABSORCIÓN Y DISTRIBUCIÓN
evelyn sagredo
 
Técnicas del coaching
Técnicas del coachingTécnicas del coaching
Técnicas del coaching
Rondonjhenyfer
 
CArcMOOC 06.04 - Dynamic optimizations
CArcMOOC 06.04 - Dynamic optimizationsCArcMOOC 06.04 - Dynamic optimizations
CArcMOOC 06.04 - Dynamic optimizations
Alessandro Bogliolo
 
BDD to the Bone: Using Behave and Selenium to Test-Drive Web Applications
BDD to the Bone: Using Behave and Selenium to Test-Drive Web ApplicationsBDD to the Bone: Using Behave and Selenium to Test-Drive Web Applications
BDD to the Bone: Using Behave and Selenium to Test-Drive Web Applications
Patrick Viafore
 
мадоу № 82
мадоу № 82мадоу № 82
мадоу № 82
Skazka82
 
Magazine front covers 4
Magazine front covers 4Magazine front covers 4
Magazine front covers 4
ah05007283
 
Virus360 supersaiyajinlegendario.exe
Virus360 supersaiyajinlegendario.exeVirus360 supersaiyajinlegendario.exe
Virus360 supersaiyajinlegendario.exe
Mery Noguera
 
Basic functionalities of ez cast dongle
Basic functionalities of ez cast dongleBasic functionalities of ez cast dongle
Basic functionalities of ez cast dongle
wifi ezcast dongle
 
TRATAMIENTO AGUA EN HEMODIALISIS
TRATAMIENTO AGUA EN HEMODIALISISTRATAMIENTO AGUA EN HEMODIALISIS
TRATAMIENTO AGUA EN HEMODIALISIS
gustavo diaz nuñez
 
PRINCIPIOS BIOFISICOS DE LA HEMODIALISIS
PRINCIPIOS BIOFISICOS DE LA HEMODIALISISPRINCIPIOS BIOFISICOS DE LA HEMODIALISIS
PRINCIPIOS BIOFISICOS DE LA HEMODIALISIS
gustavo diaz nuñez
 
Lagopusで試すFW
Lagopusで試すFWLagopusで試すFW
Lagopusで試すFW
Tomoya Hibi
 
FARMACOCINETICA: ABSORCIÓN Y DISTRIBUCIÓN
FARMACOCINETICA: ABSORCIÓN Y DISTRIBUCIÓN FARMACOCINETICA: ABSORCIÓN Y DISTRIBUCIÓN
FARMACOCINETICA: ABSORCIÓN Y DISTRIBUCIÓN
evelyn sagredo
 
Técnicas del coaching
Técnicas del coachingTécnicas del coaching
Técnicas del coaching
Rondonjhenyfer
 
CArcMOOC 06.04 - Dynamic optimizations
CArcMOOC 06.04 - Dynamic optimizationsCArcMOOC 06.04 - Dynamic optimizations
CArcMOOC 06.04 - Dynamic optimizations
Alessandro Bogliolo
 
Ad

Similar to Lambda Expressions in C++ (20)

The Arrow Library in Kotlin
The Arrow Library in KotlinThe Arrow Library in Kotlin
The Arrow Library in Kotlin
Garth Gilmour
 
Developer Experience i TypeScript. Najbardziej ikoniczne duo
Developer Experience i TypeScript. Najbardziej ikoniczne duoDeveloper Experience i TypeScript. Najbardziej ikoniczne duo
Developer Experience i TypeScript. Najbardziej ikoniczne duo
The Software House
 
Templates in C++
Templates in C++Templates in C++
Templates in C++
Tech_MX
 
Let Us Learn Lambda Using C# 3.0
Let Us Learn Lambda Using C# 3.0Let Us Learn Lambda Using C# 3.0
Let Us Learn Lambda Using C# 3.0
Sheik Uduman Ali
 
Library functions in c++
Library functions in c++Library functions in c++
Library functions in c++
Neeru Mittal
 
Fun with Lambdas: C++14 Style (part 2)
Fun with Lambdas: C++14 Style (part 2)Fun with Lambdas: C++14 Style (part 2)
Fun with Lambdas: C++14 Style (part 2)
Sumant Tambe
 
An imperative study of c
An imperative study of cAn imperative study of c
An imperative study of c
Tushar B Kute
 
POEPPSGNHwkejnkweoewnkenjwjewkjewoewkjewijewjk
POEPPSGNHwkejnkweoewnkenjwjewkjewoewkjewijewjkPOEPPSGNHwkejnkweoewnkenjwjewkjewoewkjewijewjk
POEPPSGNHwkejnkweoewnkenjwjewkjewoewkjewijewjk
hanumanthumanideeph6
 
SaraPIC
SaraPICSaraPIC
SaraPIC
Sara Sahu
 
Input output functions
Input output functionsInput output functions
Input output functions
hyderali123
 
NetPonto - The Future Of C# - NetConf Edition
NetPonto - The Future Of C# - NetConf EditionNetPonto - The Future Of C# - NetConf Edition
NetPonto - The Future Of C# - NetConf Edition
Paulo Morgado
 
String Manipulation Function and Header File Functions
String Manipulation Function and Header File FunctionsString Manipulation Function and Header File Functions
String Manipulation Function and Header File Functions
Bosco Technical Training Society, Don Bosco Technical School (Aff. GGSIP University, New Delhi)
 
Csharp4 delegates lambda_and_events
Csharp4 delegates lambda_and_eventsCsharp4 delegates lambda_and_events
Csharp4 delegates lambda_and_events
Abed Bukhari
 
Alexey Tsoy Meta Programming in C++ 16.11.17
Alexey Tsoy Meta Programming in C++ 16.11.17Alexey Tsoy Meta Programming in C++ 16.11.17
Alexey Tsoy Meta Programming in C++ 16.11.17
LogeekNightUkraine
 
CS101- Introduction to Computing- Lecture 38
CS101- Introduction to Computing- Lecture 38CS101- Introduction to Computing- Lecture 38
CS101- Introduction to Computing- Lecture 38
Bilal Ahmed
 
Unit 5 Foc
Unit 5 FocUnit 5 Foc
Unit 5 Foc
JAYA
 
USER DEFINE FUNCTIONS IN PYTHON
USER DEFINE FUNCTIONS IN PYTHONUSER DEFINE FUNCTIONS IN PYTHON
USER DEFINE FUNCTIONS IN PYTHON
vikram mahendra
 
Apache Commons - Don\'t re-invent the wheel
Apache Commons - Don\'t re-invent the wheelApache Commons - Don\'t re-invent the wheel
Apache Commons - Don\'t re-invent the wheel
tcurdt
 
Scala @ TomTom
Scala @ TomTomScala @ TomTom
Scala @ TomTom
Eric Bowman
 
.net progrmming part1
.net progrmming part1.net progrmming part1
.net progrmming part1
Dr.M.Karthika parthasarathy
 
The Arrow Library in Kotlin
The Arrow Library in KotlinThe Arrow Library in Kotlin
The Arrow Library in Kotlin
Garth Gilmour
 
Developer Experience i TypeScript. Najbardziej ikoniczne duo
Developer Experience i TypeScript. Najbardziej ikoniczne duoDeveloper Experience i TypeScript. Najbardziej ikoniczne duo
Developer Experience i TypeScript. Najbardziej ikoniczne duo
The Software House
 
Templates in C++
Templates in C++Templates in C++
Templates in C++
Tech_MX
 
Let Us Learn Lambda Using C# 3.0
Let Us Learn Lambda Using C# 3.0Let Us Learn Lambda Using C# 3.0
Let Us Learn Lambda Using C# 3.0
Sheik Uduman Ali
 
Library functions in c++
Library functions in c++Library functions in c++
Library functions in c++
Neeru Mittal
 
Fun with Lambdas: C++14 Style (part 2)
Fun with Lambdas: C++14 Style (part 2)Fun with Lambdas: C++14 Style (part 2)
Fun with Lambdas: C++14 Style (part 2)
Sumant Tambe
 
An imperative study of c
An imperative study of cAn imperative study of c
An imperative study of c
Tushar B Kute
 
POEPPSGNHwkejnkweoewnkenjwjewkjewoewkjewijewjk
POEPPSGNHwkejnkweoewnkenjwjewkjewoewkjewijewjkPOEPPSGNHwkejnkweoewnkenjwjewkjewoewkjewijewjk
POEPPSGNHwkejnkweoewnkenjwjewkjewoewkjewijewjk
hanumanthumanideeph6
 
Input output functions
Input output functionsInput output functions
Input output functions
hyderali123
 
NetPonto - The Future Of C# - NetConf Edition
NetPonto - The Future Of C# - NetConf EditionNetPonto - The Future Of C# - NetConf Edition
NetPonto - The Future Of C# - NetConf Edition
Paulo Morgado
 
Csharp4 delegates lambda_and_events
Csharp4 delegates lambda_and_eventsCsharp4 delegates lambda_and_events
Csharp4 delegates lambda_and_events
Abed Bukhari
 
Alexey Tsoy Meta Programming in C++ 16.11.17
Alexey Tsoy Meta Programming in C++ 16.11.17Alexey Tsoy Meta Programming in C++ 16.11.17
Alexey Tsoy Meta Programming in C++ 16.11.17
LogeekNightUkraine
 
CS101- Introduction to Computing- Lecture 38
CS101- Introduction to Computing- Lecture 38CS101- Introduction to Computing- Lecture 38
CS101- Introduction to Computing- Lecture 38
Bilal Ahmed
 
Unit 5 Foc
Unit 5 FocUnit 5 Foc
Unit 5 Foc
JAYA
 
USER DEFINE FUNCTIONS IN PYTHON
USER DEFINE FUNCTIONS IN PYTHONUSER DEFINE FUNCTIONS IN PYTHON
USER DEFINE FUNCTIONS IN PYTHON
vikram mahendra
 
Apache Commons - Don\'t re-invent the wheel
Apache Commons - Don\'t re-invent the wheelApache Commons - Don\'t re-invent the wheel
Apache Commons - Don\'t re-invent the wheel
tcurdt
 
Ad

More from Patrick Viafore (12)

Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024
Patrick Viafore
 
User-Defined Types.pdf
User-Defined Types.pdfUser-Defined Types.pdf
User-Defined Types.pdf
Patrick Viafore
 
The Most Misunderstood Line In Zen Of Python.pdf
The Most Misunderstood Line In Zen Of Python.pdfThe Most Misunderstood Line In Zen Of Python.pdf
The Most Misunderstood Line In Zen Of Python.pdf
Patrick Viafore
 
Robust Python.pptx
Robust Python.pptxRobust Python.pptx
Robust Python.pptx
Patrick Viafore
 
Tip Top Typing - A Look at Python Typing
Tip Top Typing - A Look at Python TypingTip Top Typing - A Look at Python Typing
Tip Top Typing - A Look at Python Typing
Patrick Viafore
 
RunC, Docker, RunC
RunC, Docker, RunCRunC, Docker, RunC
RunC, Docker, RunC
Patrick Viafore
 
DevSpace 2018 - Practical Computer Science: What You Need To Know Without Th...
 DevSpace 2018 - Practical Computer Science: What You Need To Know Without Th... DevSpace 2018 - Practical Computer Science: What You Need To Know Without Th...
DevSpace 2018 - Practical Computer Science: What You Need To Know Without Th...
Patrick Viafore
 
Controlling Raspberry Pis With Your Phone Using Python
Controlling Raspberry Pis With Your Phone Using PythonControlling Raspberry Pis With Your Phone Using Python
Controlling Raspberry Pis With Your Phone Using Python
Patrick Viafore
 
C++17 not your father’s c++
C++17  not your father’s c++C++17  not your father’s c++
C++17 not your father’s c++
Patrick Viafore
 
Building a development community within your workplace
Building a development community within your workplaceBuilding a development community within your workplace
Building a development community within your workplace
Patrick Viafore
 
Hsv.py Lightning Talk - Bottle
Hsv.py Lightning Talk - BottleHsv.py Lightning Talk - Bottle
Hsv.py Lightning Talk - Bottle
Patrick Viafore
 
Controlling the browser through python and selenium
Controlling the browser through python and seleniumControlling the browser through python and selenium
Controlling the browser through python and selenium
Patrick Viafore
 
Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024
Patrick Viafore
 
The Most Misunderstood Line In Zen Of Python.pdf
The Most Misunderstood Line In Zen Of Python.pdfThe Most Misunderstood Line In Zen Of Python.pdf
The Most Misunderstood Line In Zen Of Python.pdf
Patrick Viafore
 
Tip Top Typing - A Look at Python Typing
Tip Top Typing - A Look at Python TypingTip Top Typing - A Look at Python Typing
Tip Top Typing - A Look at Python Typing
Patrick Viafore
 
DevSpace 2018 - Practical Computer Science: What You Need To Know Without Th...
 DevSpace 2018 - Practical Computer Science: What You Need To Know Without Th... DevSpace 2018 - Practical Computer Science: What You Need To Know Without Th...
DevSpace 2018 - Practical Computer Science: What You Need To Know Without Th...
Patrick Viafore
 
Controlling Raspberry Pis With Your Phone Using Python
Controlling Raspberry Pis With Your Phone Using PythonControlling Raspberry Pis With Your Phone Using Python
Controlling Raspberry Pis With Your Phone Using Python
Patrick Viafore
 
C++17 not your father’s c++
C++17  not your father’s c++C++17  not your father’s c++
C++17 not your father’s c++
Patrick Viafore
 
Building a development community within your workplace
Building a development community within your workplaceBuilding a development community within your workplace
Building a development community within your workplace
Patrick Viafore
 
Hsv.py Lightning Talk - Bottle
Hsv.py Lightning Talk - BottleHsv.py Lightning Talk - Bottle
Hsv.py Lightning Talk - Bottle
Patrick Viafore
 
Controlling the browser through python and selenium
Controlling the browser through python and seleniumControlling the browser through python and selenium
Controlling the browser through python and selenium
Patrick Viafore
 

Recently uploaded (20)

How can one start with crypto wallet development.pptx
How can one start with crypto wallet development.pptxHow can one start with crypto wallet development.pptx
How can one start with crypto wallet development.pptx
laravinson24
 
Microsoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdf
Microsoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdfMicrosoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdf
Microsoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdf
TechSoup
 
EASEUS Partition Master Crack + License Code
EASEUS Partition Master Crack + License CodeEASEUS Partition Master Crack + License Code
EASEUS Partition Master Crack + License Code
aneelaramzan63
 
Avast Premium Security Crack FREE Latest Version 2025
Avast Premium Security Crack FREE Latest Version 2025Avast Premium Security Crack FREE Latest Version 2025
Avast Premium Security Crack FREE Latest Version 2025
mu394968
 
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software DevelopmentSecure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Shubham Joshi
 
Expand your AI adoption with AgentExchange
Expand your AI adoption with AgentExchangeExpand your AI adoption with AgentExchange
Expand your AI adoption with AgentExchange
Fexle Services Pvt. Ltd.
 
Solidworks Crack 2025 latest new + license code
Solidworks Crack 2025 latest new + license codeSolidworks Crack 2025 latest new + license code
Solidworks Crack 2025 latest new + license code
aneelaramzan63
 
Download YouTube By Click 2025 Free Full Activated
Download YouTube By Click 2025 Free Full ActivatedDownload YouTube By Click 2025 Free Full Activated
Download YouTube By Click 2025 Free Full Activated
saniamalik72555
 
PDF Reader Pro Crack Latest Version FREE Download 2025
PDF Reader Pro Crack Latest Version FREE Download 2025PDF Reader Pro Crack Latest Version FREE Download 2025
PDF Reader Pro Crack Latest Version FREE Download 2025
mu394968
 
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
Andre Hora
 
Designing AI-Powered APIs on Azure: Best Practices& Considerations
Designing AI-Powered APIs on Azure: Best Practices& ConsiderationsDesigning AI-Powered APIs on Azure: Best Practices& Considerations
Designing AI-Powered APIs on Azure: Best Practices& Considerations
Dinusha Kumarasiri
 
Adobe Lightroom Classic Crack FREE Latest link 2025
Adobe Lightroom Classic Crack FREE Latest link 2025Adobe Lightroom Classic Crack FREE Latest link 2025
Adobe Lightroom Classic Crack FREE Latest link 2025
kashifyounis067
 
Top 10 Client Portal Software Solutions for 2025.docx
Top 10 Client Portal Software Solutions for 2025.docxTop 10 Client Portal Software Solutions for 2025.docx
Top 10 Client Portal Software Solutions for 2025.docx
Portli
 
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Ranjan Baisak
 
Douwan Crack 2025 new verson+ License code
Douwan Crack 2025 new verson+ License codeDouwan Crack 2025 new verson+ License code
Douwan Crack 2025 new verson+ License code
aneelaramzan63
 
How to Optimize Your AWS Environment for Improved Cloud Performance
How to Optimize Your AWS Environment for Improved Cloud PerformanceHow to Optimize Your AWS Environment for Improved Cloud Performance
How to Optimize Your AWS Environment for Improved Cloud Performance
ThousandEyes
 
The Significance of Hardware in Information Systems.pdf
The Significance of Hardware in Information Systems.pdfThe Significance of Hardware in Information Systems.pdf
The Significance of Hardware in Information Systems.pdf
drewplanas10
 
WinRAR Crack for Windows (100% Working 2025)
WinRAR Crack for Windows (100% Working 2025)WinRAR Crack for Windows (100% Working 2025)
WinRAR Crack for Windows (100% Working 2025)
sh607827
 
F-Secure Freedome VPN 2025 Crack Plus Activation New Version
F-Secure Freedome VPN 2025 Crack Plus Activation  New VersionF-Secure Freedome VPN 2025 Crack Plus Activation  New Version
F-Secure Freedome VPN 2025 Crack Plus Activation New Version
saimabibi60507
 
Societal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainabilitySocietal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainability
Jordi Cabot
 
How can one start with crypto wallet development.pptx
How can one start with crypto wallet development.pptxHow can one start with crypto wallet development.pptx
How can one start with crypto wallet development.pptx
laravinson24
 
Microsoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdf
Microsoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdfMicrosoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdf
Microsoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdf
TechSoup
 
EASEUS Partition Master Crack + License Code
EASEUS Partition Master Crack + License CodeEASEUS Partition Master Crack + License Code
EASEUS Partition Master Crack + License Code
aneelaramzan63
 
Avast Premium Security Crack FREE Latest Version 2025
Avast Premium Security Crack FREE Latest Version 2025Avast Premium Security Crack FREE Latest Version 2025
Avast Premium Security Crack FREE Latest Version 2025
mu394968
 
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software DevelopmentSecure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Shubham Joshi
 
Expand your AI adoption with AgentExchange
Expand your AI adoption with AgentExchangeExpand your AI adoption with AgentExchange
Expand your AI adoption with AgentExchange
Fexle Services Pvt. Ltd.
 
Solidworks Crack 2025 latest new + license code
Solidworks Crack 2025 latest new + license codeSolidworks Crack 2025 latest new + license code
Solidworks Crack 2025 latest new + license code
aneelaramzan63
 
Download YouTube By Click 2025 Free Full Activated
Download YouTube By Click 2025 Free Full ActivatedDownload YouTube By Click 2025 Free Full Activated
Download YouTube By Click 2025 Free Full Activated
saniamalik72555
 
PDF Reader Pro Crack Latest Version FREE Download 2025
PDF Reader Pro Crack Latest Version FREE Download 2025PDF Reader Pro Crack Latest Version FREE Download 2025
PDF Reader Pro Crack Latest Version FREE Download 2025
mu394968
 
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
Andre Hora
 
Designing AI-Powered APIs on Azure: Best Practices& Considerations
Designing AI-Powered APIs on Azure: Best Practices& ConsiderationsDesigning AI-Powered APIs on Azure: Best Practices& Considerations
Designing AI-Powered APIs on Azure: Best Practices& Considerations
Dinusha Kumarasiri
 
Adobe Lightroom Classic Crack FREE Latest link 2025
Adobe Lightroom Classic Crack FREE Latest link 2025Adobe Lightroom Classic Crack FREE Latest link 2025
Adobe Lightroom Classic Crack FREE Latest link 2025
kashifyounis067
 
Top 10 Client Portal Software Solutions for 2025.docx
Top 10 Client Portal Software Solutions for 2025.docxTop 10 Client Portal Software Solutions for 2025.docx
Top 10 Client Portal Software Solutions for 2025.docx
Portli
 
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Ranjan Baisak
 
Douwan Crack 2025 new verson+ License code
Douwan Crack 2025 new verson+ License codeDouwan Crack 2025 new verson+ License code
Douwan Crack 2025 new verson+ License code
aneelaramzan63
 
How to Optimize Your AWS Environment for Improved Cloud Performance
How to Optimize Your AWS Environment for Improved Cloud PerformanceHow to Optimize Your AWS Environment for Improved Cloud Performance
How to Optimize Your AWS Environment for Improved Cloud Performance
ThousandEyes
 
The Significance of Hardware in Information Systems.pdf
The Significance of Hardware in Information Systems.pdfThe Significance of Hardware in Information Systems.pdf
The Significance of Hardware in Information Systems.pdf
drewplanas10
 
WinRAR Crack for Windows (100% Working 2025)
WinRAR Crack for Windows (100% Working 2025)WinRAR Crack for Windows (100% Working 2025)
WinRAR Crack for Windows (100% Working 2025)
sh607827
 
F-Secure Freedome VPN 2025 Crack Plus Activation New Version
F-Secure Freedome VPN 2025 Crack Plus Activation  New VersionF-Secure Freedome VPN 2025 Crack Plus Activation  New Version
F-Secure Freedome VPN 2025 Crack Plus Activation New Version
saimabibi60507
 
Societal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainabilitySocietal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainability
Jordi Cabot
 

Lambda Expressions in C++

  • 1. [](){}(); Or How I Learned To Stop Worrying and Love the Lambda Pat Viafore HSV.cpp Meetup 3/15/2017
  • 3. Lambda Expressions Lambda Calculus Church-Turing Thesis Conversion and Reduction Complicated Mathematics Functional Programming Underpinnings of Computer Science Lisp?
  • 9. void print(std::function<bool()> func) { std::string str = func() ? "true" : "false"; std::cout << str << “n”; } auto isFiveGreaterThanThree = [](){ return 5 > 3; }; print(isFiveGreaterThanThree);
  • 11. void print(int param, std::function<bool(int)> func) { std::string str = func(param) ? "true" : "false"; std::cout << str << “n”; } auto isGreaterThanThree = [](int num){ return num > 3; }; print(5, isGreaterThanThree);
  • 13. void print(int num, std::function<bool(int)> func) { std::string str = func(num) ? "true" : "false"; std::cout << str << “n”; } int target = 3; auto isGreaterThan = [target](int n){ return n > target; }; target = 6; print(5, isGreaterThan);
  • 14. Capture List By Value By Reference [this] [a,b] [=] [&a,&b] [&] Prefer Explicit Captures Over Default Captures
  • 15. class A { public: int x; A(): x(10) {} std::function<bool()> getLambda() { return [=](){ return x+2; }; } }; int main() { A* a = new A(); auto lambda = a->getLambda(); delete a; lambda(); } This is implicitly this->x. The this parameter is what gets captured, not x.
  • 16. class A { public: int x; A(): x(10) {} std::function<bool()> getLambda() { return [copy=x](){ return copy+2; }; } }; int main() { A* a = new A(); auto lambda = a->getLambda(); delete a; lambda(); } C++14 gives us init captures, where we can initialize the variables we capture (useful for any non-local captures)
  • 17. Why? Dependency Injection Pass a function to inject a dependency Functional Programming Styles Mapping and Filtering just got a whole lot easier Algorithm Library auto isSpecial = [](MacAddress& mac){ return MacAddress::ItuAddress == mac; }; any_of(macs.begin(), macs.end(), isSpecial); count_if(macs.begin(), macs.end(), isSpecial); replace_if(macs.begin(), macs.end(), isSpecial, MacAddress::BlankMacAddress); sort(ips.begin(), ips.end(), [](IpAddressV4& ip1, IpAddressV4& ip2) { return ip1.getNetworkByteOrder() < ip2.getNetworkByteOrder()); });