Class Central is learner-supported. When you buy through links on our site, we may earn an affiliate commission.

YouTube

The Many Variants of std - variant

CppNow via YouTube

Overview

Explore the intricacies of std::variant in C++17 through this comprehensive conference talk from C++Now 2019. Delve into the design deliberations, tradeoffs, and controversies surrounding the discriminated union variant type. Gain insights from Nevin ":-)" Liber, a C++ Committee member and veteran developer, as he provides a first-hand account of the standardization process. Learn about performance and usability considerations, vocabulary sum types, noexcept move construction, and the challenges of designing variant. Examine topics such as never-empty guarantees, comparisons, default construction, element access, and the partially formed state. Discover the evolution of std::variant through various iterations and competing proposals. Understand the potential future directions for this feature in the C++ language.

Syllabus

Intro
What is a variant?
Three vocabulary sum types
Why is noexcept move construction desirable?
optional
C++ Committee
Designing variant
Tradeoffs
Never-empty
Comparisons
Default Construction
Accessing its element
"Ideal" Solution: False Hopes
Initial Solution: Double Storage
Current Approach: Temporary Heap Backup
Nothrow Default Constructible
Element access
Partially formed state
Sidebar
Sorting types
std::variant v2
std::variant v3
Pessimization
Competing papers
std::variant v7

Taught by

CppNow

Reviews

Start your review of The Many Variants of std - variant

Never Stop Learning.

Get personalized course recommendations, track subjects and courses with reminders, and more.

Someone learning on their laptop while sitting on the floor.