c++17 · iso/iec 14882:2017

Второй по величине сдвиг после C++11The second-biggest shift after C++11

structured bindings, if constexpr, std::optional/variant/string_view, parallel algorithms, class template argument deduction — и десяток более мелких, но постоянно используемых улучшений. 18 фич, каждая — отдельная страница.structured bindings, if constexpr, std::optional/variant/string_view, parallel algorithms, class template argument deduction — plus a dozen smaller but constantly-used improvements. 18 features, each its own page.

Ядро языка — синтаксисCore language — syntax

меняют то, как выглядит кодchange what the code looks like

Убирают многословность и ручные обходные пути, накопившиеся за C++98–14.Remove verbosity and manual workarounds accumulated since C++98–14.

01

structured bindingsstructured bindings

Разбор tuple/pair/struct на именованные переменные одной строкой — конец std::tie и .first/.second.Unpacking a tuple/pair/struct into named variables in one line — the end of std::tie and .first/.second.

02

if/switch с инициализациейif/switch with initializer

Переменная, живущая только внутри условия и его веток — не утекает в окружающий скоуп.A variable that lives only inside the condition and its branches — doesn't leak into the surrounding scope.

03

if constexpr

Ветвление на этапе компиляции внутри шаблона — конец SFINAE-трюков ради простого выбора кода.Compile-time branching inside a template — the end of SFINAE tricks for a simple code choice.

04

inline-переменныеinline variables

static-член класса с определением прямо в заголовочном файле — без ODR-нарушений при подключении в несколько единиц трансляции.A static class member defined right in the header — no ODR violations when included in multiple translation units.

05

fold expressionsfold expressions

Свёртка parameter pack оператором в одно выражение — конец рекурсивных шаблонов ради суммы/конъюнкции.Folding a parameter pack with an operator into one expression — the end of recursive templates just to sum or AND things together.

06

вывод параметров шаблона класса (CTAD)class template argument deduction (CTAD)

std::pair(1, 2.0) вместо std::pair<int, double>(1, 2.0) — компилятор выводит параметры шаблона класса из конструктора.std::pair(1, 2.0) instead of std::pair<int, double>(1, 2.0) — the compiler deduces class template parameters from the constructor.

07

[[nodiscard]] / [[maybe_unused]] / [[fallthrough]]

Стандартизированные атрибуты вместо компиляторных расширений — компилятор предупреждает о конкретных классах ошибок.Standardized attributes instead of compiler extensions — the compiler warns about specific classes of mistakes.

08

гарантированное исключение копийguaranteed copy elision

Возврат prvalue из функции больше не требует move/copy-конструктора вообще — это часть формальной семантики языка, не оптимизация компилятора.Returning a prvalue from a function no longer requires a move/copy constructor at all — this is part of the language's formal semantics, not a compiler optimization.

Библиотека — типы общего назначенияLibrary — general-purpose types

многое ушло сюда из Library Fundamentals TSmuch of this arrived from the Library Fundamentals TS

Уже частично упомянуты в cpp_ts_extensions.md как фичи, доехавшие из экспериментального TS до стандарта.Already partly covered in cpp_ts_extensions.md as features that made it from the experimental TS into the standard.

Файловая система и параллелизмFilesystem and parallelism

две большие библиотечные добавкиtwo large library additions

Мелкие, но полезные добавкиSmall but useful additions

каждая закрывает конкретную узкую задачуeach closes one specific narrow task

порядок чтенияreading order

structured bindings и if/switch-init стоит читать первыми — они меняют повседневный стиль кода сильнее остальных и встречаются в примерах для более поздних фич этого же стандарта. if constexpr важен перед тем, как переходить на C++20 concepts — это его прямой предшественник в задаче "выбрать код на этапе компиляции".structured bindings and if/switch-init are worth reading first — they change everyday coding style more than the rest and show up in examples for later features of this same standard. if constexpr matters before moving on to C++20 concepts — it's the direct predecessor in the "pick code at compile time" problem.

std::optional/variant/any/string_view пересекаются с TS-контекстом из cpp_ts_extensions.md — стоит свериться при чтении, что там уже устарело после финализации в стандарте.std::optional/variant/any/string_view overlap with the TS context in cpp_ts_extensions.md — worth cross-checking what there became outdated once these were finalized into the standard.