更新时间:2023-11-11 13:32:58
你不能。标准在 15.3 / 3
:
处理程序是一个异常对象的匹配如果
A handler is a match for an exception object of type E if
cv T&
和E和T是相同的类型(忽略***cv- cv T
或 cv T&
,T是E的明确的公共基类,或 cv1 T * cv2
,E是可以转换为处理程序类型的指针类型cv T
or cv T&
and E and T are the same type (ignoring the top-level cv-
qualifiers), orcv T
or cv T&
and T is an unambiguous public base class of E, orcv1 T* cv2
and E is a pointer type that can be converted to the type of the handler
by either or both of
您所需的场景不符合这些情况。 cv
表示const和/或volatile组合
Your desired scenario matches none of these. cv
means "const and/or volatile combination"