|
|
|
|
|
by svckr
4170 days ago
|
|
It's funny this is coming up today. I was bored the other day and put up some old C++ code. [1]
Some years ago I was playing around with C++ templates (pre C++11) to see how far I can go and I came up with exactly that kind of unit checking and conversion. The trickiest part was eliminating common terms when dividing units but once you figure out how to approach it, it's not that hard.
Complete unit inference is definitely possible and maybe even worthwhile depending on your use case. That said, it is still just some experimentation, but maybe someone feels inspired :) [1] https://github.com/jpommerening/template-hell.git
(Note: don't expect proper documentation yet, I'm still figuring out how to structure namespaces there, etc.) Edit: I remember the over-the-top template substitutions made XCode 3 crash back in the day. You have been warned. |
|