“Variants: Past, Present, and Future"
summary
History and practical details: Boost.Variant (2004) implements sum types with hidden heap allocation on assignment and a make_recursive_variant helper; extraction uses boost::get or visitors. The standard update as std::variant (C++17) adds visit, get_if, index-based access, removes special recursion support and resolves the assignment exception problem with the valueless_by_exception compromise (never-empty vs explicit-empty debate). Also shows manual recursive patterns using shared_ptr, available third-party implementations, and an in-progress language-level variant + pattern-matching draft with extractors.
AI-written summary · about
chapters (54)
- 0:00Introduction
- 0:32Past Present Future
- 1:17Motivation Examples
- 1:53Undefined Behavior
- 2:21Problems with this approach
- 2:50Abstract base classes
- 5:34More boilerplate
- 6:04Recursive
- 6:32Variant
- 7:09Person ID
- 7:33Commands
- 8:10Variants
- 8:48Variant vs Inheritance
- 10:04Boost Variant
- 13:26What did we learn
- 14:35Inheritance
- 15:09Unwrap
- 15:38Recursive Variant
- 16:46Direct Recursion
- 17:54Assignment Problem
- 20:03Standed Variant
- 20:34Visit Variant
- 21:02Get Reworked
- 21:29Get Using an Index
- 21:52Duplicate Entries
- 22:15Recursion Support
- 22:32Standem Mono States
- 23:36Empty Variant
- 25:55Valueless by Exception
- 28:03Incremental Improvements
- 28:24Questions
- 29:45Language Support
- 30:05JSON Variant
- 30:53Basic Pattern Matching
- 31:21LanguageBased Variants
- 31:49IndexBased Variants
- 32:10TypeBased Variants
- 34:35Stud Variants
- 34:54Problems with Variants
- 35:33Variant Pattern Matching
- 36:16Pattern Matching onstructs
- 36:31Pattern Matching on fields
- 37:46Standover function
- 38:33Visitors with extra arguments
- 40:13Questions comments insults
- 40:47Questions comments
- 44:51Syntax
- 45:49Pattern Matching
- 47:15Implementation Requirements
- 49:12Nested Pattern Matching
- 50:52Language Based Matching
- 52:25The Ordering Matters
- 53:29MatchAll
- 54:12Optional
related talks
01h 31mImplementing variant Visitation Using Lambdas
58mC++17 in Practice - The good and the ugly
01h 10mBack to Basics: Algebraic Data Types
54mC++17 Features (part 2 of 2)
39mKotlin variance modifiers and Covariant Object Nothing pattern.
01h 04mVariadic Templates in C++11 / C++14 - An Introduction
01h 47mFunctional C++
15mThe Simple Essence of Overloading: Making ad-hoc polymorphism more algebraic with(…)
