New C++23 standard released: what changed in the programming language
The C++ developer community has received a long-awaited update — the new C++23 standard (ISO/IEC 14882:2024) has been officially approved. Although work on it has been ongoing for several years, the final version brings a number of significant improvements that make the language even more powerful, secure, and convenient for modern projects. Let's break down the key innovations that every C++ developer should know.
Main innovations of C++23
Unlike the revolutionary C++11, the new standard can be called evolutionary. The main focus is on simplifying syntax, improving performance, and enhancing support for functional and modular programming.
- std::print and std::println — a long-awaited alternative to printf and cout. The new formatted output function works faster and safer, supporting all modern types. Example:
std::println("Hello, {}!", name); - Multidimensional subscript operator operator[] — now you can define syntax like
matrix[1, 2]without workarounds involving overloading operator(). This simplifies working with mathematical libraries and multidimensional containers. - std::expected — a new type for error handling without exceptions. It works like Result in Rust: it returns either a value or an error code. Ideal for low-level code and embedded systems.
- constexpr for std::vector and std::string — now containers can be used in compile-time computations. The compiler can create and process strings and vectors at compile time, speeding up execution.
- Improved Ranges — new adapters and algorithms have been added, such as
views::chunkandviews::slide. Working with sequences becomes even more declarative and readable. - Named arguments for lambda functions — now you can explicitly specify parameters in template lambdas:
[]. The code becomes clearer without unnecessary auto.(T a, T b) { ... }
Impact on everyday development
The new standard does not require rewriting existing projects, but provides tools for writing cleaner and faster code. Changes are especially noticeable in:
- Formatting utilities — std::print can completely replace the outdated printf in new projects.
- Error handling — std::expected simplifies writing reliable libraries without the risk of unhandled exceptions.
- Metaprogramming — constexpr containers open the way to more complex compile-time computations.
When and how to adopt
Support for C++23 is already implemented in the latest versions of GCC (14+), Clang (18+), and MSVC (2024+). To activate it, simply specify the flag -std=c++23 (or /std:c++latest in Visual Studio). We recommend starting to use the innovations in small modules or new projects, gradually adapting the code to the new capabilities.
C++23 is a step forward without breaking backward compatibility. The standard makes the language more accessible for beginners and even more performant for professionals. Be sure to explore it in practice — it's an investment in the quality of your code for years to come.