C++20
出自 cppreference.com
< cpp
C++20 是繼 C++17 之後的主要版本,包含主要特性(concepts、modules、coroutines 和 ranges)以及其他語言和函式庫特性。該標準於 2020 年 12 月發布。
| 本節尚不完整 |
目錄 |
[編輯] 新語言特性
- 特性測試巨集 (Feature test macros)
- 三路比較運算子 <=> 與 operator==() = default
- 指派初始化器 (Designated initializers)
- 範圍
for中的初始化語句與初始化器 - char8_t
- 新屬性:
[[no_unique_address]]、[[likely]]、[[unlikely]] - 封裝展開 (Pack-expansions) 於 lambda 初始化擷取中
- 在許多語境下移除必須使用
typename來消除型別歧義的需求 - consteval, constinit
- 進一步放寬 constexpr
- 有號整數採用二補數 (2's complement)
- 位元移位運算子行為統一
- 使用圓括號進行聚合初始化 (aggregate initialization)
- 協程 (coroutines)
- 模組 (modules)
- 約束 (Constraints) 與概念 (concepts)
- 簡略函式模板 (Abbreviated function template)
- DR11:array new 可以推導陣列大小
[編輯] 新函式庫特性
[編輯] 新標頭檔
- <bit>
- <compare>
- <concepts>
- <coroutine>
- <format>
- <numbers>
- <ranges>
- <source_location>
- <span>
- <syncstream>
- <version>
於 執行緒支援函式庫
[編輯] 函式庫特性
- 函式庫特性測試巨集
- 格式化 (Formatting) 函式庫
- 概念 (Concepts) 函式庫
- <chrono> 中的日曆 (Calendar) 與 時區 (Time zone) 函式庫
- std::source_location
- std::span
- std::endian:
big/little/native - <bit> 中的整數 2 的冪次運算與 std::bit_cast
- std::make_shared 對陣列的支援
- std::remove_cvref
- std::to_address
- 浮點數原子操作、std::shared_ptr 原子操作
- 執行緒協調類別:std::barrier、std::latch 以及 std::counting_semaphore
- std::jthread 與 執行緒取消類別:std::stop_token、std::stop_source 以及 std::stop_callback
- std::basic_osyncstream
- std::basic_string 以及其他 char8_t 之用途
- <algorithm>、<utility>、<complex> 的 constexpr 支援
- string::starts_with / ends_with 以及 string_view::starts_with / ends_with
- std::assume_aligned
- std::bind_front
- std::c8rtomb / std::mbrtoc8
- std::make_obj_using_allocator 等
- std::make_shared_for_overwrite / std::make_unique_for_overwrite
- 無序關聯容器中的異質查找 (Heterogeneous lookup)
- 帶有額外成員函式且以 std::byte 作為預設模板引數的 std::pmr::polymorphic_allocator
- execution::unseq
- std::midpoint 與 std::lerp
- std::ssize
- std::is_bounded_array、std::is_unbounded_array
- 範圍 (Ranges)
- 統一容器刪除:std::erase / std::erase_if,例如 std::erase(std::list) 或 erase_if(std::map) 等
- <numbers> 中的數學常數
[編輯] 缺陷報告 (Defect reports)
[編輯] 編譯器支援
主條目:C++20 編譯器支援
[編輯] C++20 核心語言特性
| C++20 特性 |
提案論文 (Papers) |
GCC |
Clang |
MSVC |
Apple Clang |
EDG eccp |
Intel C++ |
Nvidia HPC C++ (原 PGI)* |
Nvidia nvcc |
Cray |
|
|---|---|---|---|---|---|---|---|---|---|---|---|
| 允許 Lambda 擷取 [=, this] | P0409R2 | 8 | 6 | 19.22* | 10.0.0* | 5.1 | 2021.1 | 20.7 | 12.0 | 11.0 | |
__VA_OPT__
|
P0306R4 P1042R1 |
8 (部分支援)* 10 (部分支援)* 12 |
9 | 19.25* | 11.0.3* | 5.1 | 2021.1 | 20.7 | 12.0 | 11.0 | |
| 指派初始化器 (Designated initializers) (FTM)* | P0329R4 | 4.7 (部分支援)* 8 |
3.0 (部分支援)* 10 |
19.21* | 12.0.0* | 5.1 | 2021.1 | 20.7 | 12.0 | 11.0 | |
| 泛型 Lambda 的模板參數列表 (FTM)* | P0428R2 | 8 | 9 | 19.22* | 11.0.0* | 5.1 | 2021.1 | 20.7 | 12.0 | 11.0 | |
| 位元欄位 (bit-fields) 的預設成員初始化器 | P0683R1 | 8 | 6 | 19.25* | 10.0.0* | 5.1 | 2021.1 | 20.7 | 12.0 | 11.0 | |
| 類別模板引數推導 (CTAD) 中的初始化列表構造函式 | P0702R1 | 8 | 6 | 19.14* | 是 | 5.0 | 2021.1 | 20.7 | 12.0 | 11.0 | |
| const& 修飾的成員指標 | P0704R1 | 8 | 6 | 19.0 (2015)* | 10.0.0* | 5.1 | 2021.1 | 20.7 | 12.0 | 11.0 | |
| 概念 (Concepts) (FTM)* | P0734R0 | 5* 10 |
10 | 19.23* (部分支援)* 19.30* |
12.0.0* (部分支援) | 6.1 | 2023.1* | 20.11 | 12.0 | 11.0 | |
| 未求值語境 (unevaluated contexts) 中的 Lambda | P0315R4 | 9 | 13 (部分支援)* 14 (部分支援)* 17 |
19.28 (16.8)* | 13.1.6* (部分支援) | 6.2 | 2023.1 (部分支援) 2024.0 |
20.7 | 12.0 | ||
| 三路比較運算子 (FTM)* | P0515R3 | 10 | 8 (部分支援) 10 |
19.20* | 12.0.0* | 5.1 | 2021.1 | 20.7 | 12.0 | 11.0 | |
| DR11:簡化隱式 Lambda 擷取 | P0588R1 | 8 | 19.24* | 5.1 | 2021.1 | 20.7 | 12.0 | ||||
| 範圍 for 迴圈中的初始化語句 | P0614R1 | 9 | 8 | 19.25* | 11.0.0* | 6.0 | 2021.7 | 20.11 | 12.0 | 11.0 | |
| 可預設構造與可賦值的無狀態 lambda | P0624R2 | 9 | 8 | 19.22* | 10.0.1* | 5.1 | 2021.1 | 20.7 | 12.0 | 11.0 | |
| 預設特化成員函式的型別不匹配 | P0641R2 | 9 (部分支援)* | 8 | 19.0 (2015)* (部分支援)* | 10.0.1* | 5.1 | 2021.1 | 20.7 | 12.0 | 11.0 | |
| 特化版本的存取檢查 | P0692R1 | 是 | 8 (部分支援) 14 |
19.26* | 14.0.0* | 5.1 | 2021.1 | 20.7 | 12.0 | ||
| ADL 與不可見的函式模板 | P0846R0 | 9 | 9 | 19.21* | 11.0.3* | 5.1 | 2021.1 | 20.7 | 12.0 | 11.0 | |
| DR11:明確何時常量求值需要 constexpr 函式定義 (FTM)* | P0859R0 | 5.2 (部分支援)* 9 |
8 | 19.27* (部分支援)* 19.31** |
11.0.0* | (部分支援) | 12.0 | 11.0 | |||
屬性 [[likely]] 與 [[unlikely]] |
P0479R5 | 9 | 12 | 19.26* | 13.0.0* | 5.1 | 2021.7 | 20.7 | 12.0 | ||
| 使 typename 在更多場合可省略 | P0634R3 | 9 | 16 | 19.29 (16.10)* | 16.0.0* | 5.1 | 2023.1 | 20.7 | 12.0 | ||
| 封裝展開 (Pack-expansions) 於 lambda 初始化擷取中 (FTM)* | P0780R2 | 9 | 9 | 19.22* | 11.0.3* | 6.1 | 2021.7 | 20.11 | 12.0 | 11.0 | |
屬性 [[no_unique_address]] |
P0840R2 | 9 | 9 | 19.28 (16.9)** | 11.0.3* | 5.1 | 2021.1 | 20.7 | 12.0 | 11.0 | |
| 有條件的瑣碎 (trivial) 特化成員函式 (FTM)* | P0848R3 | 10 | 16 | 19.28 (16.8)* | 6.1 | 2021.7 | 20.11 | 12.0 | |||
| DR17:放寬結構化綁定 (structured bindings) 定制點查找規則 | P0961R1 | 8 | 8 | 19.20* | 10.0.1* | 5.1 | 2021.1 | 20.7 | 12.0 | 11.0 | |
| DR11:放寬 range-for 迴圈定制點查找規則 | P0962R1 | 8 | 8 | 19.25* | 11.0.0* | 5.1 | 2021.1 | 20.7 | 12.0 | 11.0 | |
| DR17:允許結構化綁定存取可存取的成員 | P0969R0 | 8 | 8 | 19.20* | 10.0.1* | 5.1 | 2021.1 | 20.7 | 12.0 | 11.0 | |
破壞性 operator delete (FTM)* |
P0722R3 | 9 | 6 | 19.27* | 10.0.0* | 6.1 | 2023.1 | 20.11 | 12.0 | 11.0 | |
| 非型別模板參數中的類別型別 | P0732R2 | 9 | 12 (部分支援) | 19.26*(部分支援)* 19.28 (16.9)* |
13.0.0* (部分支援) | 6.2 | 2023.1 (部分支援) | 21.3 | 12.0 | ||
棄用經由 [=] 對 this 的隱式擷取 |
P0806R2 | 9 | 7 | 19.22* | 10.0.1* | 5.1 | 20.7 | 12.0 | 11.0 | ||
| explicit(bool) (FTM)* | P0892R2 | 9 | 9 | 19.24* | 11.0.3* | 5.1 | 2021.1 | 20.7 | 12.0 | 11.0 | |
| 整合特性測試巨集 | P0941R2 | 5 | 3.4 | 19.15* (部分支援) 19.20* |
是 | 5.0 | 2021.1 | 20.7 | 12.0 | 11.0 | |
| 禁止具有使用者宣告構造函式的聚合型別 | P1008R1 | 9 | 8 | 19.20* | 10.0.1* | 5.1 | 2021.1 | 20.7 | 12.0 | 11.0 | |
| constexpr 虛擬函式 (FTM)* | P1064R0 | 9 | 9 | 19.28 (16.9)* | 11.0.3* | 5.1 | 2021.1 | 20.7 | 12.0 | 11.0 | |
| 比較運算子的一致性改進 | P1120R0 | 10 | 8 (部分支援) 10 |
19.22* | 12.0.0* | 5.1 | 2023.1 | 20.7 | 12.0 | 11.0 | |
char8_t (FTM)* |
P0482R6 | 9 | 7* | 19.22* | 10.0.0* | 5.1 | 2021.1 | 20.7 | 12.0 | 11.0 | |
| std::is_constant_evaluated() (FTM)* | P0595R2 | 9 | 9 | 19.25* | 11.0.3* | 5.1 | 19.1 | 21.1 | 12.0 | 11.0 | |
| constexpr try-catch 區塊 | P1002R1 | 9 | 8 | 19.25* | 10.0.1* | 5.1 | 2023.1 | 20.7 | 12.0 | 11.0 | |
| 立即函式 (Immediate functions) (consteval) (FTM)* | P1073R3 | 10 (部分支援)* 11 |
11 (部分支援) 14 (部分支援)* 17 |
19.28 (16.8)* (部分支援)* 19.29 (16.10)* |
11.0.3* (部分支援) 15.0.0* |
5.1 | 2021.1 | 20.7 | 12.0 | ||
| 巢狀內聯 (inline) 命名空間 | P1094R2 | 9 | 8 | 19.27* | 10.0.1* | 5.1 | 2021.1 | 20.7 | 12.0 | 11.0 | |
| 受限 (constrained) 宣告的另一種方法 | P1141R2 | 10 | 10 | 19.26* (部分支援) 19.28 (16.9)* |
12.0.5* | 6.1 | 2023.1 | 20.11 | 12.0 | 11.0 | |
| 有號整數採用二補數 | P1236R1 | 9 | 9 | 是 | 11.0.3* | 不適用 (N/A) | 2023.1* | 是* | 12.0 | 11.0 | |
| 常量表達式中的 dynamic_cast 與多型 typeid | P1327R1 | 10 | 9 | 19.28 (16.9)* | 11.0.3* | 5.1 | 2021.1 | 20.7 | 12.0 | 11.0 | |
| 在 constexpr 內更改 union 的活躍成員 (FTM)* | P1330R0 | 9 | 9 | 19.10* | 11.0.3* | 5.1 | 2021.1 | 20.7 | 12.0 | 11.0 | |
| 協程 (Coroutines) (FTM)* (FTM)* | P0912R5 LWG3393 |
10 | 8 (部分支援) 17 (部分支援)* |
19.0 (2015)* (部分支援) 19.10** 19.28 (16.8)* |
10.0.1* (部分支援) | 5.1 | 2021.1 | 23.3* | 12.0 (僅限主機代碼) | ||
| 使用圓括號初始化聚合型別 (FTM)* | P0960R3 | 10 | 16 | 19.28 (16.8)* | 16.0.0* | 5.1 | 2021.1 | 20.7 | 12.0 | ||
DR11:new 表達式中的陣列大小推導 |
P1009R2 | 11 | 9 | 19.27* | 11.0.3* | 5.1 | 2021.1 | 20.7 | 12.0 | 11.0 | |
| 模組 (Modules) (FTM)* | P1103R3 | 11 (部分支援) | 8 (部分支援) | 19.0 (2015)* (部分支援) 19.10** 19.28 (16.8)* |
10.0.1* (部分支援) | 2023.1 (部分支援) | |||||
| 更嚴格的 Unicode 要求 | P1041R4 P1139R2 |
10 | 是 | 19.0 (2015)** 19.26** |
是 | 不適用 (N/A) | 2023.1* | 是 | 12.0 | 11.0 | |
<=> != ==
|
P1185R2 | 10 | 10 | 19.22* | 12.0.0* | 5.1 | 2021.1 | 20.7 | 12.0 | 11.0 | |
| DR11:具有不同異常規範的明確預設 (defaulted) 函式 | P1286R2 | 10 | 9 | 19.28 (16.8)* | 11.0.3* | 5.1 | 2021.1 | 20.7 | 12.0 | 11.0 | |
| 結構化綁定的 Lambda 擷取與儲存類別說明符 | P1091R3 P1381R1 |
10 | 8 (部分支援) 16 |
19.11** 19.24** |
16.0.0* | 5.1 | 2021.1 | 20.7 | 12.0 | ||
| 允許轉換為未知界限的陣列 | P0388R4 | 10 | 14 | 19.27* | 14.0.0* | 6.0 | 2021.5 | 20.11 | 12.0 | ||
| constexpr 容器操作 (FTM)* | P0784R7 | 10 | 10 | 19.28 (16.9)* | 12.0.0* | 6.0 | 2021.5 | 20.11 | 12.0 | 11.0 | |
棄用某些 volatile 之用法 |
P1152R4 | 10 | 10 | 19.27* | 12.0.0* | 6.0 | 2021.5 | 20.11 | 12.0 | 11.0 | |
| constinit (FTM)* | P1143R2 | 10 | 10 | 19.29 (16.10)* | 12.0.0* | 6.1 | 2021.7 | 20.11 | 12.0 | 11.0 | |
| 棄用下標運算子中的逗號運算子 | P1161R3 | 10 | 9 | 19.25* | 11.0.3* | 6.0 | 2021.7 | 20.11 | 12.0 | 11.0 | |
帶訊息的 [[nodiscard]] |
P1301R4 | 10 | 9 | 19.25* | 11.0.3* | 6.0 | 2021.5 | 20.11 | 12.0 | 11.0 | |
| constexpr 函式中的瑣碎預設初始化 (Trivial default initialization) | P1331R2 | 10 | 10 | 19.27* | 12.0.0* | 6.1 | 2021.7 | 20.11 | 12.0 | 11.0 | |
| constexpr 函式中未求值的 asm 宣告 | P1668R1 | 10 | 10 | 19.28 (16.9)* | 12.0.0* | 6.1 | 2021.7 | 20.11 | 12.0 | 11.0 | |
| using enum (FTM)* | P1099R5 | 11 | 13 | 19.24* | 13.1.6* | 6.3 | 2023.1 | 22.5 | 12.0 | ||
| 為指定比較類別合成三路比較 | P1186R3 | 11 | 10 | 19.24* | 12.0.0* | 6.0 | 2021.5 | 20.11 | 12.0 | 11.0 | |
DR17:構造函式的 [[nodiscard]] |
P1771R1 | 10 | 9 | 19.24* | 11.0.3* | 6.0 | 2021.5 | 20.11 | 12.0 | 11.0 | |
| 別名模板的類別模板引數推導 (FTM)* | P1814R0 | 10 | 19 | 19.27* | 6.5 | 23.9 | 12.0 | ||||
| 聚合型別的類別模板引數推導 (FTM)* | P1816R0 P2082R1 |
10* 11* |
17 | 19.27* | 6.3 | 2023.1 (部分支援)* 2024.1 |
23.3 | 12.0 | |||
| DR11:為更多區域物件與右值引用提供隱式移動 (Implicit move) | P1825R0 | 11* | 13 | 19.24* | 13.1.6* | 6.0 | 2021.5 | 20.11 | 12.0 | ||
| 允許依值 (by value) 提供預設比較 | P1946R0 | 10 | 10 | 19.25* | 12.0.0* | 6.1 | 2021.7 | 20.11 | 12.0 | 11.0 | |
移除 std::weak_equality 與 std::strong_equality |
P1959R0 | 10 | 10 | 19.25* | 12.0.0* | 6.1 | 2021.7 | 20.11 | 12.0 | 11.0 | |
| 非型別模板參數的不一致性修復 (FTM)* | P1907R1 | 10 (部分支援) 11 |
18 (部分支援)* | 19.26* | 13.1.6* (部分支援) | 6.2 | 2023.1 (部分支援) | 21.3 | 12.0 | ||
| DR98:偽析構函式 (Pseudo-destructors) 結束物件生命週期 | P0593R6 | 11 | 11 | 是 | 12.0.5* | 不適用 (N/A) | 2023.1* | 是 | 12.0 | 11.0 | |
| DR11:從 T* 轉換為 bool 應被視為窄化轉換 (narrowing) | P1957R2 | 10* 11* |
11 | 19.27* | 12.0.5* | 6.1 | 12.0 | 11.0 | |||
| C++20 特性 |
提案論文 (Papers) |
GCC |
Clang |
MSVC |
Apple Clang |
EDG eccp |
Intel C++ |
Nvidia HPC C++ (原 PGI)* |
Nvidia nvcc |
Cray |
[編輯] C++20 函式庫特性
| C++20 特性 |
提案論文 (Papers) |
GCC libstdc++ |
Clang libc++ |
MSVC STL |
Apple Clang* |
|
|---|---|---|---|---|---|---|
| std::endian (FTM)* | P0463R1 | 8 | 7 | 19.22* | 10.0.0* | |
| 擴展 std::make_shared() 以支援陣列 (FTM)* | P0674R1 | 12 | 15 | 19.27* | 14.0.3* | |
| 浮點數原子操作 (FTM)* | P0020R6 | 10 | 18 | 19.22* | 16.0.0* | |
| 同步緩衝 (std::basic_osyncstream) (FTM)* | P0053R7 | 11 | 18 | 19.29 (16.10)* | ||
| <algorithm> 與 <utility> 的 constexpr 支援 (FTM)* | P0202R3 | 10 | 8 (部分支援) 12 |
19.26* | 10.0.1* (部分支援) 13.0.0* | |
| 為 <complex> 提供更多 constexpr 支援 (FTM)* | P0415R1 | 9 | 7 (部分支援) 16 |
19.27* | 10.0.0* (部分支援) 15.0.0* | |
| 使 std::memory_order 成為具域列舉 (scoped enumeration) | P0439R0 | 9 | 9 | 19.25* | 11.0.3* | |
| 字串前綴與後綴檢查:string(_view) ::starts_with / ends_with (FTM)* | P0457R2 | 9 | 6 | 19.21* | 10.0.0* | |
operator<=> 的函式庫支援 <compare> (FTM)* |
P0768R1 | 10 | 7 (部分支援) 12 (部分支援)* 17 |
19.20* (部分支援) 19.28 (16.9)* |
13.0.0* | |
| std::remove_cvref (FTM)* | P0550R2 | 9 | 6 | 19.20* | 10.0.0* | |
標準函式庫中的 [[nodiscard]] |
P0600R1 | 9 | 7 (部分支援) 16 |
19.13* (部分支援) 19.22* |
10.0.0* (部分支援) 15.0.0* | |
| 在數值演算法中使用 std::move | P0616R0 | 9 | 12 | 19.23* | 13.0.0* | |
| 將指標轉換為原始指標的工具 (FTM)* | P0653R2 | 8 | 6 | 19.22* | 是 | |
| 原子化 std::shared_ptr 與 std::weak_ptr (FTM)* | P0718R2 | 12 | 19.27* | |||
| std::span (FTM)* | P0122R7 | 10 | 7 | 19.26* | 10.0.0* | |
| 日曆 (Calendar) 與 時區 (Time zone) (FTM)* | P0355R7 | 11 (部分支援)* 13 (部分支援)* 14 |
7 (部分支援) 19 (部分支援)* |
19.29 (16.10)* | 10.0.0* (部分支援) | |
| <version> | P0754R2 | 9 | 7 | 19.22* | 10.0.0* | |
| 無序容器的比較 | P0809R0 | 是 | 是 | 16.0* | 是 | |
| ConstexprIterator 要求 (FTM)* (FTM)* | P0858R0 | 9 | 12 | 19.11* | 13.0.0* | |
| std::basic_string::reserve() 不應縮減容量 | P0966R1 | 11 | 8 | 19.25* | 10.0.1* | |
| 帶有填充位元的原子比較與交換 (Atomic Compare-And-Exchange) | P0528R3 | 13 | 19.28 (16.8)* | |||
| std::atomic_ref (FTM)* | P0019R8 | 10 | 19 | 19.28 (16.8)* | ||
| 關聯容器的 contains() 成員函式,例如 std::map::contains() | P0458R2 | 9 | 13 | 19.21* | 13.1.6* | |
| DR11:為分段構造 (piecewise construction) 提供保證的複製消除 (copy elision) | P0475R1 | 9 | 是 | 19.29 (16.10)* | 是 | |
| std::bit_cast() (FTM)* | P0476R2 | 11 | 14 | 19.27* | 14.0.3* | |
| 整數 2 的冪次運算 std::bit_ceil(), std::bit_floor(), std::bit_width(), std::has_single_bit() (FTM)* |
P0556R3 P1956R1 |
9* 10* |
9* 12* |
19.25** 19.27** 19.28 (16.8)* |
11.0.3** 13.0.0** | |
| 改進類似 erase 演算法的返回值 (FTM)* | P0646R1 | 9 | 10 | 19.21* | 12.0.0* | |
| std::destroying_delete_t (FTM)* | P0722R3 | 9 | 9 | 19.27* | 11.0.3* | |
| std::is_convertible (FTM)* | P0758R1 | 9 | 9 | 19.23* | 11.0.3* | |
| 將 std::shift_left/right 新增至 <algorithm> (FTM)* | P0769R2 | 10 | 12 | 19.21* | 13.0.0* | |
為 std::swap() 與 swap 相關函式提供 Constexpr 支援 |
P0879R0 | 10 | 13 | 19.26* | 13.1.6* | |
| std::type_identity (FTM)* | P0887R1 | 9 | 8 | 19.21* | 10.0.1* | |
| 概念 (Concepts) 函式庫 (FTM)* | P0898R3 | 10 | 13 | 19.23* | 13.1.6* | |
std::array 的 constexpr 比較運算子 |
P1023R0 | 10 | 8 | 19.27* | 10.0.1* | |
std::unwrap_ref_decay 與 std::unwrap_reference (FTM)* |
P0318R1 | 9 | 8 | 19.21* | 10.0.1* | |
| std::bind_front() (FTM)* | P0356R5 | 9 | 13 | 19.25* | 13.1.6* | |
| 為不完整型別提供 std::reference_wrapper | P0357R3 | 9 | 8 | 19.26* | 10.0.1* | |
| 修復 operator>>(basic_istream&, CharT*) | P0487R1 | 11 | 8 | 19.23* | 10.0.1* | |
char8_t 的函式庫支援 (FTM)* |
P0482R6 | 9 | 8 (部分支援) 16 |
19.22* | 10.0.1* (部分支援) 15.0.0* | |
| 實作 uses-allocator 構造 (construction) 的工具函式 | P0591R4 | 9 | 16 | 19.29 (16.10)* | 15.0.0* | |
| DR17:std::variant 與 std::optional 應傳遞複製/移動之瑣碎性 (triviality) | P0602R4 | 8.3 | 8 | 19.11* | 10.0.1* | |
| DR17:更合理的 std::variant 轉換構造函式 | P0608R3 | 10 | 9 | 19.29 (16.10)** 19.42** |
11.0.3* | |
| std::function 的移動構造函式應為 noexcept | P0771R1 | 7.2 | 6 | 19.22* | 是 | |
| Ranges 提案 全文 (FTM)* | P0896R4 | 10 | 13 (部分支援) 15* |
19.29 (16.10)* | 14.0.3* | |
| 無序關聯容器的異質查找 (FTM)* | P0919R3 P1690R1 |
11 | 12 | 19.23* (P0919R3) 19.25* (P1690R1) |
13.0.0* | |
<chrono> zero()、min() 與 max() 應為 noexcept |
P0972R0 | 9 | 8 | 19.14* | 10.0.1* | |
| std::pointer_traits 中的 constexpr 支援 (FTM)* | P1006R1 | 9 | 8 | 19.26* | 10.0.1* | |
| std::assume_aligned() (FTM)* | P1007R3 | 9* 11 |
15 | 19.28 (16.9)* | 14.0.3* | |
| 使用預設初始化建立智慧指標 (例如 make_unique_for_overwrite) (FTM)* | P1020R1 P1973R1 |
11* 12* |
16 | 19.28 (16.9)* | 15.0.0* | |
| 雜項 constexpr 支援 (FTM)* (FTM)* (FTM)* (FTM)* (FTM)* (FTM)* | P1032R1 | 10 | 13 | 19.28 (16.8)* | 13.1.6* | |
| 移除 std::span 的比較運算子 | P1085R2 | 10 | 8 | 19.26* | 10.0.1* | |
| 使具狀態分配器 (stateful allocator) 的傳遞在 operator+(basic_string) 中更一致 | P1165R1 | 10 | 15 | 19.26* | 14.0.3* | |
| 一致的容器刪除操作,例如 std::erase(std::vector) 或 std::erase_if(std::map) (FTM)* | P1209R0 P1115R3 |
9* 10* |
8* 11* |
19.25** 19.27** |
10.0.1** 12.0.5** | |
| 標準函式庫標頭檔單元 (Header units) | P1502R1 | 11 | 19.29 (16.10)* | |||
| 作為詞彙型別 (vocabulary type) 的 polymorphic_allocator<> (FTM)* | P0339R6 | 9 | 16 | 19.28 (16.9)* | 15.0.0* | |
| std::execution::unseq (FTM)* | P1001R2 | 9 | 17 | 19.28 (16.8)* | ||
| std::lerp() 與 std::midpoint() (FTM)* | P0811R3 | 9 | 9 | 19.23* (部分支援) 19.28 (16.8)* |
11.0.3* | |
| std::span 的可用性增強 | P1024R3 | 10 | 9* 14 |
19.26* | 11.0.3* | |
| DR17:使 std::create_directory() 更直觀 | P1164R1 | 8.3 | 12 | 19.20* | 13.0.0* | |
| std::ssize() 與 std::span 的無符號範圍 (extent) (FTM)* | P1227R2 | 10 | 9 | 19.25* | 11.0.3* | |
| (無)有界陣列的特徵 (Traits) (FTM)* | P1357R1 | 9 | 9 | 19.25* | 11.0.3* | |
| std::to_array() (FTM)* | P0325R4 | 10 | 10 | 19.25* | 12.0.0* | |
| 高效存取 std::basic_stringbuf 的緩衝區 | P0408R7 | 11 | 17 | 19.29 (16.10)* | 15.0.0* | |
| 佈局一致性 (Layout-compatibility) 與指標互轉性 (pointer-interconvertibility) 特徵 (FTM)* (FTM)* | P0466R5 | 12 | 19.29 (16.10)** | |||
| 位元操作:std:: rotl(), rotr(), countl_zero(), countl_one(), countr_zero(), countr_one(), popcount() (FTM)* |
P0553R4 | 9 | 9 | 19.25** 19.28 (16.8)* |
11.0.3* | |
| 數學常數 (FTM)* | P0631R8 | 10 | 11 | 19.25* | 12.0.5* | |
| 文字格式化 (Text formatting) (FTM)* | P0645R10 | 13 | 14** 17 |
19.29 (16.10)* | 15.0.0* | |
| std::stop_token 與 std::jthread (FTM)* | P0660R10 | 10 | 17 (部分支援)* 20* |
19.28 (16.9)* | ||
| constexpr std::allocator 及相關工具 (FTM)* | P0784R7 | 10 | 12 | 19.29 (16.10)* | 13.0.0* | |
| constexpr std::string (FTM)* | P0426R1 P1032R1 P0980R1 |
12 | 15 | 19.29 (16.10)* 19.30** |
14.0.3* | |
| constexpr std::vector (FTM)* | P1004R2 | 12 | 15 | 19.29 (16.10)* 19.30** |
14.0.3* | |
| 輸入範圍配接器 (range adaptors) | P1035R7 | 10 | 16 | 19.29 (16.10)* | 15.0.0* | |
| constexpr std::invoke() 及相關工具 | P1065R2 | 10 | 12 | 19.28 (16.8)* | 13.0.0* | |
| 原子等待與通知、std::counting_semaphore、std::latch 以及 std::barrier (FTM)* (FTM)* (FTM)* (FTM)* (FTM)* (FTM)* | P1135R6 | 11 | 11 | 19.28 (16.9)* | 13.1.6* | |
| std::source_location (FTM)* | P1208R6 | 11 | 15* (部分支援) 16 |
19.29 (16.10)* | 15.0.0* | |
| 將 <=> 新增至標準函式庫 | P1614R2 | 10 | 14* (部分支援) 17* (部分支援) 19 |
19.29 (16.10)* | 13.1.6* (部分支援) | |
| std::atomic 與 std::atomic_flag 的 constexpr 預設構造函式 (FTM)* | P0883R2 | 10 | 13 | 19.26* | 13.1.6* | |
| 數值演算法的 constexpr 支援 (FTM)* | P1645R1 | 10 | 12 | 19.26* | 13.0.0* | |
| 安全整數比較 (FTM)* | P0586R2 | 10 | 13 | 19.27* | 13.1.6* | |
| C++20 特性 |
提案論文 (Papers) |
GCC libstdc++ |
Clang libc++ |
MSVC STL |
Apple Clang* |
* - 將游標懸停在標有星號 * 的儲存格上可查看額外的彈出說明。
DRnn - "DR" 後的數字 nn 表示該缺陷報告適用的 C++ 修訂版本,例如 DR20 → C++20。
[編輯] 外部連結
| 1. | C++20 - 維基百科 |
| 2. | C++20 實作範例 |