Hacker News new | past | comments | ask | show | jobs | submit login
Show HN: Au: A C++14-compatible units library, by Aurora (github.com/aurora-opensource)
27 points by chiphogg on Feb 8, 2023 | hide | past | favorite | 1 comment
Aurora's C++ units library called "Au" (rhymes with "hey you!") has been a small but critical tool in Aurora's software development toolbox. Today, we're sharing it with the world[1]: Au is now open source for all to use. Feel free to ask me any questions!

[1] https://blog.aurora.tech/engineering/introducing-au-our-open...




As a very simple example of what using this library could look like, here is a tiny code snippet taken from one of the tutorials:

    constexpr double speed_mph = 65.0;
    constexpr double speed_mps = (miles / hour)(speed_mph).in(meters / second);
In a larger program, of course, the whole point is to avoid using naked "doubles" (or floats or ints, etc) at all, and instead use the library's "Quantity" types, which encode information about their units. Conversions are done automatically, and incompatible operations become compile-time errors.

    const auto time = hours(1.0)
    const auto distance = miles(65.0)

    const auto average_speed = distance/time;
The tutorials are a nice way to be introduced to the library:

https://aurora-opensource.github.io/au/tutorial/

From a user's point of view (I am a physicist by training), I find the library wonderfully unobtrusive and "natural" to use.

Disclosure: I work at Aurora and helped with the effort to open-source this library.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: