Skip to content

Commit

Permalink
补充第 14 题的解释与措辞
Browse files Browse the repository at this point in the history
  • Loading branch information
Mq-b committed Oct 22, 2024
1 parent 572337c commit 18f30a3
Showing 1 changed file with 59 additions and 51 deletions.
110 changes: 59 additions & 51 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,75 +21,77 @@

- [前言](#前言)
- [`01` 实现管道运算符](#01-实现管道运算符)
+ [运行结果](#运行结果)
+ [群友提交](#群友提交-0)
+ [标准答案](#标准答案-0)
+ [解析](#解析-0)
- [运行结果](#运行结果)

Check failure on line 24 in README.md

View workflow job for this annotation

GitHub Actions / check

Unordered list style

README.md:24:1 MD004/ul-style Unordered list style [Expected: plus; Actual: dash] https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md004.md
- [群友提交](#群友提交)

Check failure on line 25 in README.md

View workflow job for this annotation

GitHub Actions / check

Unordered list style

README.md:25:1 MD004/ul-style Unordered list style [Expected: plus; Actual: dash] https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md004.md
- [标准答案](#标准答案)

Check failure on line 26 in README.md

View workflow job for this annotation

GitHub Actions / check

Unordered list style

README.md:26:1 MD004/ul-style Unordered list style [Expected: plus; Actual: dash] https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md004.md
- [解析](#解析)

Check failure on line 27 in README.md

View workflow job for this annotation

GitHub Actions / check

Unordered list style

README.md:27:1 MD004/ul-style Unordered list style [Expected: plus; Actual: dash] https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md004.md
- [`02` 实现自定义字面量 `_f`](#02-实现自定义字面量-_f)
+ [运行结果](#运行结果-1)
+ [群友提交](#群友提交-1)
+ [标准答案](#标准答案-1)
+ [解析](#解析-1)
- [运行结果](#运行结果-1)

Check failure on line 29 in README.md

View workflow job for this annotation

GitHub Actions / check

Unordered list style

README.md:29:1 MD004/ul-style Unordered list style [Expected: plus; Actual: dash] https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md004.md
- [群友提交](#群友提交-1)

Check failure on line 30 in README.md

View workflow job for this annotation

GitHub Actions / check

Unordered list style

README.md:30:1 MD004/ul-style Unordered list style [Expected: plus; Actual: dash] https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md004.md
- [标准答案](#标准答案-1)

Check failure on line 31 in README.md

View workflow job for this annotation

GitHub Actions / check

Unordered list style

README.md:31:1 MD004/ul-style Unordered list style [Expected: plus; Actual: dash] https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md004.md
- [解析](#解析-1)

Check failure on line 32 in README.md

View workflow job for this annotation

GitHub Actions / check

Unordered list style

README.md:32:1 MD004/ul-style Unordered list style [Expected: plus; Actual: dash] https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md004.md
- [`03` 实现 `print` 以及特化 `std::formatter`](#03-实现-print-以及特化-stdformatter)
+ [运行结果](#运行结果-2)
+ [群友提交](#群友提交-2)
+ [标准答案](#标准答案-2)
+ [解析](#解析-2)
- [运行结果](#运行结果-2)

Check failure on line 34 in README.md

View workflow job for this annotation

GitHub Actions / check

Unordered list style

README.md:34:1 MD004/ul-style Unordered list style [Expected: plus; Actual: dash] https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md004.md
- [群友提交](#群友提交-2)

Check failure on line 35 in README.md

View workflow job for this annotation

GitHub Actions / check

Unordered list style

README.md:35:1 MD004/ul-style Unordered list style [Expected: plus; Actual: dash] https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md004.md
- [标准答案](#标准答案-2)
- [解析](#解析-2)
- [`04` 给定类模板修改,让其对每一个不同类型实例化有不同 ID](#04-给定类模板修改让其对每一个不同类型实例化有不同-id)
+ [运行结果](#运行结果-3)
+ [群友提交](#群友提交-3)
+ [标准答案](#标准答案-3)
- [运行结果](#运行结果-3)
- [群友提交](#群友提交-3)
- [标准答案](#标准答案-3)
- [`05` 实现 `scope_guard` 类型](#05-实现-scope_guard-类型)
+ [运行结果](#运行结果-4)
+ [群友提交](#群友提交-4)
+ [标准答案](#标准答案-4)
- [运行结果](#运行结果-4)
- [群友提交](#群友提交-4)
- [标准答案](#标准答案-4)
- [`06` 解释 `std::atomic` 初始化](#06-解释-stdatomic-初始化)
+ [群友提交](#群友提交-5)
+ [标准答案](#标准答案-5)
- [群友提交](#群友提交-5)
- [标准答案](#标准答案-5)
- [`07` `throw new MyException`](#07-throw-new-myexception)
+ [运行结果](#运行结果-5)
+ [群友提交](#群友提交-6)
+ [标准答案](#标准答案-6)
- [运行结果](#运行结果-5)
- [群友提交](#群友提交-6)
- [标准答案](#标准答案-6)
- [`08` 定义`array`推导指引](#08-定义array推导指引)
+ [运行结果](#运行结果-6)
+ [群友提交](#群友提交-7)
+ [标准答案](#标准答案-7)
- [运行结果](#运行结果-6)
- [群友提交](#群友提交-7)
- [标准答案](#标准答案-7)
- [`09` 名字查找的问题](#09-名字查找的问题)
+ [运行结果](#运行结果-7)
+ [群友提交](#群友提交-8)
+ [标准答案](#标准答案-8)
- [运行结果](#运行结果-7)
- [群友提交](#群友提交-8)
- [标准答案](#标准答案-8)
- [`10` 遍历任意类数据成员](#10-遍历任意类数据成员)
+ [运行结果](#运行结果-8)
+ [群友提交](#群友提交-9)
+ [标准答案](#标准答案-9)
- [运行结果](#运行结果-8)
- [群友提交](#群友提交-9)
- [标准答案](#标准答案-9)
- [`C++17` 写法](#c17-写法)
- [`C++20` 写法](#c20-写法)
+ [补充说明](#补充说明-0)
- [无法处理引用类型以及不可移动类型](#无法处理引用类型以及不可移动类型)
- [补充说明](#补充说明)
- [`11` `emplace_back()` 的问题](#11-emplace_back-的问题)
+ [群友提交](#群友提交-10)
+ [标准答案](#标准答案-10)
- [群友提交](#群友提交-10)
- [标准答案](#标准答案-10)
- [`12` 实现`make_vector()`](#12-实现make_vector)
+ [运行结果](#运行结果-9)
+ [群友提交](#群友提交-11)
+ [标准答案](#标准答案-11)
- [运行结果](#运行结果-9)
- [群友提交](#群友提交-11)
- [标准答案](#标准答案-11)
- [运行结果](#运行结果-10)
- [`13` 关于 `return std::move`](#13-关于-return-stdmove)
+ [群友提交](#群友提交-12)
+ [标准答案](#标准答案-12)
- [群友提交](#群友提交-12)
- [标准答案](#标准答案-12)
- [`14` 以特殊方法修改命名空间中声明的对象](#14-以特殊方法修改命名空间中声明的对象)
+ [运行结果](#运行结果-11)
+ [群友提交](#群友提交-13)
+ [标准答案](#标准答案-13)
- [运行结果](#运行结果-11)
- [群友提交](#群友提交-13)
- [标准答案](#标准答案-13)
- [利用符号来解决](#利用符号来解决)
- [直接修改内存](#直接修改内存)
- [利用名字查找规则](#利用名字查找规则)
- [`15` 表达式模板](#15-表达式模板)
+ [群友提交](#群友提交-14)
+ [标准答案](#标准答案-14)
+ [解析](#解析-3)
- [运行结果](#运行结果-12)
- [群友提交](#群友提交-14)
- [标准答案](#标准答案-14)
- [解析](#解析-3)
- [`16` 制造传递函数模板的宏](#16-制造传递函数模板的宏)
+ [群友提交](#群友提交-15)
+ [标准答案](#标准答案-15)
- [群友提交](#群友提交-15)
- [标准答案](#标准答案-15)

</details>

Expand Down Expand Up @@ -2088,10 +2090,14 @@ int main(){

<br>

当然了,我们也可以利用预处理器,来进行兼容**原理**
当然了,我们也可以利用预处理指令 [`#pragma comment`](https://learn.microsoft.com/zh-cn/cpp/preprocessor/comment-c-cpp?view=msvc-170),来特殊处理 MSVC**原理**

- Itanium ABI 上变量 ss::a 的重整名为 _ZN2ss1aE。
- 在 MSVC 上需要用 #pragma 告诉链接器使用 MSVC ABI 的重整名 ?a@ss@@3HA
- [Itanium ABI](https://itanium-cxx-abi.github.io/cxx-abi/abi.html) 上变量 `ss::a` 的重整名为 `_ZN2ss1aE`
- 在 MSVC 可以使用 `#pragma comment` 添加 `/alternatename` 链接选项,指定在找不到符号 `?_ZN2ss1aE@@3HA` 时,使用符号 `?a@ss@@3HA` 作为替代。

>`?a@ss@@3HA` 就是 `ss::a` 的符号,而 `?_ZN2ss1aE@@3HA` 就是 `extern int _ZN2ss1aE` 的符号。
>
>因为 `_ZN2ss1aE` 没有定义,所以必然没有符号 `?_ZN2ss1aE@@3HA` ,就使用 `?a@ss@@3HA` 作为替代,那么此时操作 `_ZN2ss1aE` 如同操作 `ss::a`
```cpp
#include<iostream>
Expand All @@ -2110,6 +2116,8 @@ int main() {
}
```
>
> 来源:[聚聚](https://github.com/Mq-b/Loser-HomeWork/pull/194)。
#### 直接修改内存
Expand Down

0 comments on commit 18f30a3

Please sign in to comment.