103 lines
8.2 KiB
HTML
103 lines
8.2 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::filesystem::filesystem_error::filesystem_error</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_filesystem_filesystem_error_filesystem_error 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::filesystem::filesystem_error::</span>filesystem_error</h1>
|
|
<div id="bodyContent">
|
|
<div id="contentSub"><span class="subpages">< <a href="cpp.html">cpp</a>‎ | <a href="cpp-filesystem.html">filesystem</a>‎ | <a href="cpp-filesystem-filesystem_error.html">filesystem 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-dcl t-since-cxx17">
|
|
<td>
|
|
<div><span class="mw-geshi cpp source-cpp">filesystem_error<span class="br0">(</span> <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,<br />
|
|
<a href="cpp-error-error_code.html"><span class="kw877">std::<span class="me2">error_code</span></span></a> ec <span class="br0">)</span><span class="sy4">;</span></span></div>
|
|
</td>
|
|
<td>(1)</td>
|
|
<td><span class="t-mark-rev t-since-cxx17">(C++17 起)</span></td>
|
|
</tr>
|
|
<tr class="t-dcl t-since-cxx17">
|
|
<td>
|
|
<div><span class="mw-geshi cpp source-cpp">filesystem_error<span class="br0">(</span> <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,<br /></span>
|
|
<p> <span class="kw4">const</span> <a href="cpp-filesystem-path.html"><span class="kw2199">std::<span class="me2">filesystem</span><span class="sy4">::</span><span class="me2">path</span></span></a><span class="sy3">&</span> p1,<br /></p>
|
|
<a href="cpp-error-error_code.html"><span class="kw877">std::<span class="me2">error_code</span></span></a> ec <span class="br0">)</span><span class="sy4">;</span></div>
|
|
</td>
|
|
<td>(2)</td>
|
|
<td><span class="t-mark-rev t-since-cxx17">(C++17 起)</span></td>
|
|
</tr>
|
|
<tr class="t-dcl t-since-cxx17">
|
|
<td>
|
|
<div><span class="mw-geshi cpp source-cpp">filesystem_error<span class="br0">(</span> <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,<br /></span>
|
|
<p> <span class="kw4">const</span> <a href="cpp-filesystem-path.html"><span class="kw2199">std::<span class="me2">filesystem</span><span class="sy4">::</span><span class="me2">path</span></span></a><span class="sy3">&</span> p1,<br />
|
|
<span class="kw4">const</span> <a href="cpp-filesystem-path.html"><span class="kw2199">std::<span class="me2">filesystem</span><span class="sy4">::</span><span class="me2">path</span></span></a><span class="sy3">&</span> p2,<br /></p>
|
|
<a href="cpp-error-error_code.html"><span class="kw877">std::<span class="me2">error_code</span></span></a> ec <span class="br0">)</span><span class="sy4">;</span></div>
|
|
</td>
|
|
<td>(3)</td>
|
|
<td><span class="t-mark-rev t-since-cxx17">(C++17 起)</span></td>
|
|
</tr>
|
|
<tr class="t-dcl t-since-cxx17">
|
|
<td>
|
|
<div><span class="mw-geshi cpp source-cpp">filesystem_error<span class="br0">(</span> <span class="kw4">const</span> filesystem_error<span class="sy3">&</span> other <span class="br0">)</span> <span class="kw1">noexcept</span><span class="sy4">;</span></span></div>
|
|
</td>
|
|
<td>(4)</td>
|
|
<td><span class="t-mark-rev t-since-cxx17">(C++17 起)</span></td>
|
|
</tr>
|
|
<tr class="t-dcl-sep">
|
|
<td></td>
|
|
<td></td>
|
|
<td></td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p>构造新的文件系统错误对象。</p>
|
|
<div class="t-li1"><span class="t-li">1-3)</span> 设置错误码为 <code>ec</code> ,可选地将导致该错误的操作中设计的路径设为 <code>p1</code> 和 <code>p2</code> 。构造后 <code>what()</code> 返回含有 <code>what_arg</code> 的 string (假定它不含内嵌的空字符 )。若未提供一个或两个 <code>path</code> 参数,则用 <code>path</code> 代替。</div>
|
|
<div class="t-li1"><span class="t-li">4)</span> 复制构造函数。以 <code>other</code> 的内容初始化内容。若 <code>*this</code> 与 <code>other</code> 均拥有动态类型 <code>std::filesystem_error::filesystem_error</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>what_arg</td>
|
|
<td>-</td>
|
|
<td>解释字符串</td>
|
|
</tr>
|
|
<tr class="t-par">
|
|
<td>ec</td>
|
|
<td>-</td>
|
|
<td>依赖特定操作系统的错误的错误码</td>
|
|
</tr>
|
|
<tr class="t-par">
|
|
<td>p1, p2</td>
|
|
<td>-</td>
|
|
<td>引发系统错误的操作中涉及的路径</td>
|
|
</tr>
|
|
<tr class="t-par">
|
|
<td>other</td>
|
|
<td>-</td>
|
|
<td>要复制的另一 <code>filesystem_error</code> 对象</td>
|
|
</tr>
|
|
</table>
|
|
<h3><span class="mw-headline" id=".E6.B3.A8.E8.A7.A3">注解</span></h3>
|
|
<p>因为不容许复制 <code>std::filesystem::filesystem_error</code> 抛异常,解释字符串常被在内部存储于分离分配的引用计数存储。这也是无构造函数接收 <code>std::string&&</code> 的原因:它总是要复制内容。</p>
|
|
<p>典型实现亦将 <span class="t-lc"><a href="cpp-filesystem-filesystem_error-path.html">path1()</a></span> 与 <span class="t-lc"><a href="cpp-filesystem-filesystem_error-path.html">path2()</a></span> 所引用的 <code>path</code> 对象存储于引用计数存储。</p>
|
|
<h3><span class="mw-headline" id=".E7.A4.BA.E4.BE.8B">示例</span></h3>
|
|
<table class="metadata plainlinks ambox mbox-small-left ambox-notice" style="">
|
|
<tr>
|
|
<td class="mbox-empty-cell"></td>
|
|
<td class="mbox-text" style="">本节未完成<br />
|
|
原因:暂无示例</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
<div class="visualClear"></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</body>
|
|
</html>
|