- [Instructor] Let's do another lambda example.…This time we'll create a special function,…which we'll call Incrementer.…So we'll come up here, above the main.…We'll do auto space incrementer.…And we will set this equal to lambda.…And this time the lambda's not going to take…any parameters.…And then on the inside we'll say auto increment equal zero.…Then what this function returns is another lambda.…
And then we want to capture increment,…and once again we take no values,…and now we need to use a special keyword…which is called mutable.…Any time you want to modify a value…that's in the closure, you have to say mutable…in order to be able to change it.…And what we're going to do is we're going to say return…increment plus plus.…And then a semicolon.…And we need semicolons here, and here.…
So we have our little function called incrementer,…it is going to start off at zero,…and every time you call it, it's going to increase…its value by one.…And so let's comment this code back in.…Here we call increment the first time,…
- Unit testing and functional programming
- Function and Lambda functions
- C++ templates
- Working with the Standard Template Library and Boost.Hana
- Functional reactive programming
Skill Level Intermediate
2. Functional Programming in Modern C++
3. Template Metaprogramming
4. Functional Reactive Programming
RxCpp library5m 21s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.