We will analyse such code
int main() {
std::vector vec(10);
std::generate(begin(vec),
end(vec),
[i{0}]() mutable { return i++; });
print(vec);
return 0;
}
auto lambda = [](auto x, auto y) { return x + y; }
// compiler generated code
struct UnnamedClosureClass {
template
auto operator()(T1 x, T2 y) const {
return x + y;
}
};
auto lambda = UnnamedClosureClass{};
Your abilities after Lambda expressions in C++ training
- you can write own lambda expressions
- you know the implications of different variable capture ways
- you know drawbacks of different ways of passing lambdas, functors and functions
- you can implement own customizable functions
- you know the lifetime issues associated with lambda expressions
- you can simplify template functions with generic lambdas
Agenda
- STL algorithms customization
- the anatomy of lambda
- capture list and mutable lambdas
-
std::function
vs pointer to function - own customizable algorithms
- lifetime issues
-
constexpr
lambdas - generic lambdas
- templates simplification with generic lambdas
Activities
- pre-work to be done before our training
- pre-test pre-test at the beginning
- exercises followed by trainer's implementation
- code review of participants' solutions
- post-work with code review
- post-test one week after the training
- certificate of completion
Duration
- 1 day (7 hours with breaks)
Form
- online
- classroom