Library 7. Variant
How Does the Variant Library Improve Your Programs?
• Typesafe storage and retrieval of a user-specified set of types
• A means to store heterogeneous types in Standard Library containers
• Compile-time checked visitation of variants
• Efficient, stack-based storage for variants
The Variant library focuses on typesafe storage and retrieval of a bounded set of types—that is, on discriminated unions. The Boost.Variant library has many features in common with Boost.Any, but there are different tradeoffs as well as differences in functionality. The need for discriminated unions (variant types) is very common in everyday programming. One typical solution while retaining type safety is to use abstract base classes, but that's not ...
Get Beyond the C++ Standard Library: An Introduction to Boost now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.