New Features in C 17
Following the completion of feature development for C 17, several new language features and library additions have been introduced:
Language Features:
Library Additions:
Data Types:
- std::variant for representing values of different types
- std::optional for representing optional values
- std::any for representing values of any type, including non-copyable types
- std::string_view for efficient handling of string references
- std::byte for representing data without type information
Callable Handling:
- std::invoke for generic callable invocation
- std::apply for tuple-based callable invocation
- std::make_from_tuple for constructing objects from tuples
- Introduction of is_invocable and related traits
File System Library:
- Implementation of the File System Technical Specification (TS)
New Algorithms:
- for_each_n, reduce, transform_reduce, and more
Threading Enhancements:
- Introduction of std::shared_mutex for more efficient multi-threaded access
- Atomic guarantees and hardware interference size detection
Library Fundamentals TS Additions:
- Searching algorithms (alg.search)
- Polymorphic allocator (pmr)
Container Improvements:
- try_emplace and insert_or_assign for efficient container insertion
- Splicing for maps, sets, and unordered containers
- Non-const data() access for strings
Smart Pointers:
- Fixes and tweaks to unique_ptr
- Introduction of weak_from_this for managing shared pointers
Misc:
- Use of C11 instead of C99 for the standard library
- Reserved std[0-9] namespaces for future standard libraries
- Various utility functions (destroy, uninitialized_***)
- Exposure of special math functions
- Introduction of std::clamp, std::gcd, and std::lcm
- Exception handling improvements, including std::uncaught_exceptions
- std::as_const, std::bool_constant, and various template utilities
- Improved std::chrono library
- Introduction of Boolean operators (std::conjunction, std::disjunction, std::negation)
- Rules for noexcept usage within std
Deprecated Features:
- Removal of some C libraries, , result_of, and others
The above is the detailed content of What are the Key Language and Library Features Introduced in C 17?. For more information, please follow other related articles on the PHP Chinese website!
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn