This code results in an error message:
libc++abi: terminating with uncaught exception of type std::bad_any_cast: bad any cast
vector<any> A = {vector<any>({1, 2})};
cout << any_cast<int>(any_cast<vector<any>>(A[0])[0]) << endl;
I am unable to debug this problem. Note that the following works and correctly outputs 1:
vector<any> A = {vector<int>({1, 2})};
cout << any_cast<vector<int>>(A[0])[0] << endl;
When I try to find the type of any_cast<vector>(A[0])[0] - which is obviously int - I get the same error message:
cout << any_cast<vector<any>>(A[0])[0].type().name() << endl;
libc++abi: terminating with uncaught exception of type std::bad_any_cast: bad any cast