mirror of
https://github.com/Light-City/CPlusPlusThings.git
synced 2026-10-31 20:35:29 +08:00
- const README: rewrite the space-saving claim per issue #5 follow-ups (constant-expression const vs #define immediates; which const qualify as constant expressions) - const README: fix the class-section diagnosis per issue #338 (overload resolution picks the const overload; the restriction only surfaces once that overload is removed) - sizeof README: virtual-inheritance result is compiler-dependent (GCC merges vbptr+vfptr -> 16, MSVC keeps them separate -> 32) #246 - static README: new section on internal linkage / access restriction with anonymous-namespace comparison #142 - 10-day practice: full problem list table + fixed day links #136 - new design_pattern/singleton/singleton_default.hpp: reusable thread-safe CRTP singleton template, compile+concurrency tested #303
This commit is contained in:
51
site_extras/cpp-idioms-trigraphs-cpp.md
Normal file
51
site_extras/cpp-idioms-trigraphs-cpp.md
Normal file
@@ -0,0 +1,51 @@
|
||||
> 来自 [C++那些事网站](https://light-city.github.io/stories_things/cpp-idioms/trigraphs-cpp/) 的文章,由站点同步脚本导出。
|
||||
|
||||
# C++ 三字母词
|
||||
|
||||
## C++那些事之删除三字母
|
||||
|
||||
C++17 之前,Trigraph 是用 ISO/IEC 646 等小字符代码编写程序的功能,在 C89 中引入。 ISO/IEC 646 缺少 C 中使用的以下字符,因此`??`请使用以下字符进行转义:
|
||||
|
||||
| 三字母内容 | 替换的内容 |
|
||||
| ---------- | ---------- |
|
||||
| `??=` | `#` |
|
||||
| `??(` | `[` |
|
||||
| `??)` | `]` |
|
||||
| `??<` | `{` |
|
||||
| `??>` | `}` |
|
||||
| `??/` | `\` |
|
||||
| `??!` | `|` |
|
||||
| `??-` | `~` |
|
||||
| `??'` | `^` |
|
||||
|
||||
`\?`它被转义以防止被三字母表替换。
|
||||
|
||||
C++17三字母被删除,`??=`等不再被替换。
|
||||
|
||||
## 示例
|
||||
|
||||
C++17之前:
|
||||
|
||||
```cpp
|
||||
std::cout << "??=" << std::endl;
|
||||
std::cout << "??(" << std::endl;
|
||||
std::cout << "?\?(" << std::endl;
|
||||
```
|
||||
|
||||
输出:
|
||||
|
||||
```
|
||||
#
|
||||
[
|
||||
??(
|
||||
```
|
||||
|
||||
C++17及之后:
|
||||
|
||||
```
|
||||
??=
|
||||
??(
|
||||
??(
|
||||
```
|
||||
|
||||
现在可能由于Unicode等字符编码已经普遍存在,不再需要三字母组,而gcc等编译器默认禁用三字母组。
|
||||
Reference in New Issue
Block a user