Skip to content

Commit 22549eb

Browse files
committed
deploy: e02029e
1 parent 849b1f4 commit 22549eb

File tree

5 files changed

+12
-12
lines changed

5 files changed

+12
-12
lines changed

cpp_tricks/index.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@
408408
<ul class="nav flex-column">
409409
</ul>
410410
</li>
411-
<li class="nav-item" data-bs-level="2"><a href="#adl" class="nav-link">ADL 机制</a>
411+
<li class="nav-item" data-bs-level="2"><a href="#adl" class="nav-link">ADL 机制实现静态多态</a>
412412
<ul class="nav flex-column">
413413
</ul>
414414
</li>
@@ -509,7 +509,7 @@ <h1 id="c">应知应会 C++ 小技巧</h1>
509509
<li><a href="#_13">花括号实现安全的类型转换检查</a></li>
510510
<li><a href="#_14">临时右值转左值</a></li>
511511
<li><a href="#ostringstream">ostringstream 格式化字符串</a></li>
512-
<li><a href="#adl">ADL 机制</a></li>
512+
<li><a href="#adl">ADL 机制实现静态多态</a></li>
513513
<li><a href="#shared_from_this">shared_from_this</a></li>
514514
<li><a href="#requires">requires 语法检测是否存在指定成员函数</a></li>
515515
<li><a href="#locale-utf8_1">设置 locale 为 .utf8 解决编码问题</a></li>
@@ -594,7 +594,7 @@ <h2 id="_2">读取整个文件到字符串</h2>
594594
</code></pre>
595595
<p>这样就可以把整个文件读取到内存中,进行处理后再写回文件。</p>
596596
<blockquote>
597-
<p><img src="../img/question.png" height="30px" width="auto" style="margin: 0; border: none"/> <code>std::ios::binary</code> 选项打开文件,是为了避免文件中出现 <code>'\n'</code> 时, MSVC 标准库自动转换成 <code>'\r\n'</code>,以保证跨平台</p>
597+
<p><img src="../img/bulb.png" height="30px" width="auto" style="margin: 0; border: none"/> 推荐用 <code>std::ios::binary</code> 选项打开二进制文件,否则字符串中出现 <code>'\n'</code> 时,会被 MSVC 标准库自动转换成 <code>'\r\n'</code> 来写入,妨碍我们跨平台</p>
598598
</blockquote>
599599
<h2 id="_3">别再写构造函数啦!</h2>
600600
<pre><code class="language-cpp">// C++98
@@ -1288,7 +1288,7 @@ <h2 id="_7">智能指针防止大对象移动</h2>
12881288

12891289
using BigTypePtr = unique_ptr&lt;BigType&gt;;
12901290

1291-
vector&lt;BigType&gt; arr;
1291+
vector&lt;BigTypePtr&gt; arr;
12921292

