#include #include #include #include using namespace std ; int main() { any x1 {5}; cout << x1.has_value() << endl ; // == true cout << any_cast(x1) << endl ; // == 5 if (x1.type() == typeid(int) ) { // Extract using any_cast int value = any_cast(x1); cout << "Found an integer: " << value << "\n"; } //The type can be changed dynamically x1 = string{ "Some string" } ; cout << any_cast(x1) << endl ; }