1616// along with this program. If not, see <http://www.gnu.org/licenses/>.
1717//
1818
19+ // C++ headers
20+ #include < type_traits> // for enable_if_t
21+
1922// libsemigroups headers
2023#include < libsemigroups/runner.hpp>
2124
@@ -33,20 +36,29 @@ namespace libsemigroups {
3336 namespace py = pybind11;
3437
3538 namespace {
36- std::chrono::system_clock::time_point
37- to_system (std::chrono::high_resolution_clock::time_point tp) {
38- using namespace std ::chrono;
39- if constexpr (std::is_same_v<system_clock, high_resolution_clock>) {
40- return tp;
41- } else {
42- // Account for the difference between system_clock and
43- // high_resolution_clock
44- auto sys_now = system_clock::now ();
45- auto high_res_now = high_resolution_clock::now ();
46- return time_point_cast<system_clock::duration>(tp - high_res_now
47- + sys_now);
48- }
39+ using namespace std ::chrono;
40+ template <
41+ typename TimePoint,
42+ std::enable_if_t <std::is_same_v<TimePoint, high_resolution_clock>, bool >
43+ = true >
44+ system_clock::time_point to_system (TimePoint tp) {
45+ return tp;
46+ }
47+
48+ template <
49+ typename TimePoint,
50+ std::enable_if_t <!std::is_same_v<TimePoint, high_resolution_clock>,
51+ bool >
52+ = true >
53+ system_clock::time_point to_system (TimePoint tp) {
54+ // Account for the difference between system_clock and
55+ // high_resolution_clock
56+ auto sys_now = system_clock::now ();
57+ auto high_res_now = high_resolution_clock::now ();
58+ return time_point_cast<system_clock::duration>(tp - high_res_now
59+ + sys_now);
4960 }
61+
5062 } // namespace
5163
5264 void init_reporter (py::module & m) {
0 commit comments