Readable

last modified: October 23, 2025

Units of Measurements for Safe C++ Variables

Posted on 2019-07-11— C++, Improve your Code, Learn

I show how I avoid unit mistakes in C++ by creating a templated Duration type and user-defined literals like 100_ms. I explain declaring Seconds/Milliseconds/Nanoseconds, adding conversions, and how the compiler catches unit mismatches with no runtime cost. Read the full article for code examples and the GitHub repo.

Read this post

Make your Code Safe and Readable with Flags

Posted on 2018-05-06— C++, Improve your Code

I show how a small C++ flags template makes embedded register bitmasks safer and much easier to read. I'll explain why macros and CMSIS-style definitions lead to errors, and walk through clear C++11 examples and a simple driver. Read on to see the implementation and usage.

Read this post