C++20 的编译器支持

来自cppreference.com


* - 在版本号上停留可以查看注记 * 查看其他注记
DRnn - 在 "DR" 后的数字 nn 表示应用该缺陷报告的目标 C++ 修订版本,例如 DR20 → C++20。

[编辑] C++20 核心语言功能特性

C++20 功能特性

 
提案

 
GCC
Clang
MSVC
Apple Clang
EDG eccp
Intel C++
Nvidia HPC C++ (ex PGI)*
Nvidia nvcc
Cray
允许 lambda 捕获 [=, this]P0409R28619.22*10.0.0*5.12021.120.712.011.0
__VA_OPT__P0306R4
P1042R1
8 (部分)*
10 (部分)*
12
919.25*11.0.3*5.12021.120.712.011.0
指派初始化器  (FTM)*P0329R44.7 (部分)*
8
3.0 (部分)*
10
19.21*(部分)*5.12021.120.712.011.0
泛型 lambda 的模板形参列表  (FTM)*P0428R28919.22*11.0.0*5.12021.120.712.011.0
位域的默认成员初始化器P0683R18619.25*10.0.0*5.12021.120.712.011.0
类模板实参推导中的 intializer_list 构造函数P0702R18619.14*5.02021.120.712.011.0
const& 限定的成员指针P0704R18619.0 (2015)*10.0.0*5.12021.120.712.011.0
概念  (FTM)*P0734R05*
10
1019.23* (部分)*
19.30*
12.0.0* (部分)6.12023.1*20.1112.011.0
不求值语境中的 lambdaP0315R4913 (部分)*
14 (部分)*
17
19.28 (16.8)*13.1.6* (部分)6.22023.1 (部分)
2024.0
20.712.0
三路比较运算符  (FTM)*P0515R3108 (部分)
10
19.20*12.0.0*5.12021.120.712.011.0
DR11:简化隐式 lambda 捕获P0588R1819.24*5.12021.120.712.0
基于范围的 for 的初始化语句P0614R19819.25*11.0.0*6.02021.720.1112.011.0
可默认构造与可赋值的无状态 lambdaP0624R29819.22*10.0.1*5.12021.120.712.011.0
预置特殊成员函数的类型不匹配P0641R29 (部分)*819.0 (2015)* (部分)*10.0.1*5.12021.120.712.011.0
特化中的访问检查P0692R18 (部分)
14
19.26*14.0.0*5.12021.120.712.0
ADL 与不可见的函数模板P0846R09919.21*11.0.3*5.12021.120.712.011.0
DR11:指定 constexpr 函数定义何时为常量求值所需要  (FTM)*P0859R05.2 (部分)*
9
819.27* (部分)*
19.31**
11.0.0*(部分)12.011.0
属性 [[likely]][[unlikely]]P0479R591219.26*13.0.0*5.12021.720.712.0
使 typename 更可选P0634R391619.29 (16.10)*16.0.0*5.12023.120.712.0
lambda 初始化捕获中的包展开  (FTM)*P0780R29919.22*11.0.3*6.12021.720.1112.011.0
属性 [[no_unique_address]]P0840R29919.28 (16.9)**11.0.3*5.12021.120.712.011.0
条件性平凡的特殊成员函数  (FTM)*P0848R3101619.28 (16.8)*6.12021.720.1112.0
DR17:放松结构化绑定定制点查找规则P0961R18819.20*10.0.1*5.12021.120.712.011.0
DR11:放松范围 for 循环定制点查找规则P0962R18819.25*11.0.0*5.12021.120.712.011.0
DR17:允许到可访问成员的结构化绑定P0969R08819.20*10.0.1*5.12021.120.712.011.0
销毁的 operator delete  (FTM)*P0722R39619.27*10.0.0*6.12023.120.1112.011.0
常量模板形参中的类类型P0732R2912 (部分)19.26* (部分)*
19.28 (16.9)*
13.0.0* (部分)6.22023.1 (部分)21.312.0
弃用经由 [=] 隐式捕获 thisP0806R29719.22*10.0.1*5.120.712.011.0
explicit(bool)  (FTM)*P0892R29919.24*11.0.3*5.12021.120.712.011.0
集成功能特性测试宏P0941R253.419.15* (部分)
19.20*
5.02021.120.712.011.0
禁止有用户声明构造函数的聚合体P1008R19819.20*10.0.1*5.12021.120.712.011.0
constexpr 虚函数  (FTM)*P1064R09919.28 (16.9)*11.0.3*5.12021.120.712.011.0
比较的一致性改进P1120R0108 (部分)
10
19.22*12.0.0*5.12023.120.712.011.0
char8_t  (FTM)*P0482R69*19.22*10.0.0*5.12021.120.712.011.0
std::is_constant_evaluated()  (FTM)*P0595R29919.25*11.0.3*5.119.121.112.011.0
constexpr 函数中的 try-catchP1002R19819.25*10.0.1*5.12023.120.712.011.0
立即函数consteval)  (FTM)*P1073R310 (部分)*
11
11 (部分)
14 (部分)*
17
19.28 (16.8)*
(部分)*

