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

πŸ§‘β€πŸ”¬ Make sure safe arithmetic works with a dimensional analysis library (like mpusz/units) #8

Open
lukevalenty opened this issue Nov 30, 2022 · 2 comments

Comments

@lukevalenty
Copy link
Contributor

No description provided.

@lukevalenty lukevalenty changed the title ✨ Add support for requirements extensions (units) πŸ§‘β€πŸ”¬ Make sure safe arithmetic works with a dimensional analysis library (like mpusz/units) Nov 30, 2022
@lukevalenty
Copy link
Contributor Author

Some notes on how this might work.

safe::var<int, ival<0, 1023>, km / h> current_speed = 100_s32 * km / h;

constexpr auto speed_limit = 100_s32 * km / h;
units::some_type<safe::var<int, ival<0, 1023>>> current_speed = 100_s32 * km / h;

safe::var<unit::some_type<int, km / h>, ival<0, 1023>> current_speed = 100_s32 * km / h;
units::some_type<safe::var<int, ival<100, 100>>>

@lukevalenty
Copy link
Contributor Author

another variation of the top that does a better job satisfying the DRY principle:

auto current_speed = s32_ival<0, 1023>{100_s32} * km / h;

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

1 participant