If you have read Function pointers, you may be wondering about how you might use function pointers to call the member functions of structs and classes. And you would be right to wonder. Regular function pointers will not work. What we need for this task is member function pointers, aka pointers to members functions. StrictlyContinue reading “Member function pointers”
Author Archives: unicyclebloke
Function pointers
Function pointers are a commonly used feature of both C and C++, though perhaps to a lesser extent in C++ because some of the use cases are obviated by other language features. They seem to be the cause of some confusion, especially among beginners, so I thought it might be useful to go through aContinue reading “Function pointers”
Traits for STM32 pin functions
This article presents another example of using trait templates to help us not shoot ourselves in the foot with invalid pin assignments. If this means nothing to you please take a look Traits templates 101. If it all looks spookily familiar, perhaps you already read Traits for wake-up pins. The comments below do present essentiallyContinue reading “Traits for STM32 pin functions”
Datasheets in databases
I focus on STM32 microprocessors in the discussion below, but the ideas could apply to any range of devices. Background I have spent a lot of time in recent years trawling through the datasheets, reference manuals and programming manuals for STM32 microprocessors. Mostly for STM32F4s, but also for STM32F0s. These documents are incredibly useful, andContinue reading “Datasheets in databases”
Traits for wake-up pins
This is a real example from an embedded project I’ve been working on. The goal was to convert a potential run time error into a compile time error. If you haven’t done so already, please take a look at Traits templates 101, which introduces some of the ideas discussed below. The scenario The device isContinue reading “Traits for wake-up pins”
Traits templates 101
If you are not familiar with them, traits in C++ are a simple method of using templates to associate custom information with specific data types (and/or with specific data values) at compile time. If you think for a moment about the built-in integral types: int, short, long, and so on, you already know that theseContinue reading “Traits templates 101”