4 ms·
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_mp
by tobinfricke 4y ago
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/ 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.