Simple, Extensible Pattern Matching in C++14 - John R. Bandela [ CppCon 2015 ]
4,127 views · Published 11 October 2015 · 51:27 · Indexed 20 September 2026
Channel: CppCon · 2015 · Science & Technology
http://www.Cppcon.org — Presentation Slides, PDFs, Source Code and other presenter materials are available at: https://github.com/cppcon/cppcon2015 — Recently, there has been in increased interest in applying functional programming techniques to C++. A very convenient construct that is used in functional programming languages is pattern matching. Due to the features introduced in C++11 and C++14 we can actually write a simple, easy to use, understandable, and extensible pattern matching library that is header only and uses no macros. In this talks we will discuss the motivations for pattern matching, and see examples of use from other languages. We will then go on to design and implement a pattern matching library in C++. Particular attention will be payed to new C++14 features that greatly simplify the implementation such as integer_sequence, function return type deduction, and generic lambdas. The implementation will also serve a practical guide to using variadic templates and std::tuple. We will show how the library can be easily extended and customized by working through some examples of customization such as working with user defined classes and structs, pointers, tuples, boost::optional, and boost::variant. At the end of the session, the audience will have an appreciation for pattern matching, as well as a sense that the C++11/14 features open new paradigms without sacrificing understandable code. — I first started programming in C++ at age 14 in 1994 when I cajoled my parents into buying me Visual C++ 1.0 for my birthday. It took a while, but as I learned the language, I decided I really liked C++. I attended the University of Florida and obtained my undergraduate degree in Computer and Information Science. During my undergraduate time, I created and submitted Boost.Tokenizer. I went on to medical school and neurosurgery residency, but decided to do something with a little less scary undefined behavior and returned to programming in C++. I am currently working for Transunion Specialized Risk Group as a Senior C++ programmer. — Videos Filmed & Edited by Bash Films: http://www.BashFilms.com — Optimized And Managed by Digital Medium Ltd - events.digital-medium.co.uk [email protected] Work at Hudson River Trading (HRT): https://tinyurl.com/safxfctf