C++20
From cppreference.com
< cpp
C++20 is a major version after C++17, featuring major features (concepts, modules, coroutines, and ranges) and other language and library features. The standard was published in December 2020.
| This section is incomplete |
Contents |
[edit] New language features
- Feature test macros
- Three-way comparison operator <=> and operator==() = default
- Designated initializers
- Init-statements and initializers in range-
for - char8_t
- New attributes:
[[no_unique_address]],[[likely]],[[unlikely]] - Pack-expansions in lambda init-captures
- Removed the requirement to use
typenameto disambiguate types in many contexts - consteval, constinit
- Further relaxed constexpr
- Signed integers are 2's complement
- Bitwise shift operators unified behavior
- aggregate initialization using parentheses
- coroutines
- modules
- Constraints and concepts
- Abbreviated function template
- DR11: array new can deduce array size
[edit] New library features
[edit] New headers
- <bit>
- <compare>
- <concepts>
- <coroutine>
- <format>
- <numbers>
- <ranges>
- <source_location>
- <span>
- <syncstream>
- <version>
[edit] Library features
- Library feature-test macros
- Formatting library
- Concepts library
- Calendar and Time zone library in <chrono>
- std::source_location
- std::span
- std::endian:
big/little/native - Integral power-of-2 operations and std::bit_cast in <bit>
- Array support for std::make_shared
- std::remove_cvref
- std::to_address
- Floating-point atomics, std::shared_ptr atomics
- Thread-coordination classes: std::barrier, std::latch, and std::counting_semaphore
- std::jthread and thread cancellation classes: std::stop_token, std::stop_source, and std::stop_callback
- std::basic_osyncstream
- std::basic_string and other char8_t uses
- constexpr for <algorithm>, <utility>, <complex>
- string::starts_with / ends_with and string_view::starts_with / ends_with
- std::assume_aligned
- std::bind_front
- std::c8rtomb / std::mbrtoc8
- std::make_obj_using_allocator etc
- std::make_shared_for_overwrite / std::make_unique_for_overwrite
- Heterogeneous lookup in unordered associative containers
- std::pmr::polymorphic_allocator with additional member functions and std::byte as its default template argument
- execution::unseq
- std::midpoint and std::lerp
- std::ssize
- std::is_bounded_array, std::is_unbounded_array
- Ranges
- Uniform container erasure: std::erase / std::erase_if, e.g. std::erase(std::list) or erase_if(std::map) etc
- Mathematical constants in <numbers>