skip to content

How do you decide whether a C++ codebase built by MSVC, GCC and Clang for three platforms should move from C++17 to C++20, and how do you roll it out?

level: principalimportance: should knowfreq 40%

answer

  1. oldest toolchain sets the ceiling
  2. per-feature support matrix
  3. value of the features you want
  4. dependencies rebuilt in one mode
  5. parallel CI job, then flip

basics

~20 s

The baseline is capped by the oldest compiler and standard library each platform must keep. Build a per-feature support matrix, weigh the features you want against migration cost and dependency rebuilds, then roll out with a parallel C++20 CI job before flipping.

solid answer

~40 s

Start from **constraints**: list every compiler and standard library release each platform must support — a console SDK, an LTS distribution, a customer's MSVC — because the oldest one caps the baseline. Then build a **per-feature matrix** for the C++20 features you actually want (concepts, `std::span`, designated initializers, `<=>`, ranges, `std::format`) from vendor status pages and a CI probe, not from the `-std` flag. Weigh **value** — clearer template errors, fewer hand-rolled utilities — against **cost**: the compatibility breaks, third-party code, and rebuilding every dependency in one mode. Decide what stays **off-limits** even after the switch, often modules and some library features. Roll out with a non-gating C++20 job on all three compilers, mode-neutral fixes, then flip the default with an allow-list of features and a date to revisit C++23.

go deeper

for a junior

Know that a team chooses one standard for the whole codebase and that the oldest compiler it supports limits that choice.

for a middle

Explain how to check feature support per toolchain and why a migration needs a parallel CI job and explicit -std settings.

for a senior

Show you can run the migration: the compatibility breaks, rebuilding dependencies in one mode, and an allow-list that matches what every toolchain really implements.

for a principal

Own the trade-off: the dominating constraint, the value of named features against migration and ABI risk, what stays forbidden, and the trigger for the next review.

## The decision is about toolchains, not the standard A team does not adopt "C++20"; it adopts the subset of C++20 that **every compiler and standard library in its build matrix** implements correctly. With MSVC on Windows, GCC on Linux and Clang on macOS, that is three compilers and three libraries — the MSVC STL, libstdc++ and libc++ — each with its own release cadence and its own gaps. The question "should we move to C++20?" therefore splits into four questions a lead has to answer. ## 1. What is the ceiling? Inventory every toolchain you must keep building with, and the **oldest** version of each: - platform SDKs pinned by a vendor or a console manufacturer; - the system compiler of the oldest Linux distribution you support; - the MSVC version your customers or plugin hosts use; - the standard library actually linked — Clang on Linux often uses the distribution's libstdc++, not libc++. The oldest entry caps what the baseline may use. Defaults are not a guide: GCC 16 documents `gnu++20` as its default, upstream Clang `gnu++17`, and Apple clang 21 still builds as C++14 when no flag is given. ## 2. Which features are really there? Build a **per-feature matrix** from the vendors' status pages and a CI probe that prints the relevant feature-test macros on every toolchain. Some entries will surprise you: | Feature | Typical finding | |---|---| | concepts, `<=>`, designated initializers, `std::span` | broadly available on current releases | | `std::format` | present, but feature-test values lag on some libraries | | `std::atomic<std::shared_ptr>`, calendars and time zones | listed as missing or partial in libc++ for LLVM 23 | | modules | GCC 16 still requires `-fmodules`; build-system support varies | The matrix decides the **allow-list**: what code may use after the switch, and what stays forbidden until the slowest toolchain catches up. ## 3. Is it worth it? The value side is concrete when you name it: - **concepts** replace `enable_if` and give readable template errors; - **`std::span`** and designated initializers simplify interfaces; - defaulted **`<=>`** and `==` remove boilerplate comparison code; - **`std::format`** and **ranges** retire in-house formatting and algorithm helpers. The cost side is the compatibility annex (new keywords, `char8_t` literals, the aggregate rule, reversed `==`, removed library names), third-party code that does not build in C++20 mode, and rebuilding every **prebuilt dependency** in the same mode — some library declarations change between modes, so mixed objects can fail to link. Factor in **ABI maturity** as well: libstdc++'s documentation records that GCC 9.1 was the first release with non-experimental C++17 support, so the ABI of C++17 features is stable only from there. A mode a vendor still calls experimental, as GCC 16 does for C++23, is a poor baseline for libraries you ship as binaries. ## 4. How do you roll it out? 1. **Pin the mode explicitly** on every target, so no build relies on a compiler default. 2. Add a **non-gating C++20 job** on all three compilers beside the C++17 job. 3. Fix breaks in code that compiles in **both modes**; clear deprecation warnings too. 4. Rebuild **all dependencies** in C++20 mode through the package manager and run the whole test suite, sanitizer builds included. 5. **Flip** the default, publish the allow-list, and delete the C++17 job. 6. Put a **date or trigger** on the next review — a toolchain upgrade, or C++23 support across the matrix — so the baseline does not freeze. ## The judgment calls There is no universally right answer. A game studio shipping to a console whose SDK lags may stay on C++17 for years and allow a few C++20 library types through polyfills. A service team owning its whole toolchain may move in a sprint. A library shipped as source to many users may keep a lower **public** baseline than it uses internally, guarding newer features with feature-test macros. Good answers name the constraint that dominates for *this* codebase and show the trade-off, rather than citing the newest standard as automatically better.

  • One platform's SDK compiler lacks a C++20 feature the other two have. What are your options?
    Keep it off the allow-list until the SDK catches up; use a small polyfill or third-party equivalent behind one wrapper header selected by a feature-test macro; or isolate the code that needs it in a component that does not build for that platform. The wrapper option works only when the interface is identical, so the fallback can be deleted cleanly later.
  • Why might a library keep a lower public standard than its own implementation uses?
    Its headers are compiled by consumers on their toolchains and modes. Requiring C++20 in public headers forces every user to C++20; keeping the headers C++17-compatible and using newer features only in source files lets users upgrade on their own schedule. The cost is a split codebase and stricter review of what headers may include.

A convoy moves at the speed of its slowest ship: a codebase built by three toolchains can use only what the oldest of them implements, however fast the newest one is.

  • Pick the newest standard the newest compiler supports.
  • If all three compilers accept -std=c++20, every C++20 feature can be used.
  • Dependencies can stay prebuilt in C++17 mode after the switch.
  • Modules should be adopted together with the C++20 baseline switch.
  • Once the baseline is raised, the decision never needs revisiting.

Assumes C++20 adoption decisions against GCC 16, LLVM 23 libc++ and current MSVC, with C++23 the latest published standard.