19.29 (16.10)*
11.0.3* (部分)
15.0.0*
5.12021.120.712.0
嵌套内联命名空间P1094R29819.27*10.0.1*5.12021.120.712.011.0
有约束声明的另一种方式P1141R2101019.26* (部分)
19.28 (16.9)*
12.0.5*6.12023.120.1112.011.0
有符号整数为补码P1236R19911.0.3*不适用2023.1*是*12.011.0
常量表达式中的 dynamic_cast 及多态 typeidP1327R110919.28 (16.9)*11.0.3*5.12021.120.712.011.0
constexpr 内更改联合体的活跃成员  (FTM)*P1330R09919.10*11.0.3*5.12021.120.712.011.0
协程  (FTM)*  (FTM)*P0912R5
LWG3393
108 (部分)
17 (部分)*
19.0 (2015)* (部分)
19.10**
19.28 (16.8)*
10.0.1* (部分)5.12021.123.3*12.0 (host code only)
括号形式的聚合体初始化  (FTM)*P0960R3101619.28 (16.8)*16.0.0*5.12021.120.712.0
DR11:new 表达式中的数组大小推导P1009R211919.27*11.0.3*5.12021.120.712.011.0
模块  (FTM)*P1103R311 (部分)8 (部分)19.0 (2015)* (部分)
19.10**
19.28 (16.8)*
10.0.1* (部分)2023.1 (部分)
更强的 Unicode 要求P1041R4
P1139R2
1019.0 (2015)**
19.26**
不适用2023.1*12.011.0
<=> != ==P1185R2101019.22*12.0.0*5.12021.120.712.011.0
DR11:拥有不同异常说明的显式默认化函数P1286R210919.28 (16.8)*11.0.3*5.12021.120.712.011.0
结构化绑定的 lambda 捕获与存储类说明符P1091R3
P1381R1
108 (部分)
16
19.11**
19.24**
16.0.0*5.12021.120.712.0
容许转换到未知边界数组P0388R4101419.27*14.0.0*6.02021.520.1112.0
constexpr 容器操作  (FTM)*P0784R7101019.28 (16.9)*12.0.0*6.02021.520.1112.011.0
弃用 volatile 的某些用法P1152R4101019.27*12.0.0*6.02021.520.1112.011.0
constinit  (FTM)*P1143R2101019.29 (16.10)*12.0.0*6.12021.720.1112.011.0
弃用下标中的逗号运算符P1161R310919.25*11.0.3*6.02021.720.1112.011.0
带消息的 [[nodiscard]]P1301R410919.25*11.0.3*6.02021.520.1112.011.0
constexpr 函数中的平凡默认初始化P1331R2101019.27*12.0.0*6.12021.720.1112.011.0
constexpr 函数中的不求值 asm 声明P1668R1101019.28 (16.9)*12.0.0*6.12021.720.1112.011.0
using enum  (FTM)*P1099R5111319.24*13.1.6*6.32023.122.512.0
对指定的比较类别合成三路比较P1186R3111019.24*12.0.0*6.02021.520.1112.011.0
DR17:构造函数的 [[nodiscard]]P1771R110919.24*11.0.3*6.02021.520.1112.011.0
别名模板的类模板实参推导  (FTM)*P1814R0101919.27*6.523.912.0
聚合类的类模板实参推导  (FTM)*P1816R0
P2082R1
10*
11*
1719.27*6.32023.1 (部分)*
2024.1
23.312.0
DR11:更多局部对象与右值引用的隐式移动P1825R011*1319.24*13.1.6*6.02021.520.1112.0
允许默认化按值比较P1946R0101019.25*12.0.0*6.12021.720.1112.011.0
移除 std::weak_equalitystd::strong_equalityP1959R0101019.25*12.0.0*6.12021.720.1112.011.0
常量模板形参的不一致  (FTM)*P1907R110 (部分)
11
18 (部分)*19.26*13.1.6* (部分)6.22023.1 (部分)21.312.0
DR98:伪析构函数终结对象生存期P0593R6111112.0.5*不适用2023.1*12.011.0
DR11:应认为从 T*bool 的转换为窄化P1957R210*
11*
1119.27*12.0.5*6.112.011.0
 

C++20 功能特性
 

提案
GCC
Clang
MSVC
Apple Clang
EDG eccp
Intel C++
Nvidia HPC C++ (ex PGI)*
Nvidia nvcc
Cray

[编辑] C++20 库功能特性

C++20 功能特性

 
提案

 
GCC libstdc++
Clang libc++
MSVC STL
Apple Clang*
std::endian  (FTM)*P0463R18719.22*10.0.0*
扩展 std::make_shared() 以支持数组  (FTM)*P0674R1121519.27*14.0.3*
原子浮点数类型  (FTM)*P0020R6101819.22*16.0.0*
同步缓冲std::basic_osyncstream)  (FTM)*P0053R7111819.29 (16.10)*
<algorithm><utility>constexpr  (FTM)*P0202R3108 (部分)
12
19.26*10.0.1* (部分)
13.0.0*
<complex> 的更多 constexpr  (FTM)*P0415R197 (部分)
16
19.27*10.0.0* (部分)
15.0.0*
使 std::memory_order 为有作用域枚举P0439R09919.25*11.0.3*
字符串前缀后缀检查:string(_view) ::starts_with / ends_with  (FTM)*P0457R29619.21*10.0.0*
operator<=> 的库支持 <compare>  (FTM)*P0768R1107 (部分)
12 (部分)*
17
19.20* (部分)
19.28 (16.9)*
13.0.0*
std::remove_cvref  (FTM)*P0550R29619.20*10.0.0*
标准库中的 [[nodiscard]]P0600R197 (部分)
16
19.13* (部分)
19.22*
10.0.0* (部分)
15.0.0*
数值算法使用 std::moveP0616R091219.23*13.0.0*
转换指针为裸指针的工具  (FTM)*P0653R28619.22*
原子 std::shared_ptrstd::weak_ptr  (FTM)*P0718R21219.27*
std::span  (FTM)*P0122R710719.26*10.0.0*
日历时区  (FTM)*P0355R711 (部分)*
13 (部分)*
14
7 (部分)
19 (部分)*
19.29 (16.10)*10.0.0* (部分)
<version>P0754R29719.22*10.0.0*
比较无序容器P0809R016.0*
常量表达式迭代器 (ConstexprIterator) 要求  (FTM)*  (FTM)*P0858R091219.11*13.0.0*
std::basic_string::reserve() 不应收缩P0966R111819.25*10.0.1*
带填充位的原子比较交换P0528R31319.28 (16.8)*
std::atomic_ref  (FTM)*P0019R8101919.28 (16.8)*
关联容器的 contains() 成员函数,如 std::map::contains()P0458R291319.21*13.1.6*
DR11:逐片构造的受保证复制消除P0475R1919.29 (16.10)*
std::bit_cast()  (FTM)*P0476R2111419.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**
改进擦除式算法的返回值  (FTM)*P0646R191019.21*12.0.0*
std::destroying_delete_t  (FTM)*P0722R39919.27*11.0.3*
std::is_convertible  (FTM)*P0758R19919.23*11.0.3*
添加 std::shift_left/right<algorithm>  (FTM)*P0769R2101219.21*13.0.0*
std::swap()swap 相关函数的 constexprP0879R0101319.26*13.1.6*
std::type_identity  (FTM)*P0887R19819.21*10.0.1*
概念库  (FTM)*P0898R3101319.23*13.1.6*
std::arrayconstexpr 比较运算符P1023R010819.27*10.0.1*
std::unwrap_ref_decaystd::unwrap_reference  (FTM)*P0318R19819.21*10.0.1*
std::bind_front()  (FTM)*P0356R591319.25*13.1.6*
不完整类型的 std::reference_wrapperP0357R39819.26*10.0.1*
修正 operator>>(basic_istream&, CharT*)P0487R111819.23*10.0.1*
char8_t 的库支持  (FTM)*P0482R698 (部分)
16
19.22*10.0.1* (部分)
15.0.0*
实现使用分配器构造工具函数P0591R491619.29 (16.10)*15.0.0*
DR17:std::variantstd::optional 应传播复制/移动平凡性P0602R48.3819.11*10.0.1*
DR17:理智的 std::variant 转换构造函数P0608R310919.29 (16.10)**
19.42**
11.0.3*
std::function 的移动构造函数应为 noexceptP0771R17.2619.22*
唯一范围提案  (FTM)*P0896R41013 (部分)
15*
19.29 (16.10)*14.0.3*
无序关联容器的异质查找  (FTM)*P0919R3
P1690R1
111219.23**
19.25**
13.0.0*
<chrono> zero()min()max() 应为 noexceptP0972R09819.14*10.0.1*
std::pointer_traits 中的 constexpr  (FTM)*P1006R19819.26*10.0.1*
std::assume_aligned()  (FTM)*P1007R39*
11
1519.28 (16.9)*14.0.3*
使用默认初始化的智能指针创建(如 make_unique_for_overwrite)  (FTM)*P1020R1
P1973R1
11*
12*
1619.28 (16.9)*15.0.0*
杂项 constexpr 小部分  (FTM)*  (FTM)*  (FTM)*  (FTM)*  (FTM)*  (FTM)*P1032R1101319.28 (16.8)*13.1.6*
移除 std::span 的比较运算符P1085R210819.26*10.0.1*
使 operator+(basic_string) 的有状态分配器传播更加一致P1165R1101519.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**
标准库头文件单元P1502R11119.29 (16.10)*
polymorphic_allocator<> 作为词汇类型  (FTM)*P0339R691619.28 (16.9)*15.0.0*
std::execution::unseq  (FTM)*P1001R291719.28 (16.8)*
std::lerp()std::midpoint()  (FTM)*P0811R39919.23* (部分)
19.28 (16.8)*
11.0.3*
std::span 的实用性增强P1024R3109*
14
19.26*11.0.3*
DR17:使 std::create_directory() 自发P1164R18.31219.20*13.0.0*
std::ssize()std::span 的无符号长度  (FTM)*P1227R210919.25*11.0.3*
有界无界数组特征  (FTM)*P1357R19919.25*11.0.3*
std::to_array()  (FTM)*P0325R4101019.25*12.0.0*
std::basic_stringbuf 缓冲的有效访问P0408R7111719.29 (16.10)*15.0.0*
布局兼容性指针可互转换性特征  (FTM)*  (FTM)*P0466R51219.29 (16.10)**
位操作std::

