Skip to content

Integer reps perform truncating conversions without warning #122

@chiphogg

Description

@chiphogg

Describe the bug
Unit conversions which divide the underlying value by some integer are accepted without complaint for integer reps.

To Reproduce
Steps to reproduce the behavior:

SI::length_t<int, std::ratio<1>> x{3};
SI::length_t<int, std::ratio<12>> y = x;
std::cout << "x = " << x << "; y = " << y << "!\n";

For me, this prints:

x = 3 m; y = 0 m!

Expected behavior
This should be a compiler error. If the rep is integral, we should only permit conversions which multiply by an integer, since these will stay in the domain of the integers.

Screenshots
N/A

Desktop (please complete the following information):

  • OS: Linux
  • Browser: chrome
  • Version: 22.04

Smartphone (please complete the following information):
N/A

Additional context
N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions