Английская Википедия:C++17
Шаблон:Short description Шаблон:Distinguish Шаблон:Multiple issues Шаблон:C++ language revisions C++17 is a version of the ISO/IEC 14882 standard for the C++ programming language. C++17 replaced the prior version of the C++ standard, called C++14, and was later replaced by C++20.
History
Before the C++ Standards Committee fixed a 3-year release cycle, C++17's release date was uncertain. In that time period, the C++17 revision was also called C++1z, following C++0x or C++1x for C++11 and C++1y for C++14. The C++17 specification reached the Draft International Standard (DIS) stage in March 2017.[1][2] This DIS was unanimously approved, with only editorial comments,[3] and the final standard was published in December 2017.[4] Few changes were made to the C++ Standard Template Library, although some algorithms in the <algorithm>
header were given support for explicit parallelization and some syntactic enhancements were made.
New features
C++17 introduced many new features. The following lists may be incomplete.
Language
- Making the text message for Шаблон:Code optional[5]
- Allow Шаблон:Code (as an alternative to Шаблон:Code) in a template template parameter[6]
- New rules for [[Type inference|Шаблон:Code]] deduction from braced-init-list[7][8]
- Nested namespace definitions, e.g., Шаблон:Code instead of Шаблон:Code[8][9]
- Allowing attributes for namespaces and enumerators[10][11]
- New standard attributes Шаблон:Code, Шаблон:Code and Шаблон:Code[12]
- UTF-8 (Шаблон:Code) character literals[10][13] (UTF-8 string literals have existed since C++11; C++17 adds the corresponding character literals for consistency, though as they are restricted to a single byte they can only store "Basic Latin" and C0 control codes, i.e. ASCII)
- Hexadecimal floating-point literals[14][15]
- Use of Шаблон:Code as the type for a non-type template parameter[16]
- Constant evaluation for all non-type template arguments[10][17]
- Fold expressions, for variadic templates[10][18]
- A compile-time static Шаблон:Code with the form Шаблон:Code[19]
- Structured binding declarations, allowing Шаблон:Code[20]
- Initializers in Шаблон:Code and Шаблон:Code statements[21]
- copy-initialization and direct-initialization of objects of type Шаблон:Code from prvalue expressions of type Шаблон:Code (ignoring top-level cv-qualifiers) shall result in no copy or move constructors from the prvalue expression. See copy elision for more information.
- Some extensions on over-aligned memory allocation[22]
- Class template argument deduction (CTAD), introducing constructor deduction guides, e.g. allowing Шаблон:Code instead of requiring explicit constructor arguments types Шаблон:Code or an additional helper template function Шаблон:Code.[23][24]
- Inline variables, which allows the definition of variables in header files without violating the one definition rule. The rules are effectively the same as inline functions
- Шаблон:Code, allowing the availability of a header to be checked by preprocessor directives[25]
- Value of Шаблон:Code changed to Шаблон:Code[26]
- Exception specifications were made part of the function type[27]
- Lambda expressions can capture "*this" by value[28]
Library
- Most of Library Fundamentals TS I, including:[29][30]
std::string_view
, a read-only non-owning reference to a character sequence or string-slice[31]std::optional
, for representing optional objects, a data type that may not always be returned by a given algorithm with support for non-returnstd::any
, for holding single values of any type
std::uncaught_exceptions
, as a replacement ofstd::uncaught_exception
in exception handling[32][10]- New insertion functions
try_emplace
andinsert_or_assign
forstd::map
andstd::unordered_map
key-value associative data structures[33][34] - Uniform container access:
std::size
,std::empty
andstd::data
[34][35] - Definition of "contiguous iterators"[34][36]
- A file system library based on
boost::filesystem
[37] - Parallel versions of STL algorithms[38]
- Additional mathematical special functions, including elliptic integrals and Bessel functions[39]
std::variant
, a tagged union container[40]std::byte
, allowing char to be replaced for data types intending to model a byte of data as a byte rather than a character[41]- Logical operator traits:
std::conjunction
,std::disjunction
andstd::negation
[42] <memory_resource>
header, for polymorphic memory resources[43]
Removed features
This revision of C++ not only added new features but also removed a few.
- Trigraphs were removed.[44][45]
- Some deprecated types and functions were removed from the standard library, including
std::auto_ptr
,std::random_shuffle
, and old function adaptors.[8][46] These were superseded in C++11 by improved facilities such asstd::unique_ptr
,std::shuffle
,std::bind
, and lambdas. - The (formerly deprecated) use of the keyword Шаблон:Code as a storage class specifier was removed.[47] This keyword is still reserved but now unused.
Compiler support
- GCC has had complete support for C++17 language features since version 8.[48]
- Clang 5 and later supports all C++17 language features.[49]
- Visual Studio 2017 15.8 (MSVC 19.15) and later supports all C++17 language features.[50][51]
Library support
- libstdc++ since version 9.1 has complete support for C++17 (8.1 without Parallelism TS and referring to C99 instead of C11) [52]
- libc++ as of version 9 has partial support for C++17, with the remainder "in progress" [53]
- Visual Studio 2017 15.8 (MSVC 19.15) Standard Library and later supports all C++17 library features except for "Elementary String Conversions" and referring to C99 instead of C11. "Elementary String Conversions" is added in Visual Studio 2019 16.4[54]
See also
References
Шаблон:C++ProLang Шаблон:ISO standards
- ↑ Шаблон:Cite web
- ↑ Шаблон:Cite web
- ↑ Шаблон:Cite web
- ↑ Шаблон:Cite web
- ↑ Шаблон:Cite web
- ↑ Шаблон:Cite web
- ↑ Шаблон:Cite web
- ↑ 8,0 8,1 8,2 Шаблон:Cite web
- ↑ Шаблон:Cite web
- ↑ 10,0 10,1 10,2 10,3 10,4 Шаблон:Cite web
- ↑ Шаблон:Cite web
- ↑ Шаблон:Cite web
- ↑ Шаблон:Cite web
- ↑ Шаблон:Cite web
- ↑ Шаблон:Cite web
- ↑ Шаблон:Cite web
- ↑ Шаблон:Cite web
- ↑ Шаблон:Cite web
- ↑ Шаблон:Cite web
- ↑ Шаблон:Cite web
- ↑ Шаблон:Cite web
- ↑ Шаблон:Cite web
- ↑ Шаблон:Cite web
- ↑ Шаблон:Cite web
- ↑ Шаблон:Cite web
- ↑ Шаблон:Cite web
- ↑ Шаблон:Cite web
- ↑ Шаблон:Cite web
- ↑ Шаблон:Cite web
- ↑ Шаблон:Cite web
- ↑ Шаблон:Cite web
- ↑ Шаблон:Cite web
- ↑ Шаблон:Cite web
- ↑ 34,0 34,1 34,2 Шаблон:Cite web
- ↑ Шаблон:Cite web
- ↑ Шаблон:Cite web
- ↑ Шаблон:Cite web
- ↑ Шаблон:Cite web
- ↑ Шаблон:Cite web
- ↑ Шаблон:Cite web
- ↑ Шаблон:Cite web
- ↑ Шаблон:Cite web
- ↑ Шаблон:Cite web
- ↑ Шаблон:Cite web
- ↑ IBM comment on preparing for a Trigraph-adverse future in C++17 Шаблон:Webarchive, IBM paper N4210, 2014-10-10. Authors: Michael Wong, Hubert Tong, Rajan Bhakta, Derek Inglis
- ↑ Шаблон:Cite web
- ↑ Шаблон:Cite web
- ↑ Шаблон:Cite web
- ↑ Шаблон:Cite web
- ↑ Шаблон:Cite web
- ↑ Шаблон:Cite web
- ↑ Шаблон:Cite web
- ↑ Шаблон:Cite web
- ↑ Шаблон:Cite web