rotl()rotr()countl_zero()countl_one()countr_zero()countr_one()popcount()  (FTM)*

P0553R49919.25**
19.28 (16.8)*
11.0.3*
数学常数  (FTM)*P0631R8101119.25*12.0.5*
文本格式化  (FTM)*P0645R101314**
17
19.29 (16.10)*15.0.0*
std::stop_tokenstd::jthread  (FTM)*P0660R101017 (部分)*
20*
19.28 (16.9)*
constexpr std::allocator 及相关工具  (FTM)*P0784R7101219.29 (16.10)*13.0.0*
constexpr std::string  (FTM)*P0426R1
P1032R1
P0980R1
121519.29 (16.10)*
19.30**
14.0.3*
constexpr std::vector  (FTM)*P1004R2121519.29 (16.10)*
19.30**
14.0.3*
输入范围适配器P1035R7101619.29 (16.10)*15.0.0*
constexpr std::invoke() 及相关工具P1065R2101219.28 (16.8)*13.0.0*
原子等待与提醒、std::counting_semaphorestd::latchstd::barrier  (FTM)*  (FTM)*  (FTM)*  (FTM)*  (FTM)*  (FTM)*P1135R6111119.28 (16.9)*13.1.6*
std::source_location  (FTM)*P1208R61115* (部分)
16
19.29 (16.10)*15.0.0*
添加 <=> 到标准库P1614R21014* (部分)
17* (部分)
19
19.29 (16.10)*13.1.6* (部分)
std::atomicstd::atomic_flagconstexpr 默认构造函数  (FTM)*P0883R2101319.26*13.1.6*
数值算法constexpr  (FTM)*P1645R1101219.26*13.0.0*
安全整数比较  (FTM)*P0586R2101319.27*13.1.6*
 

C++20 功能特性
 

提案
GCC libstdc++
Clang libc++
MSVC STL
Apple Clang*