Skip to content
0:00 / 0:00

#c++#lambdas

C++ Weekly - Ep 49 - Why Inherit From Lambdas?

C++ Weekly With Jason Turner

130K subscribers • 5 videos on Hallway

YouTube

Intermediate. Assumes working knowledge.

15K views9 years ago1 recommendation

Programming languagesC++

Jason Turner explains the utility of inheriting from lambdas in C++ and how it enables powerful patterns.

☟☟ Awesome T-Shirts! Sponsors! Books! ☟☟ C++ Best Practices Workshops Near You: Preview: youtu.be/Ipr6ntCAm9A Sep 12-13 (Aurora, CO): cppcon.org/class-2026-best-practices/ Sep 21-22 (Kongsberg, NO): ndctechtown.com/tickets Oct 14 (Breda, NL): cppunderthesea.nl/#workshops T-SHIRTS AVAILABLE! ► The best C++ T-Shirts anywhere! jason-turner-shop.fourthwall.com/ WANT MORE JASON? ► My Training Classes: emptycrate.com/training.html ► Follow me on twitter: twitter.com/lefticus SUPPORT THE CHANNEL ► Patreon: patreon.com/lefticus ► Github Sponsors: github.com/sponsors/lefticus ► Paypal Donation: paypal.com/donate/?hosted_button_id=PQ4A2V6ZZFQEU GET INVOLVED ► Video Idea List: github.com/lefticus/cpp_weekly/issues JASON'S BOOKS ► C++23 Best Practices Amazon Paperback: amzn.to/47MEAhj Leanpub Ebook: leanpub.com/cpp23_best_practices/ ► C++ Best Practices Amazon Paperback: amzn.to/3wpAU3Z Leanpub Ebook: leanpub.com/cppbestpractices JASON'S PUZZLE BOOKS ► Programming Puzzles Big Book Amazon Paperback: amzn.to/4plj0cb Leanpub Ebook: leanpub.com/programming_puzzles_for_everyone ► Object Lifetime Puzzlers Book 1 Amazon Paperback: amzn.to/3g6Ervj Leanpub Ebook: leanpub.com/objectlifetimepuzzlers_book1 ► Object Lifetime Puzzlers Book 2 Amazon Paperback: amzn.to/3whdUDU Leanpub Ebook: leanpub.com/objectlifetimepuzzlers_book2 ► Object Lifetime Puzzlers Book 3 Leanpub Ebook: leanpub.com/objectlifetimepuzzlers_book3 ► Copy and Reference Puzzlers Book 1 Amazon Paperback: amzn.to/3g7ZVb9 Leanpub Ebook: leanpub.com/copyandreferencepuzzlers_book1 ► Copy and Reference Puzzlers Book 2 Amazon Paperback: amzn.to/3X1LOIx Leanpub Ebook: leanpub.com/copyandreferencepuzzlers_book2 ► Copy and Reference Puzzlers Book 3 Leanpub Ebook: leanpub.com/copyandreferencepuzzlers_book3 ► OpCode Puzzlers Book 1 Amazon Paperback: amzn.to/3KCNJg6 Leanpub Ebook: leanpub.com/opcodepuzzlers_book1 RECOMMENDED BOOKS ► Bjarne Stroustrup's A Tour of C++ (now with C++20/23!): amzn.to/3X4Wypr AWESOME PROJECTS ► The C++ Starter Project - Gets you started with Best Practices Quickly - github.com/cpp-best-practices/cpp_starter_project ► C++ Best Practices Forkable Coding Standards - github.com/cpp-best-practices/cppbestpractices O'Reilly VIDEOS ► Inheritance and Polymorphism in C++ - oreilly.com/library/view/inheritance-and-polymorphism/978149… ► Learning C++ Best Practices - oreilly.com/library/view/learning-c-best/9781491954898/ Source: godbolt.org/g/AD2eu3

Why it's here

1 person recommends this

What people say. Recommended as part of a series explaining how to implement clean visitor patterns in modern C++.

u/parnmattin r/programming • Recommends

On “std::visit is Everything Wrong with Modern C++”

It's a deduction guide. It is needed such that you do not need to explicit specify the template types. This is because there is no constructor within `overloaded` which would get that deduction implied. Due to C++17 also adding aggregate initialisation of base classes, an explicit constructor isn't needed at all. My understanding is that the constructor would have (subtly) different types in the constructor's parameter pack (ensures the correct types are used), than the struct itself, so it is needed. telling the compiler "if you see `overloaded` 'constructed' as such, it is of *this* type" edit: Jason Turner covered this a few years ago in Eps. 48 49, and revisited *cough* in 134 w…