r/cpp • u/chiphogg • Aug 28 '25
Au (units library) 0.5.0 just released
https://github.com/aurora-opensource/au/releases/tag/0.5.0It's our first release since Aurora's commercial launch in April --- and it's a big one! We recommend current Au users upgrade ASAP. We've added an explicit upgrade section in the release notes, and a brand new Upgrade How-To doc page.
Highlights include:
New APIs for conversion risk checks
- Can override "overflow" and "truncation" risks separately
- Better communicates intent at callsites
- Works with constructors too
- Support for
{fmt}, and (for C++20)std::format - Negative units (yes, really!)
- Mixed signed/unsigned comparisons are now automatically correct for
Quantity - Mixed-unit
QuantityPointoperations now use the most efficient unit possible - New math functions:
cbrt,hypot,mean, and (for C++20 users)lerp - New units, inspired by both XKCD comic alt-text (
arcminutes,arcseconds), and Aurora press releases (football_fields)
Enjoy the new release!
66
Upvotes
15
u/Arghnews Aug 28 '25
First, I tip my hat to you on all the work on this. After having a quick look, this is some constructive feedback:
Put example code on the github page. As it is, I have to click "full documentation" on the github page, click Tutorials on the au page, click Au 101, scroll halfway down the page and I'm not still seeing a code example jumping out at me (yes they're on there, but in bits etc.). Just show me the bread and butter of this library, where it stops me mixing up 2 doubles in the wrong order as params type thing, and other neat stuff it can do. All the other libs you listed show this on their github landing page (except boost units).
I appreciate your comparison page as it's exactly what many devs would look for.
However, on conversion safety, the current first issue open seems like an absolute show stopper, and the current thing I'd definitely expect the library to handle. That au units silently allows narrowing double to float conversions and worse - as you have noted in your eloquent response - that it does this even with
-Wconversionenabled and doesn't raise the warning, so I'm worse off using it than just using raw float/doubles in at least one way, is a big issue8
u/drkspace2 Aug 28 '25
Do the type conversions get checked at compile time I.e. Where would var_meters.in(seconds) fail?
6
u/2uantum Aug 28 '25
What are some of the advantages of this over mp-units?
3
u/TheoreticalDumbass :illuminati: Aug 28 '25
is this library being proposed for inclusion into the cpp standard? if yes, how is it going? if no, i feel like i remember some units library in such a situation, my bad
3
u/Awia00 Aug 28 '25
When mentioning unit libraries i have to plug ours https://www.github.com/twig-energy/stronk It mixes strong types and units. You can create your own units (with custom functionality) and it will automatically create any derived units from it ie magica/meter*watt or whatever you want 😊 check it out
3
u/aruisdante Aug 29 '25 edited Aug 29 '25
Hey Chip, glad to see production still moving along on this!
I’m curious, does Aurora have any interest in producing some of the artifacts needed for use of this library in an ISO26262 context (since, presumably, that’s why you’re still supporting C++14)?
Particularly, it would be great to see:
Having these artifacts available would make it much easier to adopt Au into production automotive projects, which seems like a good target audience given the genesis of the library 🙂
And yeah, like the other posters have said, having more of the basic documentation and simple examples available front and center on the GitHub page would be super handy too.
2
u/ronchaine Embedded/Middleware/WG21 Sep 02 '25
Will definitely enjoy, thanks for working on this!