Closed amesgames closed 1 year ago
Sorry, I somehow missed your message here. It might be a genuine bug or limitation in the string conversion. I will look into it
In your code where you define the unit_symbol your are passing the type of the ratio not the ratio itself. Get rid of the ::type
and it should work as expected.
template <>
struct unit_symbol<'L', std::ratio<1609344l, 1000l>>
: SI::detail::unit_symbol_impl<'m', 'i'> {};
No clue why it works with mph
.
I will try to add a warning or error to the template to catch these errors easier but I am not sure if it is possible If you would like to add the imperial units feel free to open a PR ;)
That did it.
When I get back to this project, I will certainly issue a PR.
Thank you!
Describe the bug Terrific library, by the way. This could be user error, however I am unable to define a unit symbol for miles (
mi
), even though miles per hour (mph
) works.To Reproduce Steps to reproduce the behavior:
With the following header file, I am unable to produce a
SI::to_string()
output that hasmi
units.Expected behavior
The follow should produce the
str
value"1.000000 mi"
. Instead, it produces"1.000000 \000m"
.However, the following works fine and produces
"1.000000 mph"
.Desktop: