Skip to content

Latest commit

 

History

History
74 lines (68 loc) · 2.61 KB

C++20.md

File metadata and controls

74 lines (68 loc) · 2.61 KB

C++20语言新特性

  • 特性测试宏
  • 三路比较运算符<=>operator==() = default
  • 指派初始化器
  • 范围for中的初始化语句和初始化器
  • char8_t
  • [[no_unique_address]]
  • [[likely]]
  • [[unlikely]]
  • lambda初始化捕获中的包展开
  • 移除多种上下文中,使用typename关键字消除歧义的要求
  • consteval、constinit
  • 更为宽松的constexpr要求
  • 规定有符号整数以补码实现
  • 使用圆括号的聚合初始化
  • 协程
  • 模块
  • 约束与概念
  • 缩略函数模板X
  • DR:数组new可以推导数组长度

C++20新头文件

线程支持库中:

C++20标准库新特性

  • 库特性测试宏
  • 格式化库
  • 日历和时区库
  • std::source_location
  • std::span
  • std::endian
  • 针对数组的 std::make_shared 支持
  • std::remove_cvref
  • std::to_address
  • 浮点类型和 shared_ptr 的原子对象
  • std::barrier 、 std::latch 和 std::counting_semaphore
  • std::jthread 和线程取消类
  • std::osyncstream
  • std::u8string 和其他 char8_t 的使用
  • <algorithm> 、 <utility> 、 <complex> 中设施的 constexpr 化
  • std::string::starts_with / ends_with 与 std::string_view::starts_with / - ends_with
  • assume_aligned
  • bind_front
  • c8rtomb/mbrtoc8
  • make_obj_using_allocator 等
  • std::make_shared_for_overwrite/std::make_unique_for_overwrite
  • 无序关联容器中的异质查找
  • std::polymoprhic_allocator 的额外成员函数和 std::byte 作为其默认模板实参
  • std::execution::unseq
  • std::midpoint 和 std::lerp
  • std::ssize
  • std::is_bounded_array
  • 范围
  • 统一容器擦除 (std::erase/std::erase_if)
  • 数学常数