do not click

Meeting C++ 2026   |  Online   |  Training   |  Books   |  Survey   |  Job fair   |  Advertising   |  Jobposting   |  Login

Meeting C++ 2026 - Improving application design with std::variant and templates

Conference | Live Schedule | Talks | Get your ticket | Slides | Set your timezone

Improving application design with std::variant and templates

Join session

Robert Schimkowitsch

On Day 2 at 14:30 (CET/Berlin) in Track B [Opal Room and online]

A std::variant can store a value of one type at a time, out of a user-defined set of types. Those types can be completely unrelated to one another, but we can design them to have similarities. Templates allow us to process unrelated types, if there is a common way to interact with them. Bring those two observations together, and wonderful things become possible.

In this talk, we explore combining template techniques with std::variant. The result? Extensible code with less boilerplate.

We cover the basics of the subject area, then introduce an example inspired by my own work experience. As we dive into some key code snippets essential to the overall design, we identify problems, then figure out how to solve them. On this journey, we learn about breaking dependencies, ergonomic use of distinct data types and replacing duplicate code with a single implementation. We look at template instantiations to visualize and understand both the compile-time and run-time aspects of our code. Finally, we evaluate the code design impact of our changes, and what benefits they gave us.

After this talk, you will have a firm grasp on techniques that make std::variant even more useful in practice. This will unlock more options for your next application subsystem design. You do not need prior knowledge of either std::variant or writing template code.

Please login to comment

Copyright Meetingcpp GmbH Imprint Privacy Policy