private inheritance, friends, and exception-handling

99封情书 提交于 2019-12-04 11:20:58

Nope, that's not what the standard says. It says (C++0x):

A handler is a match for an exception object of type E if

— The handler is of type cv T or cv T& and E and T are the same type (ignoring the top-level cv-qualifiers), or

— the handler is of type cv T or cv T& and T is an unambiguous public base class of E, or

— the handler is of type cv1 T* cv2 and E is a pointer type that can be converted to the type of the handler by either or both of

    — a standard pointer conversion (4.10) not involving conversions to pointers to private or protected or ambiguous classes

    — a qualification conversion

— the handler is a pointer or pointer to member type and E is std::nullptr_t

Rationale: Complicated implementation. You can look at this like the conversion happens somewhere between the throw and the catch, not in g itself.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!