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

Add error, with link, for passing Quantity to unit slot #327

Open
chiphogg opened this issue Nov 21, 2024 · 0 comments
Open

Add error, with link, for passing Quantity to unit slot #327

chiphogg opened this issue Nov 21, 2024 · 0 comments
Labels
⬇️ affects: documentation Improvements or additions to documentation 📁 kind: enhancement New feature or request 💪 effort: small

Comments

@chiphogg
Copy link
Contributor

Imagine trying to round some size to the nearest 10 bytes:

auto size = bytes(1234);
size = round_as<int>(bytes * mag<10>(), size);

This works (it gives bytes(1230)). However, users might try writing something like this:

auto size = bytes(1234);
size = round_as<int>(bytes(10), size); // (Incorrect)

If so, they might get an error like this:

image

That's not the best. It does say that IsUnit<...Quantity...> isn't satisfied, but it's not as straightforward as it could be.

We could instead turn AssociatedUnit<Quantity<...>> into a hard compiler error, with a readable message. Something like this:

image

That seems better: we can directly tell them that they're passing a Quantity to a unit slot, and link them to documentation on unit slots. Actually, probably even better would be to make a new entry in the troubleshooting page.

@chiphogg chiphogg added ⬇️ affects: documentation Improvements or additions to documentation 📁 kind: enhancement New feature or request 💪 effort: small labels Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⬇️ affects: documentation Improvements or additions to documentation 📁 kind: enhancement New feature or request 💪 effort: small
Projects
None yet
Development

No branches or pull requests

1 participant