C++20 最新進展:已完成設計加入模塊和協程
C++ 委員會於上週在夏威夷科納舉辦了一場官方ISO 會議,以確定下一個國際標準C++20 的功能集。根據會議報告,C++20 的功能設計現已完成。計劃於2019年7月在科隆舉行的會議上,完成 C++20 的規範並發送一份委員會草案以供審查。

上週會議確定添加至C++20 草案的新特性:
- Modules !
- Coroutines !
static
,thread_local
, and lambda capture for structured bindings .std::polymorphic_allocator<>
.std::midpoint
andstd::lerp
.std::execution::unseq
execution policy .std::ssize()
free function that returns a sized size .std::span
usability enhancements .- Precalculated hash values in lookup .
而以下的特性已在本次會議或之前的會議上獲得了C++20 批准,但尚未添加到C++20 中,因為目前仍在完成規範。它們有望在2019年7月的科隆會議上被加入,不過由於時間限制,可能無法完成所有工作。
- Expansion statements .
- The C++20 synchronization library .
std::format
.constexpr
std::vector
.- Allow
constexpr
allocation, but disallow allocations that are not deleted at compile time . constexpr
std::type_info::operator==
.- New conceptification of iterators .
- Monadic operations for
std::optional
. std::source_location
.std::flatmap
.std::flatset
.std::ostream_joiner
.- Stack trace library .
std::byteswap
.constinit
.- Deprecating some uses of
volatile
. - Implicit creation of objects for low-level object manipulation .
using enum
.
而下面的這些特性,早已在之前的會議上獲得了C++ 20 批准。
- Concepts .
- Contracts .
- Ranges .
operator<=>
.- A lot more
constexpr
features:consteval
functions ,std::is_constant_evaluated
,constexpr
union
,constexpr
try
andcatch
,constexpr
dynamic_cast
andtypeid
. - Feature test macros .
std::span
.- Synchronized output .
std::atomic_ref
.
總之,C++20 應該會是一個像C++11 那樣的大版本。
據透露,工具研究小組SG15決定創建一個C++ 生態系統技術報告,該報告將描述新模塊化C++世界中工具(構建系統等)的最佳實踐和最新技術。
參考:https://www.reddit.com/r/cpp/comments/au0c4x/201902_kona_iso_c_committee_trip_report_c20/