Is there any safe std::any_cast and static_cast combination?
I'm trying to perform the following:
#include <any>
#include <iostream>
int main( )
{
auto x = std::make_any< int >( 5 );
#if 0 // doesn't work
std::cout << std::any_cast< short >( x );
#else // works, but requires knowing the initial type
std::cout << static_cast< short >( std::any_cast< int >( x ) );
#endif
}