Language features:
Templates and Generic Code
Lambda
Attributes
Syntax cleanup
Cleaner multi-return and flow control
Misc
Hexadecimal float point literals
Dynamic memory allocation for over-aligned data
Guaranteed copy elision
- Finally!
- Not in all cases, but distinguishes syntax where you are "just creating something" that was called elision, from "genuine elision".
Fixed order-of-evaluation for (some) expressions with some modifications
- Not including function arguments, but function argument evaluation interleaving now banned
- Makes a bunch of broken code work mostly, and makes
.then
on future work.
Direct list-initialization of enums
Forward progress guarantees (FPG) (also, FPGs for parallel algorithms)
- I think this is saying "the implementation may not stall threads forever"?
u8'U', u8'T', u8'F', u8'8'
character literals (string already existed)
"noexcept" in the type system
__has_include
- Test if a header file include would be an error
- makes migrating from experimental to std almost seamless
Arrays of pointer conversion fixes
inherited constructors fixes to some corner cases (see P0136R0 for examples of behavior changes)
aggregate initialization with inheritance.
std::launder
, type punning, etc
Library additions:
Data types
Invoke stuff
std::invoke
- Call any callable (function pointer, function, member pointer) with one syntax. From the standard INVOKE concept.
std::apply
- Takes a function-like and a tuple, and unpacks the tuple into the call.
std::make_from_tuple
, std::apply
applied to object construction
is_invocable
, is_invocable_r
, invoke_result
Threading
Container Improvements
Smart pointer changes
Other std
datatype improvements:
Misc
C++17 library is based on C11 instead of C99
Reserved std[0-9]+
for future standard libraries
destroy(_at|_n)
, uninitialized_move(_n)
, uninitialized_value_construct(_n)
, uninitialized_default_construct(_n)
- utility code already in most
std
implementations exposed
Special math functions
std::clamp()
std::clamp( a, b, c ) == std::max( b, std::min( a, c ) )
roughly
gcd
and lcm
std::uncaught_exceptions
- Required if you want to only throw if safe from destructors
std::as_const
std::bool_constant
A whole bunch of _v
template variables
std::void_t<T>
- Surprisingly useful when writing templates
std::owner_less<void>
- like
std::less<void>
, but for smart pointers to sort based on contents
std::chrono
polish
std::conjunction
, std::disjunction
, std::negation
exposed
std::not_fn
Rules for noexcept within std
std::is_contiguous_layout, useful for efficient hashing
std::to_chars/std::from_chars, high performance, locale agnostic number conversion; finally a way to serialize/deserialize to human readable formats (JSON & co)
std::default_order, indirection over std::less
. (breaks ABI of some compilers due to name mangling, removed.)
memory_order_consume
, added language to prefer use of memory_order_acquire
Traits
Deprecated
Isocpp.org has has an independent list of changes since C++14; it has been partly pillaged.
Naturally TS work continues in parallel, so there are some TS that are not-quite-ripe that will have to wait for the next iteration. The target for the next iteration is C++20 as previously planned, not C++19 as some rumors implied. C++1O has been avoided.
Initial list taken from this reddit post and this reddit post, with links added via googling or from the above isocpp.org page.
Additional entries pillaged from SD-6 feature-test list.
clang's feature list and library feature list are next to be pillaged. This doesn't seem to be reliable, as it is C++1z, not C++17.
these slides had some features missing elsewhere.
While "what was removed" was not asked, here is a short list of a few things ((mostly?) previous deprecated) that are removed in C++17 from C++:
Removed:
There were rewordings. I am unsure if these have any impact on code, or if they are just cleanups in the standard:
Papers not yet integrated into above:
P0505R0 (constexpr chrono)
P0418R2 (atomic tweaks)
P0512R0 (template argument deduction tweaks)
P0490R0 (structured binding tweaks)
P0513R0 (changes to std::hash
)
P0502R0 (parallel exceptions)
P0509R1 (updating restrictions on exception handling)
P0012R1 (make exception specifications be part of the type system)
P0510R0 (restrictions on variants)
P0504R0 (tags for optional/variant/any)
P0497R0 (shared ptr tweaks)
P0508R0 (structured bindings node handles)
P0521R0 (shared pointer use count and unique changes?)
Spec changes:
Further reference: