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

Request: Implicit conversion from double-precision seconds to std::chrono::duration<double>. #290

Open
BenFrantzDale opened this issue Aug 16, 2022 · 0 comments

Comments

@BenFrantzDale
Copy link

Please include the following information in your issue:

  1. Using ea6d126 (Sun Oct 11 06:46:02 2020 +0800)
  2. 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>.

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