Files
hustoj/web/cppreference-zh/chmhelp/cpp-error-tx_exception.html
2025-08-01 12:57:54 +08:00

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">&lt; <a href="cpp.html">cpp</a>&lrm; | <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>&#23450;&#20041;&#20110;&#22836;&#25991;&#20214; <code><a href="cpp-header-stdexcept.html">&lt;stdexcept&gt;</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">&lt;</span> <span class="kw1">class</span> T <span class="sy1">&gt;</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>&#23450;&#20041;&#33021;&#29992;&#20110;&#21462;&#28040;&#24182;&#22238;&#28378;&#20851;&#38190;&#35789; <a href="cpp-language-transactional_memory.html"><tt>atomic_cancel</tt></a> &#25152;&#21021;&#22987;&#21270;&#30340;&#21407;&#23376;&#20107;&#21153;&#30340;&#24322;&#24120;&#31867;&#22411;&#12290;</p>
<p>&#33509; <code>T</code> &#38750;<a href="cpp-named_req-TriviallyCopyable.html"><span style="font-style:italic">&#21487;&#24179;&#20961;&#22797;&#21046;</span> <span style="font-family: Georgia, &#39;DejaVu Serif&#39;, serif; font-style:italic">(TriviallyCopyable)</span></a> &#65292;&#21017;&#29305;&#21270; <code>std::tx_exception&lt;T&gt;</code> &#30340;&#31243;&#24207;&#20026;&#35884;&#26500;&#12290;</p>
<h3><span class="mw-headline" id=".E6.88.90.E5.91.98.E5.87.BD.E6.95.B0">&#25104;&#21592;&#20989;&#25968;</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">&amp;</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">&amp;</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> &#20197; <code>what_arg</code> &#20026;&#33021;&#36890;&#36807; <span class="t-lc">what()</span> &#35775;&#38382;&#30340;&#35299;&#37322;&#24615;&#23383;&#31526;&#20018;&#24182;&#20197; <code>value</code> &#20026;&#33021;&#36890;&#36807; <span class="t-lc">get()</span> &#35775;&#38382;&#30340;&#23545;&#35937;&#26500;&#36896;&#24322;&#24120;&#23545;&#35937;&#12290;</div>
<div class="t-li1"><span class="t-li">4)</span> &#22797;&#21046;&#26500;&#36896;&#20989;&#25968;&#12290;&#33509; <code>*this</code> &#19982; <code>other</code> &#22343;&#25317;&#26377;&#21160;&#24577;&#31867;&#22411; <code>std::tx_exception&lt;T&gt;</code> &#21017; <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> &#12290;</div>
<h3><span class="mw-headline" id=".E5.8F.82.E6.95.B0">&#21442;&#25968;</span></h3>
<table class="t-par-begin">
<tr class="t-par">
<td>value</td>
<td>-</td>
<td>&#36733;&#33655;&#23545;&#35937;</td>
</tr>
<tr class="t-par">
<td>what_arg</td>
<td>-</td>
<td>&#35299;&#37322;&#23383;&#31526;&#20018;</td>
</tr>
<tr class="t-par">
<td>other</td>
<td>-</td>
<td>&#35201;&#22797;&#21046;&#30340;&#21478;&#19968;&#23383;&#31526;&#20018;</td>
</tr>
</table>
<h3><span class="mw-headline" id=".E5.BC.82.E5.B8.B8">&#24322;&#24120;</span></h3>
<div class="t-li1"><span class="t-li">1-3)</span> &#21487;&#33021;&#25243;&#20986;&#23454;&#29616;&#23450;&#20041;&#30340;&#24322;&#24120;&#12290;</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">&amp;</span> operator<span class="sy1">=</span><span class="br0">(</span> <span class="kw4">const</span> tx_exception<span class="sy3">&amp;</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>&#20197; <code>other</code> &#30340;&#20869;&#23481;&#36171;&#20540;&#20869;&#23481;&#12290;&#33509; <code>*this</code> &#19982; <code>other</code> &#22343;&#25317;&#26377;&#21160;&#24577;&#31867;&#22411; <code>std::tx_exception&lt;T&gt;</code> &#21017;&#36171;&#20540;&#21518; <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> &#12290;</p>
<h3><span class="mw-headline" id=".E5.8F.82.E6.95.B0_2">&#21442;&#25968;</span></h3>
<table class="t-par-begin">
<tr class="t-par">
<td>other</td>
<td>-</td>
<td>&#29992;&#20197;&#36171;&#20540;&#30340;&#21478;&#19968;&#24322;&#24120;&#23545;&#35937;</td>
</tr>
</table>
<h3><span class="mw-headline" id=".E8.BF.94.E5.9B.9E.E5.80.BC">&#36820;&#22238;&#20540;</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>&#36820;&#22238;&#24322;&#24120;&#23545;&#35937;&#20445;&#26377;&#30340;&#36733;&#33655;&#23545;&#35937;&#12290;</p>
<h3><span class="mw-headline" id=".E5.BC.82.E5.B8.B8_2">&#24322;&#24120;</span></h3>
<p>&#21487;&#33021;&#25243;&#20986;&#23454;&#29616;&#23450;&#20041;&#30340;&#24322;&#24120;&#12290;</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>&#36820;&#22238;&#35299;&#37322;&#23383;&#31526;&#20018;&#12290;</p>
<h3><span class="mw-headline" id=".E5.8F.82.E6.95.B0_3">&#21442;&#25968;</span></h3>
<p>&#65288;&#26080;&#65289;</p>
<h3><span class="mw-headline" id=".E8.BF.94.E5.9B.9E.E5.80.BC_2">&#36820;&#22238;&#20540;</span></h3>
<p>&#25351;&#21521;&#25317;&#26377;&#35299;&#37322;&#20449;&#24687;&#30340;&#31354;&#20013;&#27490;&#23383;&#31526;&#20018;&#30340;&#25351;&#38024;&#12290;</p>
</div>
<div class="t-inherited">
<h2><span class="mw-headline" id=".E7.BB.A7.E6.89.BF.E8.87.AA_std::runtime_error">&#32487;&#25215;&#33258; <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">&#32487;&#25215;&#33258; <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">&#25104;&#21592;&#20989;&#25968;</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>(&#26512;&#26500;&#20989;&#25968;)</span></span></a></div>
<div><span class="t-lines"><span><span class="t-cmark">[&#34394;]</span></span></span></div>
</div>
</td>
<td>&#26512;&#26500;&#35813;&#24322;&#24120;&#23545;&#35937;<br />
<span class="t-mark">(<code>std::exception</code> &#30340;&#34394;&#20844;&#24320;&#25104;&#21592;&#20989;&#25968;)</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">[&#34394;]</span></span></span></div>
</div>
</td>
<td>&#36820;&#22238;&#35299;&#37322;&#24615;&#23383;&#31526;&#20018;<br />
<span class="t-mark">(<code>std::exception</code> &#30340;&#34394;&#20844;&#24320;&#25104;&#21592;&#20989;&#25968;)</span></td>
</tr>
</table>
</div>
</div>
<div class="visualClear"></div>
</div>
</div>
</div>
</body>
</html>