January 6, 20251 yr Since its introduction, constexpr in C++ has evolved significantly, offering powerful ways to optimize code at compile-time. This article shares a real-world story of using constexpr to dramatically reduce memory usage and code size in an embedded system, showcasing its potential to improve both performance and efficiency. Write More C++ Code Thanks to constexpr by Andreas Fertig From the article: I'm a big fan ofâ¬Ã¡constexprâ¬Ã¡and am not alone.â¬Ã¡Jason Turnerâ¬Ã¡is also very vocal, having coined the term "constexpr all the things". Well, demonstrating the powers ofâ¬Ã¡constexprâ¬Ã¡is nonetheless something difficult. I know that from my training classes and various consulting contracts. Today, I'd like to share a story from back in time when a customer hired me to consult. They did develop an embedded system and ran out of memory. Not during run-time, but before. The features they wanted to put in the chip were too big in code size and somewhat RAM. Initialâ¬Ã¡constexpr-free example They used a class I've seen a couple of times in embedded systems with some variations. A string brings its memory picky-back. View the full article
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.