Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying C++ in Embedded Systems
  • Table Of Contents Toc
  • Feedback & Rating feedback
C++ in Embedded Systems

C++ in Embedded Systems

By : Amar Mahmutbegović
5 (4)
close
close
C++ in Embedded Systems

C++ in Embedded Systems

5 (4)
By: Amar Mahmutbegović

Overview of this book

Transitioning from C can be daunting, with concerns about performance overhead, added complexity, and unfamiliar tooling. Addressing these challenges, Amar Mahmutbegovic, an advocate for modern C++ in embedded development, shows you how to harness zero-cost abstractions, compile-time checks, and powerful modern C++ capabilities to preserve performance while achieving safer, cleaner code. This book bridges the gap between traditional C and advanced C++, helping you retain the efficiency C developers demand while unlocking the safety and expressiveness of modern C++. Starting with a modern development environment setup, including a Docker container for seamless example replication, you’ll overcome the hurdles of using the C++ standard library in memory-constrained settings and get acquainted with the Embedded Template Library (ETL) as an alternative. The book walks you through essential C++ concepts before exploring advanced topics such as templates, strong typing, error handling, compile-time computation, and RAII. Through practical examples, you'll implement a sequencer, write a type-safe HAL, and apply patterns like Command, State, and Observer to solve common embedded development problems. By the end of this book, you’ll have learned how to apply modern C++ to develop robust, modular firmware with performance matching or exceeding hand-coded C solutions.
Table of Contents (25 chapters)
close
close
Preface
Lock Free Chapter
1
Part I: Introduction to C++ in Embedded Development
6
Part II: C++ Fundamentals
10
Part III: C++ Advanced Concepts
15
Part IV: Applying C++ to Solving Embedded Domain Problems
23
Other Books You May Enjoy
24
Index

Building Generic and Reusable Code with Templates

We have used class templates in previous examples in this book without explaining them in detail. You should by now have a basic understanding of templates in C++ and know how to use template container classes from the standard library to specialize containers with different underlying types. We have also covered the std::optional and std::expected template classes, which we can use to handle different return types from functions.

As you have already seen, templates are used heavily in the C++ standard library. They allow us to implement the same functionality for different types, making our code reusable and generic, which is one of the strengths of C++. Templates are an extremely complex topic; entire books have been written on templates and metaprogramming in C++. This chapter will help you understand templates in C++ in more detail.

In this chapter, we’re going to cover the following main topics:

  • Template...
Visually different images
CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
C++ in Embedded Systems
notes
bookmark Notes and Bookmarks search Search in title playlist Add to playlist download Download options font-size Font size

Change the font size

margin-width Margin width

Change margin width

day-mode Day/Sepia/Night Modes

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY

Submit Your Feedback

Modal Close icon
Modal Close icon
Modal Close icon