Loading…
CppCon 2020 has ended
Wednesday, September 16 • 13:30 - 14:30
Back to Basics: Algebraic Data Types

Log in to save this to your schedule, view media, leave feedback and see who's attending!

Feedback form is now closed.
One of the hallmarks of "modern C++" is a transition from classic object-orientation to value semantics with algebraic data types such as `variant` and `tuple`. In this session we'll explain the math behind the name, and we'll delve deep into the meaning and usage of all of the algebraic data types in C++17: pair, tuple, optional, and variant. These types have some commonalities, such as the use of type-traits to access their component types, and a common approach to implicit conversions and comparisons. We'll show how to use std::optional for deferred initialization and how to replace dynamic polymorphism with visitation over a std::variant. We'll even deliver some guidance on when NOT to return a tuple, and on how you should think about variant's "valueless by exception" state.
Attendees will leave this session with a newfound appreciation for C++'s algebraic data types.

Speakers
avatar for Arthur O'Dwyer

Arthur O'Dwyer

C++ Trainer
Arthur O'Dwyer is the author of "Mastering the C++17 STL" (Packt 2017) and of professional training courses such as "Intro to C++," "Classic STL: Algorithms, Containers, Iterators," and "The STL From Scratch." (Ask me about training your new hires!) Arthur is occasionally active on... Read More →


Wednesday September 16, 2020 13:30 - 14:30 MDT
Back to Basics
  Back to Basics