C++17
From cppreference.com
< cpp
This section is incomplete |
Following features were merged into C++17:
- From TS's: the filesystem library, the library fundamentals v1 (including optional, any, string_view, polymorphic allocators, searchers, apply), parallelism v1 (including execution policies, reduce, inclusive_scan, exclusive_scan), but removing
exception_list
. From special function IS: mathematical special functions, from library fundamentals v2: std::gcd, std::lcm - From C11: std::aligned_alloc, std::timespec_get
Obsolete
Removed
auto_ptr, deprecated function objects, std::random_shuffle, std::unexpected, the obsolete iostreams aliases, trigraphs, the register keyword, bool increment
Deprecated
std::iterator
,
std::raw_storage_iterator
,
std::get_temporary_buffer
,
std::is_literal_type
,
std::result_of
,
all of <codecvt>
New language features
- fold-expressions
- class template argument deduction
- auto non-type template parameters
- compile-time if constexpr
- inline variables
- structured bindings
- initializers for if and switch
- u8-char
- simplified nested namespaces
- using-declaration can declare multiple names
- made noexcept part of type system
- new order of evaluation rules
- guaranteed copy elision
- lambda capture of *this
- constexpr lambda
- attribute namespaces don't have to repeat
- new attributes
[[fallthrough]]
[[nodiscard]]
and[[maybe_unused]]
. - __has_include
New headers
New library features
In utility
In memory
- uninitialized memory tools
- weak_from_this
- polymorphic allocators
- aligned_alloc
- transparent owner_less
- array support for shared_ptr
- allocation functions with explicit alignment
- variadic lock_guard
- cache line interface
In types
- byte
- conjunction/disjunction/negation
- type trait variables xxx_v
- is_swappable
- is_invocable
- is_aggregate
- has_unique_object_representations.
In algorithm
- map/set extract and map/set merge
- map/unordered_map try_emplace and insert_or_assign
- contiguous iterators
- non-member size/empty/data
In numeric
Other
- is_always_lock_free
- uncaught_exceptions
- timespec_get
- rounding functions for duration and time_point
Defect reports
Compiler support
Main Article: C++ compiler support
C++17 core language features
C++17 feature |
Paper(s) |
GCC |
Clang |
MSVC |
Apple Clang |
EDG eccp |
Intel C++ |
IBM XLC++ |
Sun/Oracle C++ |
Embarcadero C++ Builder |
Cray |
Portland Group (PGI) |
Nvidia nvcc |
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
New auto rules for direct-list-initialization
|
N3922 | 5 | 3.8 | 19.0* | Yes | 4.10.1 | 17.0 | 10.3 | 17.7 | |||||
static_assert with no message | N3928 | 6 | 2.5 | 19.10* | Yes | 4.12 | 18.0 | 10.3 | 17.7 | |||||
typename in a template template parameter
|
N4051 | 5 | 3.5 | 19.0* | Yes | 4.10.1 | 17.0 | 10.3 | 17.7 | |||||
Removing trigraphs | N4086 | 5 | 3.5 | 16.0* | Yes | 5.0 | 10.3 | 19.1 | ||||||
Nested namespace definition | N4230 | 6 | 3.6 | 19.0* | Yes | 4.12 | 17.0 | 10.3 | 17.7 | |||||
Attributes for namespaces and enumerators | N4266 | 4.9 (partial)* 6 |
3.6 | 19.0* | Yes | 4.11 | 17.0 | 10.3 | 17.7 | |||||
u8 character literals
|
N4267 | 6 | 3.6 | 19.0* | Yes | 4.11 | 17.0 | 10.3 | 17.7 | |||||
Allow constant evaluation for all non-type template arguments | N4268 | 6 | 3.6 | 19.12* | Yes | 5.0 | 19.0.1 | 10.3 | 19.1 | |||||
Fold Expressions | N4295 | 6 | 3.6 | 19.12* | Yes | 4.14 | 19.0 | 10.3 | 18.1 | |||||
Unary fold expressions and empty parameter packs | P0036R0 | 6 | 3.9 | 19.12* | Yes | 4.14 | 10.3 | 19.1 | ||||||
Remove Deprecated Use of the register Keyword | P0001R1 | 7 | 3.8 | 19.11* | Yes | 4.13 | 18.0 | 10.3 | 17.7 | |||||
Remove Deprecated operator++(bool)
|
P0002R1 | 7 | 3.8 | 19.11* | Yes | 4.13 | 18.0 | 10.3 | 17.7 | |||||
Make exception specifications part of the type system | P0012R1 | 7 | 4 | 19.12* | Yes | 4.14 | 19.0 | 10.3 | 19.1 | |||||
Aggregate initialization of classes with base classes | P0017R1 | 7 | 3.9 | 19.14* | Yes | 5.0 | 19.0.1 | 10.3 | 19.1 | |||||
__has_include in preprocessor conditionals | P0061R1 | 5 | Yes | 19.11* | Yes | 4.13 | 18.0 | 10.3 | 17.7 | |||||
DR: New specification for inheriting constructors (DR1941 et al) | P0136R1 | 7 | 3.9 | 19.14* | Yes | 10.3 | 19.1 | |||||||
Lambda capture of *this
|
P0018R3 | 7 | 3.9 | 19.11* | Yes | 4.14 | 19.0 | 10.3 | 18.1 | |||||
Direct-list-initialization of enumerations | P0138R2 | 7 | 3.9 | 19.11* | Yes | 4.14 | 18.0 | 10.3 | 19.1 | |||||
constexpr lambda expressions | P0170R1 | 7 | 5 | 19.11* | Yes | 4.14 | 19.0 | 10.3 | 18.1 | |||||
Differing begin and end types in range-based for | P0184R0 | 6 | 3.9 | 19.10* | Yes | 4.12 | 18.0 | 10.3 | 17.7 | |||||
[[fallthrough]] attribute
|
P0188R1 | 7 | 3.9 | 19.10* | Yes | 4.13 | 18.0 | 10.3 | 17.7 | |||||
[[nodiscard]] attribute
|
P0189R1 | 7 | 3.9 | 19.11* | Yes | 4.13 | 18.0 | 10.3 | 17.7 | |||||
[[maybe_unused]] attribute
|
P0212R1 | 7 | 3.9 | 19.11* | Yes | 4.13 | 18.0 | 10.3 | 17.7 | |||||
Hexadecimal floating-point literals | P0245R1 | 3.0 | Yes | 19.11* | Yes | 4.13 | 18.0 | 10.3 | 17.7 | |||||
Using attribute namespaces without repetition | P0028R4 | 7 | 3.9 | 19.11* | Yes | 4.13 | 18.0 | 10.3 | 17.7 | |||||
Dynamic memory allocation for over-aligned data | P0035R4 | 7 | 4 | 19.12* |
10.0.0* |
4.14 | 19.0 | 10.3 | 19.1 | |||||
Class template argument deduction | P0091R3 | 7 | 5 | 19.14* | Yes | 5.0 | 19.0.1 | 10.3 | 19.1 | |||||
Non-type template parameters with auto type
|
P0127R2 | 7 | 4 | 19.14* | Yes | 5.0 | 19.0.1 | 10.3 | 19.1 | |||||
Guaranteed copy elision | P0135R1 | 7 | 4 | 19.13* | Yes | 5.0 | 19.0.1 | 10.3 | 19.1 | |||||
Replacement of class objects containing reference members | P0137R1 | 7 | 6 | 19.14* | Yes | 5.0 | 10.3 | 19.1 | ||||||
Stricter expression evaluation order | P0145R3 | 7 | 4 | 19.14* | Yes | 5.0 | 19.0.1 | 10.3 | 19.1 | |||||
Structured Bindings | P0217R3 | 7 | 4 | 19.11* | Yes | 4.14 | 19.0 | 10.3 | 18.1 | |||||
Ignore unknown attributes | P0283R2 | Yes | 3.9 | 19.11* | Yes | 4.13 | 18.0 | 10.3 | 17.7 | |||||
constexpr if statements | P0292R2 | 7 | 3.9 | 19.11* | Yes | 4.14 | 19.0 | 10.3 | 18.1 | |||||
init-statements for if and switch | P0305R1 | 7 | 3.9 | 19.11* | Yes | 4.14 | 18.0 | 10.3 | 18.1 | |||||
Inline variables | P0386R2 | 7 | 3.9 | 19.12* | Yes | 4.14 | 19.0 | 10.3 | 18.1 | |||||
Removing Deprecated Exception Specifications from C++17 | P0003R5 | 7 | 4 | 19.10* | Yes | 4.14 | 19.0 | 10.3 | 19.1 | |||||
Pack expansions in using-declarations | P0195R2 | 7 | 4 | 19.14* | Yes | 5.0 | 19.0 | 10.3 | 19.1 | |||||
DR: Matching of template template-arguments excludes compatible templates | P0522R0 | 7 | 4 | 19.12* | Yes | 5.0 | 19.0.1 | 10.3 | 19.1 | |||||
C++17 feature |
Paper(s) |
GCC |
Clang |
MSVC |
Apple Clang |
EDG eccp |
Intel C++ |
IBM XLC++ |
Sun/Oracle C++ |
Embarcadero C++ Builder |
Cray |
Portland Group (PGI) |
Nvidia nvcc |
C++17 library features
C++17 feature |
Paper(s) |
GCC libstdc++ |
Clang libc++ |
MSVC Standard Library |
Apple Clang |
Intel Parallel STL |
Sun/Oracle C++ Standard Library |
Embarcadero C++ Builder Standard Library |
Cray C++ Standard Library |
|
---|---|---|---|---|---|---|---|---|---|---|
std::void_t | N3911 | 6 | 3.6 | 19.0* | Yes | N/A | 10.3 | |||
std::uncaught_exceptions() | N4259 | 6 | 3.7 | 19.0* | Yes | N/A | ||||
std::size(), std::empty() and std::data() | N4280 | 6 | 3.6 | 19.0* | Yes | N/A | 10.3 | |||
Improving std::pair and std::tuple | N4387 | 6 | 4 | 19.0* | Yes | N/A | 10.3 | |||
std::bool_constant | N4389 | 6 | 3.7 | 19.0* | Yes | N/A | 10.3 | |||
std::shared_mutex (untimed) | N4508 | 6 | 3.7 | 19.0* | Yes | N/A | 10.3 | |||
Type traits variable templates | P0006R0 | 7 | 3.8 | 19.0* | Yes | N/A | 10.3 | |||
Logical operator type traits | P0013R1 | 6 | 3.8 | 19.0* | Yes | N/A | 10.3 | |||
Standardization of Parallelism TS | P0024R2 | 9* | 19.14* | 18.0* | ||||||
std::clamp() | P0025R0 | 7 | 3.9 | 19.0* |
10.0.0* |
N/A | 10.3 | |||
Hardware interference size | P0154R1 | 19.11* | N/A | |||||||
(nothrow-)swappable traits | P0185R1 | 7 | 3.9 | 19.0* |
10.0.0* |
N/A | 10.3 | |||
File system library | P0218R1 | 8 | 7 | 19.14* |
11.0.0* |
N/A | 10.3 | |||
std::string_view | N3921 P0220R1 |
7 | 4 | 19.10* |
10.0.0* |
N/A | 10.3 | |||
std::any | P0220R1 | 7 | 4 | 19.10* |
10.0.0* |
N/A | 10.3 | |||
std::optional | P0220R1 | 7 | 4 | 19.10* |
10.0.0* |
N/A | 10.3 | |||
Polymorphic memory resources | P0220R1 | 9 | 19.13* | N/A | 10.3 | |||||
Mathematical special functions | P0226R1 | 7 | 19.14* | N/A | 10.3 | |||||
C++17 should refer to C11 instead of C99 | P0063R3 | 9 | 7 | 19.0* (partial)* |
N/A | |||||
Splicing Maps and Sets | P0083R3 | 7 | 8 | 19.12* |
10.0.0* |
N/A | ||||
std::variant | P0088R3 | 7 | 4 | 19.10* |
10.0.0* |
N/A | 10.3 | |||
std::make_from_tuple() | P0209R2 | 7 | 3.9 | 19.10* | Yes | N/A | 10.3 | |||
std::has_unique_object_representations | P0258R2 | 7 | 6 | 19.11* | Yes | N/A | 10.3 | |||
std::gcd() and std::lcm() | P0295R0 | 7 | 4 | 19.11* | Yes | N/A | 10.3 | |||
std::not_fn | P0005R4 P0358R1 |
7 | 3.9 | 19.12* | Yes | N/A | 10.3 | |||
Elementary string conversions | P0067R5 | 8 (no FP) | 7 (no FP) | 19.14* (no FP)* 19.24* |
N/A | |||||
std::shared_ptr and std::weak_ptr with array support | P0414R2 | 7 | 19.12* | N/A | 10.3 | |||||
std::scoped_lock | P0156R2 | 7 | 5 | 19.11* | Yes | N/A | 10.3 | |||
std::byte | P0298R3 | 7 | 5 | 19.11* | Yes | N/A | 10.3 | |||
std::is_aggregate | LWG2911 | 7 | 5 | 19.15* | Yes | N/A | 10.3 | |||
C++17 feature |
Paper(s) |
GCC libstdc++ |
Clang libc++ |
MSVC Standard Library |
Apple Clang |
Intel Parallel STL |
Sun/Oracle C++ Standard Library |
Embarcadero C++ Builder Standard Library |
Cray C++ Standard Library |
* - hover over the version number to see notes