Chapter 3
Advanced Lambda Expressions
IN THIS CHAPTER
Understanding the C++ lambda expressions
Placing lambda expressions in new places
Creating lambda expressions that are assignable
Expanding parameter packs
The previous chapter demonstrated tasks that you can perform using lambda expressions with most versions of C++ 11 and above. This chapter takes the next step by considering advanced tasks that you can perform using newer versions of C++. In fact, the first section is C++ 20 specific. Some of the remaining sections also work with C++ 17. The point is that if you’re working with an older version of C++, most of what you see in this chapter won’t work. Remember that you can test the examples in this chapter using Wandbox (https://wandbox.org/
) if your C++ compiler doesn’t provide the required C++ 20 functionality.
Also in this chapter, you look at new ways in which to use lambda expressions in C++ 20. Before C++ 20, you couldn’t use a lambda expression in a context requiring an unevaluated expression, including the decltype()
operator, which is the specific topic of this chapter. ...
Get C++ All-in-One For Dummies, 4th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.