Improved checked_cast()