Imagine if we could do this:
try
{
// some code here
}
template<typename T> catch(T &obj)
{
if constexpr ( requires { obj.what(); } )
{
cout << obj.what() << endl;
}
else
{
cout << "Thrown object is a " << typeid(T).name() << " and its value is " << obj << endl;
}
}
Basically it would be the same as having 'catch(...)' except that we haven't lost the type info.