Skip to content

ADR-0010: C++20 in every repository

  • Status: Accepted
  • Date: 2026-11-03

Context

Part of the code the standard was built from was C++17 and the rest C++20. The standard relies on C++20: requires expressions for optional port hooks, concepts for port constraints, std::span for caller buffers, designated initialisers for configs. ESP-IDF 5.x and current STM32 toolchains support C++20.

Decision

Every repository builds as C++20 (target_compile_features(<target> PUBLIC cxx_std_20), Standard: c++20 in .clang-format). Public headers may use any C++20 language feature the pinned ESP-IDF GCC and the CI clang both support; library features are limited to the freestanding-friendly headers listed in layers.md.

The C++20 profile (2026-11-08) narrows "any C++20 language feature" to the features it marks Use or Use with rules, each under its KB-CPP20 guidelines, and requires a strict-dialect build with every target compiler. It is also the scope of deviation MD-CPP-001.

Consequences

  • One feature set for every repository; void_t detection and SFINAE tricks are replaced by requires.
  • Users of a driver need a C++20 compiler.
  • C++17 code moves up when it is brought in, which is compatible for callers already on C++20.