Skip to content

🧑‍🔬 Make sure safe arithmetic works with a dimensional analysis library (like mpusz/units) #8

Open

Description

@lukevalenty
No description provided.

Activity

  1. changed the title [-]✨ Add support for requirements extensions (units)[/-] [+]🧑‍🔬 Make sure safe arithmetic works with a dimensional analysis library (like mpusz/units)[/+] on Nov 30, 2022
  2. lukevalenty commented on Nov 30, 2022

    @lukevalenty
    ContributorAuthor

    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>>>
  3. lukevalenty commented on Dec 1, 2022

    @lukevalenty
    ContributorAuthor

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions