I work in large C++ codebase for a suite of physics simulation software, and there are like 200 something strongly typed arithmetic units here.

Anything with a finite (200 is small even) number of units misses the algebraic structure of the problem mentioned in https://news.ycombinator.com/item?id=36988497 wherein multiplying|dividing two things gives you a (potentially) new unit which implies an open ended "space" of units.

To be concrete (hah!), in C++ a template meta-type with 12 signed integer parameters (6 numerators & 6 denominators for rational exponents of SI base units) might be one way to model it.

Unlike C++ template stuff, Nim macros (like Lisp macros) makes metaprogramming more like procedural programming - just against abstract syntax trees. I think that helps to shield some of this type complexity from users, but the documentation README https://github.com/SciNim/Unchained does better job than I can in an HN comment.

Of course, for unit system conversion, the number of dimensions (6 in SI, 3 in CGS/Gaussian) changes. So, for full generality you need compile-time (if you want static type integration/CT errors) linear algebra over a rational field (at least & conventionally) to project|inverse project. That might be theoretically possible in C++. I would think it very un-fun and unlikely to ever have been done. There's probably a Mathematica package, though.

EDIT: It seems that mp-units mentioned in a sibling comment has some rare support for varying unit systems (no GR or Planck ones, but at least "natural" & "hep" & not sure about system-conversion or just system-use). That lib also leans very heavily on many very modern C++ (C++20 & beyond) features, has constexpr everywhere in use cases. I am not sure I would say it shields users wonderfully or makes it seem like units are very ordinary types. Just looking at mp-units/example/VARIOUS.cpp makes it look syntactically very noisy, verbose, and a lot to learn.