In languages with static and convenient type systems, I try to instead encode units as types. With clever C++ templating, you can even get implicit conversions (e.g. second -> hour) and compound types (e.g. meter and second types also generate m/s, m/s^2 and so on).
cgtjsiwy
joined 2 years ago
Similar problems (and more) have been solved long ago by libraries, because the issues aren't specific to music. More importantly, how does utf8 support count as a "horrible edge case" in 2022?
In C++23, you can zip the two arrays, so there's no need to declare an otherwise useless index variable:
Unfortunately, the current implementation of zip_transform in GCC doesn't understand that the output length is constant 8, so it does needless cmps every iteration to check if it should stop iterating. (Godbolt)