Library 6. Any
How Does the Any Library Improve Your Programs?
• Typesafe storage and safe retrieval of arbitrary types
• A means to store heterogeneous types in Standard Library containers
• Types are being passed through layers that need not know anything about the types
The Any library provides a type, any
, that allows for storage of any type for later retrieval without loss of type safety. It is like a variant type on steroids: It will hold any type, but you have to know the type to retrieve the value. There are times when you need to store unrelated types in the same container. There are times when certain code only cares about conveying data from one point to another without caring about the data's type. At face value, it is easy to do ...
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.