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

查看:236
本文介绍了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?

推荐答案

tl; dr std: :copy_exception 已重命名为 std :: make_exception_ptr < exception> 中为最终C ++ 11标准。

tl;dr: std::copy_exception was renamed to std::make_exception_ptr in <exception> for the final C++11 standard.

委员会决定将名称 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.

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 在这种情况下是误导的,所以该函数被重命名为 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天全站免登陆