219 lines
12 KiB
HTML
219 lines
12 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="zh" dir="ltr" class="client-nojs" xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh">
|
|
<head><meta http-equiv="x-ua-compatible" content="ie=edge">
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
<title>std::tx_exception</title>
|
|
<link rel="stylesheet" href="ext.css" />
|
|
<link rel="stylesheet" href="site_modules.css" />
|
|
</head>
|
|
<body class="mediawiki ltr sitedir-ltr ns-0 ns-subject page-cpp_error_tx_exception skin-cppreference2 action-view cpp-navbar">
|
|
<div id="cpp-content-base">
|
|
<div id="content"><a id="top"></a>
|
|
<h1 id="firstHeading" class="firstHeading"><span style="font-size:0.7em; line-height:130%">std::</span>tx_exception</h1>
|
|
<div id="bodyContent">
|
|
<div id="contentSub"><span class="subpages">< <a href="cpp.html">cpp</a>‎ | <a href="cpp-error.html">error</a></span></div>
|
|
<div id="mw-content-text" lang="zh" dir="ltr" class="mw-content-ltr" xml:lang="zh">
|
|
<table class="t-dcl-begin">
|
|
<tbody>
|
|
<tr class="t-dsc-header">
|
|
<td>
|
|
<div>定义于头文件 <code><a href="cpp-header-stdexcept.html"><stdexcept></a></code></div>
|
|
</td>
|
|
<td></td>
|
|
<td></td>
|
|
</tr>
|
|
<tr class="t-dcl t-since-tm_ts">
|
|
<td>
|
|
<div><span class="mw-geshi cpp source-cpp"><span class="kw1">template</span><span class="sy1"><</span> <span class="kw1">class</span> T <span class="sy1">></span><br />
|
|
<span class="kw1">class</span> tx_exception <span class="sy4">:</span> <span class="kw1">public</span> <a href="cpp-error-runtime_error.html"><span class="kw770">std::<span class="me2">runtime_error</span></span></a><span class="sy4">;</span></span></div>
|
|
</td>
|
|
<td class="t-dcl-nopad"></td>
|
|
<td><span class="t-mark-rev t-since-tm-ts t-mark-ts">(TM TS)</span></td>
|
|
</tr>
|
|
<tr class="t-dcl-sep">
|
|
<td></td>
|
|
<td></td>
|
|
<td></td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p>定义能用于取消并回滚关键词 <a href="cpp-language-transactional_memory.html"><tt>atomic_cancel</tt></a> 所初始化的原子事务的异常类型。</p>
|
|
<p>若 <code>T</code> 非<a href="cpp-named_req-TriviallyCopyable.html"><span style="font-style:italic">可平凡复制</span> <span style="font-family: Georgia, 'DejaVu Serif', serif; font-style:italic">(TriviallyCopyable)</span></a> ,则特化 <code>std::tx_exception<T></code> 的程序为谬构。</p>
|
|
<h3><span class="mw-headline" id=".E6.88.90.E5.91.98.E5.87.BD.E6.95.B0">成员函数</span></h3>
|
|
<div class="t-member">
|
|
<h2><span class="mw-headline" id="std::tx_exception::tx_exception"><span style="font-size:0.7em; line-height:130%">std::tx_exception::</span>tx_exception</span></h2>
|
|
<table class="t-dcl-begin">
|
|
<tbody>
|
|
<tr class="t-dcl t-since-tm_ts">
|
|
<td>
|
|
<div><span class="mw-geshi cpp source-cpp"><span class="kw1">explicit</span> tx_exception<span class="br0">(</span> T value <span class="br0">)</span> transaction_safe<span class="sy4">;</span></span></div>
|
|
</td>
|
|
<td>(1)</td>
|
|
<td><span class="t-mark-rev t-since-tm-ts t-mark-ts">(TM TS)</span></td>
|
|
</tr>
|
|
<tr class="t-dcl t-since-tm_ts">
|
|
<td>
|
|
<div><span class="mw-geshi cpp source-cpp">tx_exception<span class="br0">(</span> T value, <span class="kw4">const</span> <a href="cpp-string-basic_string.html"><span class="kw1230">std::<span class="me2">string</span></span></a><span class="sy3">&</span> what_arg <span class="br0">)</span> transaction_safe<span class="sy4">;</span></span></div>
|
|
</td>
|
|
<td>(2)</td>
|
|
<td><span class="t-mark-rev t-since-tm-ts t-mark-ts">(TM TS)</span></td>
|
|
</tr>
|
|
<tr class="t-dcl t-since-tm_ts">
|
|
<td>
|
|
<div><span class="mw-geshi cpp source-cpp">tx_exception<span class="br0">(</span> T value, <span class="kw4">const</span> <span class="kw4">char</span><span class="sy2">*</span> what_arg <span class="br0">)</span> transaction_safe<span class="sy4">;</span></span></div>
|
|
</td>
|
|
<td>(3)</td>
|
|
<td><span class="t-mark-rev t-since-tm-ts t-mark-ts">(TM TS)</span></td>
|
|
</tr>
|
|
<tr class="t-dcl t-since-tm_ts">
|
|
<td>
|
|
<div><span class="mw-geshi cpp source-cpp">tx_exception<span class="br0">(</span> <span class="kw4">const</span> tx_exception<span class="sy3">&</span> other <span class="br0">)</span> transaction_safe <span class="kw1">noexcept</span><span class="sy4">;</span></span></div>
|
|
</td>
|
|
<td>(4)</td>
|
|
<td><span class="t-mark-rev t-since-tm-ts t-mark-ts">(TM TS)</span></td>
|
|
</tr>
|
|
<tr class="t-dcl-sep">
|
|
<td></td>
|
|
<td></td>
|
|
<td></td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<div class="t-li1"><span class="t-li">1-3)</span> 以 <code>what_arg</code> 为能通过 <span class="t-lc">what()</span> 访问的解释性字符串并以 <code>value</code> 为能通过 <span class="t-lc">get()</span> 访问的对象构造异常对象。</div>
|
|
<div class="t-li1"><span class="t-li">4)</span> 复制构造函数。若 <code>*this</code> 与 <code>other</code> 均拥有动态类型 <code>std::tx_exception<T></code> 则 <span class="t-c"><span class="mw-geshi cpp source-cpp"><a href="cpp-string-byte-strcmp.html"><span class="kw1146">std::<span class="me2">strcmp</span></span></a><span class="br0">(</span>what<span class="br0">(</span><span class="br0">)</span>, other.<span class="me1">what</span><span class="br0">(</span><span class="br0">)</span><span class="br0">)</span> <span class="sy1">==</span> <span class="nu0">0</span></span></span> 。</div>
|
|
<h3><span class="mw-headline" id=".E5.8F.82.E6.95.B0">参数</span></h3>
|
|
<table class="t-par-begin">
|
|
<tr class="t-par">
|
|
<td>value</td>
|
|
<td>-</td>
|
|
<td>载荷对象</td>
|
|
</tr>
|
|
<tr class="t-par">
|
|
<td>what_arg</td>
|
|
<td>-</td>
|
|
<td>解释字符串</td>
|
|
</tr>
|
|
<tr class="t-par">
|
|
<td>other</td>
|
|
<td>-</td>
|
|
<td>要复制的另一字符串</td>
|
|
</tr>
|
|
</table>
|
|
<h3><span class="mw-headline" id=".E5.BC.82.E5.B8.B8">异常</span></h3>
|
|
<div class="t-li1"><span class="t-li">1-3)</span> 可能抛出实现定义的异常。</div>
|
|
</div>
|
|
<div class="t-member">
|
|
<h2><span class="mw-headline" id="std::tx_exception::operator.3D"><span style="font-size:0.7em; line-height:130%">std::tx_exception::</span>operator=</span></h2>
|
|
<table class="t-dcl-begin">
|
|
<tbody>
|
|
<tr class="t-dcl t-since-tm_ts">
|
|
<td>
|
|
<div><span class="mw-geshi cpp source-cpp">tx_exception<span class="sy3">&</span> operator<span class="sy1">=</span><span class="br0">(</span> <span class="kw4">const</span> tx_exception<span class="sy3">&</span> other <span class="br0">)</span> transaction_safe <span class="kw1">noexcept</span><span class="sy4">;</span></span></div>
|
|
</td>
|
|
<td class="t-dcl-nopad"></td>
|
|
<td><span class="t-mark-rev t-since-tm-ts t-mark-ts">(TM TS)</span></td>
|
|
</tr>
|
|
<tr class="t-dcl-sep">
|
|
<td></td>
|
|
<td></td>
|
|
<td></td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p>以 <code>other</code> 的内容赋值内容。若 <code>*this</code> 与 <code>other</code> 均拥有动态类型 <code>std::tx_exception<T></code> 则赋值后 <span class="t-c"><span class="mw-geshi cpp source-cpp"><a href="cpp-string-byte-strcmp.html"><span class="kw1146">std::<span class="me2">strcmp</span></span></a><span class="br0">(</span>what<span class="br0">(</span><span class="br0">)</span>, other.<span class="me1">what</span><span class="br0">(</span><span class="br0">)</span><span class="br0">)</span> <span class="sy1">==</span> <span class="nu0">0</span></span></span> 。</p>
|
|
<h3><span class="mw-headline" id=".E5.8F.82.E6.95.B0_2">参数</span></h3>
|
|
<table class="t-par-begin">
|
|
<tr class="t-par">
|
|
<td>other</td>
|
|
<td>-</td>
|
|
<td>用以赋值的另一异常对象</td>
|
|
</tr>
|
|
</table>
|
|
<h3><span class="mw-headline" id=".E8.BF.94.E5.9B.9E.E5.80.BC">返回值</span></h3>
|
|
<p><span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="sy2">*</span>this</span></span></p>
|
|
</div>
|
|
<div class="t-member">
|
|
<h2><span class="mw-headline" id="std::tx_exception::get"><span style="font-size:0.7em; line-height:130%">std::tx_exception::</span>get</span></h2>
|
|
<table class="t-dcl-begin">
|
|
<tbody>
|
|
<tr class="t-dcl t-since-tm_ts">
|
|
<td>
|
|
<div><span class="mw-geshi cpp source-cpp">T get<span class="br0">(</span><span class="br0">)</span> <span class="kw4">const</span> transaction_safe<span class="sy4">;</span></span></div>
|
|
</td>
|
|
<td class="t-dcl-nopad"></td>
|
|
<td><span class="t-mark-rev t-since-tm-ts t-mark-ts">(TM TS)</span></td>
|
|
</tr>
|
|
<tr class="t-dcl-sep">
|
|
<td></td>
|
|
<td></td>
|
|
<td></td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p>返回异常对象保有的载荷对象。</p>
|
|
<h3><span class="mw-headline" id=".E5.BC.82.E5.B8.B8_2">异常</span></h3>
|
|
<p>可能抛出实现定义的异常。</p>
|
|
</div>
|
|
<p><br /></p>
|
|
<div class="t-member">
|
|
<h2><span class="mw-headline" id="std::tx_exception::what"><span style="font-size:0.7em; line-height:130%">std::tx_exception::</span>what</span></h2>
|
|
<table class="t-dcl-begin">
|
|
<tbody>
|
|
<tr class="t-dcl t-since-tm_ts">
|
|
<td>
|
|
<div><span class="mw-geshi cpp source-cpp"><span class="kw1">virtual</span> <span class="kw4">const</span> <span class="kw4">char</span><span class="sy2">*</span> what<span class="br0">(</span><span class="br0">)</span> <span class="kw4">const</span> transaction_safe_dynamic <span class="kw1">noexcept</span><span class="sy4">;</span></span></div>
|
|
</td>
|
|
<td class="t-dcl-nopad"></td>
|
|
<td><span class="t-mark-rev t-since-tm-ts t-mark-ts">(TM TS)</span></td>
|
|
</tr>
|
|
<tr class="t-dcl-sep">
|
|
<td></td>
|
|
<td></td>
|
|
<td></td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p>返回解释字符串。</p>
|
|
<h3><span class="mw-headline" id=".E5.8F.82.E6.95.B0_3">参数</span></h3>
|
|
<p>(无)</p>
|
|
<h3><span class="mw-headline" id=".E8.BF.94.E5.9B.9E.E5.80.BC_2">返回值</span></h3>
|
|
<p>指向拥有解释信息的空中止字符串的指针。</p>
|
|
</div>
|
|
<div class="t-inherited">
|
|
<h2><span class="mw-headline" id=".E7.BB.A7.E6.89.BF.E8.87.AA_std::runtime_error">继承自 <a href="cpp-error-runtime_error.html"><span style="font-size:0.7em; line-height:130%">std::</span>runtime_error</a></span></h2>
|
|
<p><br /></p>
|
|
</div>
|
|
<div class="t-inherited">
|
|
<h2><span class="mw-headline" id=".E7.BB.A7.E6.89.BF.E8.87.AA_std::exception">继承自 <a href="cpp-error-exception.html"><span style="font-size:0.7em; line-height:130%">std::</span>exception</a></span></h2>
|
|
<h3><span class="mw-headline" id=".E6.88.90.E5.91.98.E5.87.BD.E6.95.B0_2">成员函数</span></h3>
|
|
<table class="t-dsc-begin">
|
|
<tr class="t-dsc">
|
|
<td>
|
|
<div class="t-dsc-member-div t-dsc-member-nobold-div">
|
|
<div><a href="cpp-error-exception-~exception.html"><span class="t-lines"><span>(析构函数)</span></span></a></div>
|
|
<div><span class="t-lines"><span><span class="t-cmark">[虚]</span></span></span></div>
|
|
</div>
|
|
</td>
|
|
<td>析构该异常对象<br />
|
|
<span class="t-mark">(<code>std::exception</code> 的虚公开成员函数)</span></td>
|
|
</tr>
|
|
<tr class="t-dsc">
|
|
<td>
|
|
<div class="t-dsc-member-div">
|
|
<div><a href="cpp-error-exception-what.html"><span class="t-lines"><span>what</span></span></a></div>
|
|
<div><span class="t-lines"><span><span class="t-cmark">[虚]</span></span></span></div>
|
|
</div>
|
|
</td>
|
|
<td>返回解释性字符串<br />
|
|
<span class="t-mark">(<code>std::exception</code> 的虚公开成员函数)</span></td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
<div class="visualClear"></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</body>
|
|
</html>
|