Modern C++ and embedded programming

I am wondering how many of the modern (C++11 and later) features would you consider usable for embedded programming.

The majority of the code I have seen so far can be written as plain C. I rarely see use of smart pointers, lambdas, templates and standard libraries. Even some of the classic features such as dynamic allocation and inheritance are almost never used.

I have found the C++ as C approach usually works as long as the main module is no longer than 500 lines. After that it becomes quite hard to determine the logic. This is especially true when reading code that implements state machines.

I guess at my main question is a what point would you consider using abstraction (even as simple as namespaces and classes) in your embedded code? Is there any case where you would use any modern C++ features?


Check out:

and the reddit discussion of it:

Bjarne Stroustrup was quite conscious of the overhead associated with various features and made quite an effort to insure that you don’t have to ‘pay’ for advanced features you don’t use.

1 Like