12931293
void func(BigTypePtr x) {
12941294
arr.push_back(std::move(x)); // 只拷贝 8 字节的指针,其指向的 4000 字节不用深拷贝了,直接移动所有权给 vector 里的 BigTypePtr 智能指针
@@ -1875,7 +1875,7 @@ <h2 id="ostringstream">ostringstream 格式化字符串</h2>
18751875
<p>利用临时变量语法,可以浓缩写在一行里,做个 format 拙劣的模仿者:</p>
18761876
<pre><code class="language-cpp">auto str = (std::ostringstream() &lt;&lt; &quot;你好,&quot; &lt;&lt; name &lt;&lt; &quot;!答案是 &quot; &lt;&lt; answer &lt;&lt; &quot;,十六进制:0x&quot; &lt;&lt; std::hex &lt;&lt; std::setfill('0') &lt;&lt; std::setw(2) &lt;&lt; answer &lt;&lt; &quot;\n&quot;).str();
18771877
</code></pre>
1878-
<h2 id="adl">ADL 机制</h2>
1878+
<h2 id="adl">ADL 机制实现静态多态</h2>
18791879
<p>TODO</p>
18801880
<h2 id="shared_from_this">shared_from_this</h2>
18811881
<h2 id="requires">requires 语法检测是否存在指定成员函数</h2>

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ <h2 id="_1">前言</h2>
292292
<blockquote>
293293
<p><img src="./img/bulb.png" height="30px" width="auto" style="margin: 0; border: none"/> 本书还在持续更新中……要追番的话,可以在 <a href="https://github.com/parallel101/cppguidebook">GitHub</a> 点一下右上角的 “Watch” 按钮,每当小彭老师提交新 commit,GitHub 会向你发送一封电子邮件,提醒你小彭老师更新了。</p>
294294
</blockquote>
295-
<p>更新时间:2024年09月07日 11:28:31 (UTC+08:00)</p>
295+
<p>更新时间:2024年09月09日 17:24:48 (UTC+08:00)</p>
296296
<p><a href="https://parallel101.github.io/cppguidebook">在 GitHub Pages 浏览本书</a> | <a href="https://142857.red/book">在小彭老师自己维护的镜像上浏览本书</a></p>
297297
<h2 id="_2">格式约定</h2>
298298
<blockquote>

print_page/index.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ <h2 id="index-_1">前言</h2>
421421
<blockquote>
422422
<p><img src="../img/bulb.png" height="30px" width="auto" style="margin: 0; border: none"/> 本书还在持续更新中……要追番的话,可以在 <a href="https://github.com/parallel101/cppguidebook">GitHub</a> 点一下右上角的 “Watch” 按钮,每当小彭老师提交新 commit,GitHub 会向你发送一封电子邮件,提醒你小彭老师更新了。</p>
423423
</blockquote>
424-
<p>更新时间:2024年09月07日 11:28:31 (UTC+08:00)</p>
424+
<p>更新时间:2024年09月09日 17:24:48 (UTC+08:00)</p>
425425
<p><a href="https://parallel101.github.io/cppguidebook">在 GitHub Pages 浏览本书</a> | <a href="https://142857.red/book">在小彭老师自己维护的镜像上浏览本书</a></p>
426426
<h2 id="index-_2">格式约定</h2>
427427
<blockquote>
@@ -1123,7 +1123,7 @@ <h2 id="symbols-linkage">符号的链接类型 (linkage)</h2>
11231123
<li><a href="#cpp_tricks-_13">花括号实现安全的类型转换检查</a></li>
11241124
<li><a href="#cpp_tricks-_14">临时右值转左值</a></li>
11251125
<li><a href="#cpp_tricks-ostringstream">ostringstream 格式化字符串</a></li>
1126-
<li><a href="#cpp_tricks-adl">ADL 机制</a></li>
1126+
<li><a href="#cpp_tricks-adl">ADL 机制实现静态多态</a></li>
11271127
<li><a href="#cpp_tricks-shared_from_this">shared_from_this</a></li>
11281128
<li><a href="#cpp_tricks-requires">requires 语法检测是否存在指定成员函数</a></li>
11291129
<li><a href="#cpp_tricks-locale-utf8_1">设置 locale 为 .utf8 解决编码问题</a></li>
@@ -1208,7 +1208,7 @@ <h2 id="cpp_tricks-_2">读取整个文件到字符串</h2>
12081208
</code></pre>
12091209
<p>这样就可以把整个文件读取到内存中,进行处理后再写回文件。</p>
12101210
<blockquote>
1211-
<p><img src="../img/question.png" height="30px" width="auto" style="margin: 0; border: none"/> <code>std::ios::binary</code> 选项打开文件,是为了避免文件中出现 <code>'\n'</code> 时, MSVC 标准库自动转换成 <code>'\r\n'</code>,以保证跨平台。</p>
1211+
<p><img src="../img/bulb.png" height="30px" width="auto" style="margin: 0; border: none"/> 推荐用 <code>std::ios::binary</code> 选项打开二进制文件,否则字符串中出现 <code>'\n'</code> 时,会被 MSVC 标准库自动转换成 <code>'\r\n'</code> 来写入,妨碍我们跨平台。</p>
12121212
</blockquote>
12131213
<h2 id="cpp_tricks-_3">别再写构造函数啦!</h2>
12141214
<pre><code class="language-cpp">// C++98
@@ -1902,7 +1902,7 @@ <h2 id="cpp_tricks-_7">智能指针防止大对象移动</h2>
19021902

19031903
using BigTypePtr = unique_ptr&lt;BigType&gt;;
19041904

1905-
vector&lt;BigType&gt; arr;
1905+
vector&lt;BigTypePtr&gt; arr;
19061906

19071907
void func(BigTypePtr x) {
19081908
arr.push_back(std::move(x)); // 只拷贝 8 字节的指针,其指向的 4000 字节不用深拷贝了,直接移动所有权给 vector 里的 BigTypePtr 智能指针
@@ -2489,7 +2489,7 @@ <h2 id="cpp_tricks-ostringstream">ostringstream 格式化字符串</h2>
24892489
<p>利用临时变量语法,可以浓缩写在一行里,做个 format 拙劣的模仿者:</p>
24902490
<pre><code class="language-cpp">auto str = (std::ostringstream() &lt;&lt; &quot;你好,&quot; &lt;&lt; name &lt;&lt; &quot;!答案是 &quot; &lt;&lt; answer &lt;&lt; &quot;,十六进制:0x&quot; &lt;&lt; std::hex &lt;&lt; std::setfill('0') &lt;&lt; std::setw(2) &lt;&lt; answer &lt;&lt; &quot;\n&quot;).str();
24912491
</code></pre>
2492-
<h2 id="cpp_tricks-adl">ADL 机制</h2>
2492+
<h2 id="cpp_tricks-adl">ADL 机制实现静态多态</h2>
24932493
<p>TODO</p>
24942494
<h2 id="cpp_tricks-shared_from_this">shared_from_this</h2>
24952495
<h2 id="cpp_tricks-requires">requires 语法检测是否存在指定成员函数</h2>

search/search_index.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

sitemap.xml.gz

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)