Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: improve error message with unknown units #351

Closed
JohelEGP opened this issue Mar 29, 2022 · 3 comments
Closed

feat: improve error message with unknown units #351

JohelEGP opened this issue Mar 29, 2022 · 3 comments

Comments

@JohelEGP
Copy link
Collaborator

An example at https://mpusz.github.io/units/use_cases/unknown_dimensions.html includes:

constexpr auto result = 144 * km / (2 * h);
static_assert(std::is_same_v<decltype(result)::dimension,
                             unknown_dimension<exponent<dim_length, 1>, exponent<dim_time, -1>>>);
static_assert(std::is_same_v<decltype(result)::unit,
                             scaled_unit<ratio(1, 36, 1), unknown_coherent_unit>>);

Error messages containing unknown units could be improved if instead the unit's type were formed like expression templates. In this case, it could be something like unknown_unit<kilometre, per<hour>>.
What do you think?

@mpusz
Copy link
Owner

mpusz commented May 9, 2022

In this specific case it looks like a nice solution but what about more complicated units? Will the following:

constexpr auto result = 144 * km / (2 * h) / (2 * h);

look like unknown_unit<unknown_unit<kilometre, per<hour>>, per<hour>>? I am not sure if it is better? Units can be even more complicated than that...

@JohelEGP
Copy link
Collaborator Author

JohelEGP commented May 9, 2022

Do you mean the double mention of unknown_unit? That can probably be simplified somehow.

@mpusz mpusz added this to the v0.9.0 (V2 framework) milestone Dec 5, 2022
@mpusz mpusz mentioned this issue Dec 17, 2022
18 tasks
@mpusz
Copy link
Owner

mpusz commented Jun 15, 2023

Done in V2

@mpusz mpusz closed this as completed Jun 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants