mirror of
https://github.com/pybind/pybind11.git
synced 2026-04-20 06:49:25 +00:00
Fix for floating point durations
The duration calculation was using %, but that's only supported on duration objects when the arithmetic type supports %, and hence fails for floats. Fixed by subtracting off the calculated values instead.
This commit is contained in:
@@ -48,6 +48,11 @@ std::chrono::microseconds test_chrono7(std::chrono::microseconds t) {
|
||||
return t;
|
||||
}
|
||||
|
||||
// Float durations (issue #719)
|
||||
std::chrono::duration<double> test_chrono_float_diff(std::chrono::duration<float> a, std::chrono::duration<float> b) {
|
||||
return a - b;
|
||||
}
|
||||
|
||||
test_initializer chrono([] (py::module &m) {
|
||||
m.def("test_chrono1", &test_chrono1);
|
||||
m.def("test_chrono2", &test_chrono2);
|
||||
@@ -56,4 +61,5 @@ test_initializer chrono([] (py::module &m) {
|
||||
m.def("test_chrono5", &test_chrono5);
|
||||
m.def("test_chrono6", &test_chrono6);
|
||||
m.def("test_chrono7", &test_chrono7);
|
||||
m.def("test_chrono_float_diff", &test_chrono_float_diff);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user