std :: uncaught_exception如何工作? [英] How does std::uncaught_exception work?
问题描述
有帖子和文章关于 std :: uncaught_exception $ c的用法和理性$ c>。
功能由此函数提供的
The Functionality provided by this function boils down to
std :: uncaught_exception检测是否正在进行堆栈展开
std::uncaught_exception detects if stack unwinding is currently in progress.
Q
当搜索其定义时,我看到的是对DLL的调用
Q
When searching for its definition all I see is a call to a DLL
_CRTIMP2_PURE bool __CLRCALL_PURE_OR_CDECL uncaught_exception();
如何实现程序中的这种内省水平?
推荐答案
正如你所看到的, uncaught_exception
是库的语言支持部分的一部分(第18条,[language.support])。也就是说,它是访问核心语言的某些方面(类似于类型标识和初始化器列表)的库功能。
As you can see, uncaught_exception
is part of the "Language Support" part of the library (Clause 18, [language.support]). That is to say, it is a library feature that is required to access some aspect of the core language (similar to things like type identification and initializer lists).
实现语言支持库通常需要一组适当的编译器内在函数的编译器特定知识,这些知识暴露了核心语言的相关方面。 (你不能真正建立一个完全编译器不可知的,可移植的C ++标准库实现;标准库总是绑定到平台在某种程度上,因为这些语言支持功能。 traits。)
Implementing the language support library usually requires compiler-specific knowledge of an appropriate set of compiler intrinsics that expose the relevant aspect of the core language. (You cannot really build a completely compiler-agnostic, "portable" C++ standard library implementation; the standard library is always tied to the platform to some extent because of these language support features. There are even other such situations outside Clause 18, e.g. type traits.)
异常处理本身内置于核心语言,构成编译器ABI的一大部分;部分是检测异常是否当前处于活动状态。您已经需要这些信息,以便在第一个异常被激活时抛出第二个异常,因此它只是一个问题。
Exception handling itself is built into the core language and forms a large part of the compiler's ABI; part of this is detecting whether an exception is currently active. You already need this information in order to terminate if a second exception is thrown while the first one is active, so it's just a matter of exposing this state somehow.
这篇关于std :: uncaught_exception如何工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!