any_cast doc: https://en.cppreference.com/w/cpp/utility/any/any_cast
This blog explains the std::any_cast behavior. The std::any_cast is a template function that casts std::any to a reference to the type T stored in the std::any. The std::any_cast function is used to retrieve the value stored in the std::any object. The std::any_cast function is a non-throwing function. If the std::any object does not contain a value of type T, the function returns a null pointer.
Some examples are shown below:
1 |
|
1 |
|
1 |
|