Algebraic Data Types
https://cppcon.org/ https://github.com/CppCon/CppCon2020/blob/main/Presentations/back_to_basics_algebraic_data_types/back_to_basics_algebraic_data_types__arthur_odwyer__cppcon_2020.pdf
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.
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 the C++ Standards Committee and has a blog mostly about C++. He is also the author of “Colossal Cave: The Board Game,” an avid club juggler, and the recipient of four Knuth checks.
Streamed & Edited by Digital Medium Ltd - events.digital-medium.co.uk events@digital-medium.co.uk
