Open Guillaume227 opened 1 year ago
Wait, it seems I was missing some significant updates to v3.x, for example the _t suffix is gone entirely now. I need to review and update what I said above.
Ok after a bit of renaming I managed to make almost everything work on 3.x - I updated all the PRs above, they should be good for review/feedback.
The one thing that's not working for me in 3.x as it used to on 2.3 is to_string for on-the-fly units, e.g. :
to_string(1_A * 1_A);
It used to print:
1 A^2
but now I am getting a compilation error.
Not a bit deal for me at the moment, I might look into that at a later stage unless someone has a better understand of what's going on here.
I also opened #318 and #317, they are self-explanatory
Overall things feel much cleaner in 3.x, Thanks. Straightening up the ADL story makes a big difference.
Regarding testing, my use case makes use of float
underlying_type which makes me notice how current tests cover double
underlying_type. I am not sure how to extend that without a lot of code duplication. Something like templating the test cases on underlying type?
I have been attempting to convert a codebase using version 2 to the 3.x branch and here is some feedback and questions. I embarked on this upgrade because I grew tired of the inconsistent
to_string
vsstream
behavior for units like volt_t. My initial, naive, expectation was a drop-in replacement with no change needed in the rest of the code base.Here is what happened in the hope that's useful for people going through an update. I am planning to send a few PRs as follow-up.
Most of the issues stemmed from using a
float
underlying type - all of the unit testing is done fordouble
.constexpr namespaceName::nameSingular##t operator"" ##abbreviation(long double d) noexcept \
{ \
return namespaceName::nameSingular##_t(static_cast(d)); \
}
degree_t val1 = 10_deg; degree_t val2 = 90_deg; degree_t new_val = some_bool ? val1 - val2 : val2;