Skip to content

Commit 5dcb3b0

Browse files
committed
book: cover remaining C++26 proposals in preview chapter
Add a 12.2 subsection summarizing the remaining tracked C++26 proposals: structured binding enhancements, trivially relocatable types, user-generated static_assert messages / constexpr structured bindings, std::submdspan and span/mdspan enhancements, hardened library, and debugging support. Refs #318
1 parent f148826 commit 5dcb3b0

2 files changed

Lines changed: 26 additions & 0 deletions

File tree

book/en-us/12-cpp26.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,19 @@ C++26 also plans to bring many new library facilities, including:
105105
106106
> Most of these are not yet implemented in current standard libraries; whether a few of them (such as `std::hive`) are ultimately included in C++26 remains uncertain — defer to the final standard and cppreference.
107107
108+
### Other notable proposals
109+
110+
Beyond the features above, C++26 brings many improvements to both the language and the library, for example:
111+
112+
- **Structured binding enhancements**: allowing structured bindings in conditions (`if`/`while`), and introducing packs in structured bindings;
113+
- **Trivially relocatable types**: letting "move then destroy" be optimized into a single memory copy;
114+
- **User-generated `static_assert` messages** and **`constexpr` structured bindings**: making compile-time assertion messages producible from constant expressions;
115+
- **`std::submdspan`** and other enhancements to `std::span` / `std::mdspan` (such as construction from an `initializer_list`);
116+
- a **hardened standard library** and `std::is_within_lifetime`, improving safety;
117+
- **debugging support**, such as `std::breakpoint` and `std::is_debugger_present`.
118+
119+
> Again, the final form and inclusion of these proposals are subject to the final standard.
120+
108121
## 12.3 On the standard and implementation status
109122
110123
To reiterate: C++26 has not been officially released, the **final syntax and inclusion of the features described here may change**, and only a small subset (pack indexing, `= delete` with a reason, the placeholder `_`, saturation arithmetic) can currently be compiled and run. Readers are encouraged to follow [cppreference: C++26](https://en.cppreference.com/w/cpp/26) and the [compiler support page](https://en.cppreference.com/w/cpp/compiler_support) for the latest progress.

book/zh-cn/12-cpp26.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,19 @@ C++26 还计划带来许多新的库设施,包括:
105105
106106
> 这些设施在当前标准库中大多尚未实现;其中个别设施(如 `std::hive`)是否会最终纳入 C++26 仍存在不确定性,请以最终标准与 cppreference 为准。
107107
108+
### 其他值得关注的提案
109+
110+
除上述特性外,C++26 还在语言与库两方面带来许多改进,例如:
111+
112+
- **结构化绑定的增强**:允许结构化绑定出现在 `if`/`while` 等条件中,以及在结构化绑定中引入包(pack);
113+
- **平凡可重定位类型**(trivially relocatable):让「移动后再销毁」可以被优化为一次内存拷贝;
114+
- **用户生成的 `static_assert` 消息** 与 **`constexpr` 结构化绑定**:使编译期断言信息可由常量表达式生成;
115+
- **`std::submdspan`** 等对 `std::span` / `std::mdspan` 的增强(如从 `initializer_list` 构造);
116+
- **加固标准库**(hardened library)与 `std::is_within_lifetime`,提升安全性;
117+
- **调试支持**,如 `std::breakpoint`、`std::is_debugger_present`。
118+
119+
> 同样地,这些提案的最终形态与纳入与否仍以最终标准为准。
120+
108121
## 12.3 关于标准与实现状态
109122
110123
再次强调:C++26 尚未正式发布,本章所述特性的**最终语法与是否纳入标准都可能发生变化**,且当前能够编译运行的仅是其中一小部分(如形参包索引、带原因的 `= delete`、占位符 `_`、饱和算术)。建议读者持续关注 [cppreference: C++26](https://en.cppreference.com/w/cpp/26) 与 [编译器支持情况](https://en.cppreference.com/w/cpp/compiler_support) 以获取最新进展。

0 commit comments

Comments
 (0)