The Pattern Matching We Already Have

Braden Ganetsky

⏱ 60 minute session
beginner
intermediate
14:00-15:00, Monday, 23rd June 2025

All the way since C++98, we have already had pattern matching in C++! It's limited to specific places, but it's there. Template argument deduction, function overload resolution, and class template specializations are all instances of pattern matching in the C++ language, dating all the way back to the original standard.

The C++11 additions to the language also require library constructs to help deal with type deduction in forwarding references, namely std::forward, among others. Even experienced C++ developers may run into unexpected situations using it, especially in newer scenarios like concepts from C++20. This talk will lay clear the rules of forwarding and std::forward, and how you can forward your arguments properly every time.

This interactive talk is a deep dive into template argument deduction, helping you to understand it at deeper level across all of C++'s lifespan. Almost all that applies in C++98 still applies today, so a foundational understanding is important. Additionally, newer language standards have introduced further wrinkles, like C++11's move semantics and variadic template parameters, as well as C++17's class template argument deduction. By the end of this talk, you will have a solid understanding of how C++ deduces the types used in your code.


🏷 pattern matching
🏷 move semantics
🏷 perfect forwarding
🏷 reference semantics
🏷 references
🏷 templates
🏷 metaprogramming
🏷 C++
🏷 education
🏷 languages
🏷 logic

Braden Ganetsky

Braden Ganetsky graduated from the University of Manitoba with a degree in mechanical engineering, fueled by his passion for mechanical puzzles. During his final year of school, when all classes and activities were remote, he discovered C++ and has been hooked ever since. He interned as a C++ developer, which turned into a full time job, completing a successful pivot of his career. Now he spend his nights working on fun projects like parser combinators, and getting involved in the C++ community. Since 2023, Braden sits on the ISO C++ Committee as a representative of Canada.