The Basics
The basics talk about the former kind of exceptions thrown, and when to use std::any.
We'll cover the following...
We'll cover the following...
In C++14 there weren’t many options for holding variable types in a variable. You could use void*,
of course, but this wasn’t safe. void* is just a raw pointer, and you have to manage the whole object
lifetime and protect it from casting to a different type.
Potentially, void* could be wrapped in a class with some type discriminator.
class MyAny{void* _value;TypeInfo _typeInfo;};
Making Type-Safe
As you see, we have some basic form of the type, but there’s a bit of coding required to make sure MyAny is type-safe. ...