units
units copied to clipboard
Request: Implicit conversion from double-precision seconds to `std::chrono::duration<double>`.
Please include the following information in your issue:
- Using ea6d126942cb3225a341568ab57ec52513977875 (Sun Oct 11 06:46:02 2020 +0800)
- Apple clang version 13.1.6 (clang-1316.0.21.2.5)
If I change the tests to try to do implicit conversion to std::chrono::duration<double> instead of to std::chrono::nanoseconds, I get a compile error. This seems weird since seconds_t is duration in double seconds.:
/path/to/units/unitTests/main.cpp:2637:32: error: no viable conversion from 'units::time::second_t' (aka 'unit_t<unit<ratio<1>, base_unit<ratio<0L, 1L>, ratio<0>, ratio<1>>>>') to 'std::chrono::duration<double>'
std::chrono::duration<double> j = second_t(1);
^ ~~~~~~~~~~~
It looks like we could change the implicit-conversion operator to convert to any/some std::chrono::duration<T, Ratio> types. As far as I'm concerned, it'd be fine to just add implicit conversion from units' double seconds to std::chrono::duration<value_type>.