mpusz / mp-units

The quantities and units library for C++
https://mpusz.github.io/mp-units/
MIT License
994 stars 79 forks source link

Consider using two types instead of values for the template parameters of the `reference` type #533

Closed mpusz closed 4 months ago

mpusz commented 6 months ago

Initially, I thought that the user would need to provide the template parameters to reference explicitly (e.g., in the partial specialization of templates), but it seems it is not needed. Values (NTTPs) are currently used, which results in the extraneous parenthesis in the error messages. For example, reference<isq::length(), si::metre()>.

The biggest problem with doing this is that the system_reference used for Natural Units systems needs to take those by values. It could be considered inconsistent to use types for one abstraction and values for a similar one (although the reference is never typed by the user). The easiest solution to it would be renaming the system_reference to something else, but I do not have a good idea for a new name.

mpusz commented 6 months ago

It would be consistent with what we do for derived entities. For example, m / s results in the derived_unit<si::metre, si::second> type, which takes parameters as types to limit the noise.