std :: copy_exception在哪里定义? [英] Where is std::copy_exception defined?

查看:267
本文介绍了std :: copy_exception在哪里定义?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Anthony Williams在中的 C ++并发操作 4.2.4保存将来的异常,可以直接存储异常而不使用 std :: copy_exception 抛出异常。但是我似乎找不到标准库头文件定义 std :: copy_exception 。我在哪里可以找到它?

The book C++ Concurrency in Action by Anthony Williams states in 4.2.4 Saving an exception for the future that it is possible to store an exception directly without throwing using std::copy_exception. However I seem to be unable to find the standard library header where std::copy_exception is defined. Where can I find it?

推荐答案

委员会决定名称 copy_exception (可能从 boost :: copy_exception 中复制到标准中)具有误导性,原因如下。

The committee decided that the name copy_exception (probably copied into the standard from boost::copy_exception) was misleading for the following reasons.

code> copy_exception 函数向其参数的副本返回 exception_ptr ,如同

The copy_exception function returns an exception_ptr to a copy of its argument, as if

template <class E>
exception_ptr copy_exception(E e) {
    try {
        throw e;
    } catch (...) {
        return current_exception();
    }
}

当调用 exception_ptr 作为参数,函数将返回另一个 exception_ptr 指向 exception_ptr 作为参数,而不是指向 exception_ptr 参数指向的。因为 copy_exception 对于这种情况是误导的,所以对于最终的C +,函数被重命名为 std :: make_exception_ptr +11标准。请参阅 C ++标准库缺陷报告1130

When called with an exception_ptr as argument, the function would return another exception_ptr pointing to a copy of the exception_ptr given as argument, instead of pointing to what the exception_ptr argument points to. Because the name copy_exception was misleading for this case, the function was renamed to std::make_exception_ptr for the final C++11 standard. See the C++ Standard Library Defect Report 1130 for details and discussion on this issue.

std :: make_exception_ptr 函数定义在< exception>

这篇关于std :: copy_exception在哪里定义?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