Hacker News new | ask | show | jobs
by thalur 5408 days ago
If you are using C++, you can make the units (dimensionality) compile-time checked using templates. See: http://learningcppisfun.blogspot.com/2007/01/units-and-dimen... (that isn't where I came across it, but the code looks basically the same.) It's easy to add more dimensions for any units you care about (pixels for example).
1 comments

Thanks, that looks very interesting! I wish I would have used this years ago, but (un)fortunately I switched over to Python (and some C for extensions).