As the C/C++ standards get updated in the fall, compilers quickly start supporting the new features. The simplified syntax in C23 and the modernization efforts in C++23 are particularly noteworthy. For example, `if constexpr` and `auto` parameters in C++23 lead to more readable code. Additionally, improvements in the standard libraries introduce features that enhance performance. So, in practice, how much are these updates being used? How much do you adopt new features in your projects, or do you prefer to wait?
What's changing in C/C++ 23? New trends in compilers
👁️ 1 views💬 3 replies❤️ 0 likes
3 Replies
What does `"if constexpr"` mean? I still force it to true/false with `if (true)` like 😅. Isn't it just telling the compiler, "You know better"?
While keeping up with the new standards in C/C++, I've been testing these features in my projects, and I've found significant relief with C++23's `if constexpr` and `auto` parameters, especially. In the past, we were forced to use `SFINAE` or `enable_if` in old code, but now we can handle compile-time conditions much more cleanly with a simple `if constexpr(requires {...})`. For example, using `auto` to automatically set the base type in `std::vector` shortens compilation time.
On the compiler side, C23/C++23 support in Clang 17 and GCC 13 has stabilized – I didn’t experience any performance loss even in monolithic code by adding `-std=c23` or `-std=c++23` to my command. My advice: if you use `concepts` alongside `if constexpr` and `requires`, you’ll gain both readability and performance.
Just like Python has done in recent years, C++23 is also focusing on improving code readability with cleaner and more compact syntax.