c++20 · iso/iec 14882:2020
Concepts, ranges, coroutines, modules — четыре по-настоящему новые парадигмы в одном стандарте, плюс jthread/spaceship operator/std::format и ещё десяток изменений поменьше. 18 фич, каждая — отдельная страница.Concepts, ranges, coroutines, modules — four genuinely new paradigms in a single standard, plus jthread/the spaceship operator/std::format and a dozen smaller changes. 18 features, each its own page.
Concepts заменяют SFINAE-трюки читаемыми ограничениями на шаблоны; ranges строят вычисления над последовательностями как композицию, а не вложенные циклы.Concepts replace SFINAE tricks with readable constraints on templates; ranges build computations over sequences as composition instead of nested loops.
requires-выражения и ограничения шаблонных параметров — читаемая альтернатива SFINAE/enable_if.requires-expressions and template parameter constraints — a readable alternative to SFINAE/enable_if.
std::same_as, std::integral, std::invocable и другие готовые концепты в <concepts>.std::same_as, std::integral, std::invocable, and other ready-made concepts in <concepts>.
Ленивые, компонуемые преобразования последовательностей — v | filter(...) | transform(...) без промежуточных контейнеров.Lazy, composable sequence transformations — v | filter(...) | transform(...) with no intermediate containers.
std::ranges::sort(v) вместо sort(v.begin(), v.end()) — весь <algorithm> переписан под контейнеры напрямую.std::ranges::sort(v) instead of sort(v.begin(), v.end()) — all of <algorithm> rewritten to take containers directly.
co_await/co_yield/co_return — функции, приостанавливающие себя и возобновляющиеся позже, без ручных callback'ов.co_await/co_yield/co_return — functions that suspend themselves and resume later, without manual callbacks.
import вместо #include — конец повторного парсинга заголовков и утечки макросов между единицами трансляции.import instead of #include — the end of re-parsing headers and macro leakage between translation units.
Поток с автоматическим join() в деструкторе и встроенным механизмом кооперативной отмены.A thread with automatic join() in the destructor and a built-in cooperative-cancellation mechanism.
Готовые примитивы синхронизации "N потоков должны собраться в точке" — без ручной condition_variable+счётчик.Ready-made "N threads must rendezvous" synchronization primitives — no hand-rolled condition_variable+counter.
Один оператор вместо шести — компилятор выводит <, <=, >, >= из одного определения.One operator instead of six — the compiler derives <, <=, >, >= from a single definition.
Point{.x = 1, .y = 2} — инициализация структуры по именам полей, без слепого позиционного порядка.Point{.x = 1, .y = 2} — struct initialization by field name, no blind positional order.
consteval требует вычисления на этапе компиляции всегда; constinit гарантирует статическую инициализацию без static init order fiasco.consteval always requires compile-time evaluation; constinit guarantees static initialization, avoiding the static init order fiasco.
[]<class T>(T x){...} — явный шаблонный параметр лямбды вместо auto-параметров C++14.[]<class T>(T x){...} — an explicit lambda template parameter instead of C++14's auto parameters.
Отдельный тип для UTF-8 code unit — разводит "байт памяти" и "unicode-текст" в системе типов.A dedicated type for a UTF-8 code unit — separates "memory byte" from "unicode text" in the type system.
Стандартизированная подсказка компилятору о вероятной ветке — вместо __builtin_expect.A standardized hint to the compiler about the likely branch — replacing __builtin_expect.
Типобезопасное форматирование строк в стиле Python — конец printf-спецификаторов и iostream-манипуляторов.Python-style type-safe string formatting — the end of printf specifiers and iostream manipulators.
Невладеющее представление непрерывного диапазона — string_view, но для любого типа элемента, не только char.A non-owning view over a contiguous range — string_view, but for any element type, not just char.
Даты, месяцы, часовые пояса как часть <chrono> — конец сторонних библиотек вроде date/tz.Dates, months, time zones as part of <chrono> — the end of third-party libraries like date/tz.
Файл/строка/функция вызывающего кода без макросов __FILE__/__LINE__ — типобезопасно, работает через default-параметр.Caller file/line/function without __FILE__/__LINE__ macros — type-safe, works via a default parameter.
порядок чтенияreading order
concepts стоит читать первыми — они используются как строительный блок в определении ranges (constraint на итераторы и view) и в примерах template lambdas. ranges-basics — до ranges-algorithms, views вводят словарь, на котором объясняются алгоритмы.Read concepts first — they're used as a building block in the definition of ranges (constraints on iterators and views) and in the template-lambda examples. Read ranges-basics before ranges-algorithms — views introduce the vocabulary the algorithms are explained with.
jthread/stop_token и barrier/latch/semaphore пересекаются с существующим разбором в cpp_concurrency.md — сверяться при чтении. coroutines — самая тяжёлая по объёму фича этого стандарта, готовься читать её не за один присест.jthread/stop_token and barrier/latch/semaphore overlap with the existing coverage in cpp_concurrency.md — cross-check while reading. coroutines is the heaviest single feature in this standard by volume — expect to read it over more than one sitting.