C++
Read post

Let the Compiler Check Your Units

A survey of C++ unit libraries that use the type system to enforce dimensional correctness at compile time with zero runtime overhead. Covers user-defined literals (UDLs) and their limitations, then compares four libraries: PhysUnits-CT-Cpp11, SI, Au, and mp-units. Au (C++14+) is highlighted as a practical, lightweight choice using arithmetic composition with unit constants, while mp-units (C++20+) is the most feature-complete and serves as the basis for the upcoming C++ standard proposal P3045, targeting C++29. Key concepts include dimensional analysis, quantity kinds (distinguishing semantically different quantities with the same dimension), QuantityPoint vs Quantity (mirroring chrono's time_point/duration), and safe implicit conversion rules. The article also previews the ongoing standardization effort to add physical units to the C++ standard library.

    #c++
May 22•21m read time•From accu.org
Post cover image
Table of contents
Type safety and user-defined literalsUnit libraries using UDLsUnit libraries without UDLsA standard unit library for C++29ReferencesFootnotes
171 Impressions
C++'s image
C++

ISO C++ is the official website for the C++ programming language standardization committee, providin...

571 Followers

•

493 Upvotes

Would you recommend this post?

Copy link
WhatsApp
Facebook
X
New Squad
  • © 2026 Daily Dev Ltd.
  • Guidelines
  • Explore
  • Tags
  • Sources
  • Squads
  • Leaderboard