mp-units icon indicating copy to clipboard operation
mp-units copied to clipboard

feat!: add number concepts

Open JohelEGP opened this issue 9 months ago • 36 comments

Resolves #29.


The number concepts are meant to be at a lower level than the units' library. This means that quantity can use it to constrain rep, and quantity itself can model vector_space. So number_one_v would supersede quantity_values::one(), and same for zero.


https://github.com/BobSteagall/wg21/ doesn't work because it doesn't provide compound assignments. https://github.com/mpusz/mp-units/blob/a356db749ef8651d6b8c48cf732673286a0faa39/test/unit_test/runtime/linear_algebra_test.cpp#L97 v + v is valid and the same type as v. But the equivalent for lvalues, v += v, isn't provided to mean the same thing.


There's still room for more integration. That would involve breaking up mp_units's specific concepts that couple checks on the reference and the representation: https://github.com/mpusz/mp-units/blob/a356db749ef8651d6b8c48cf732673286a0faa39/src/core/include/mp-units/quantity.h#L60-L67 Because concepts can't be generically composed (i.e., passed to a concept template parameter), interfaces would have to check the reference and representation separately.

JohelEGP avatar Sep 21 '23 19:09 JohelEGP