cmDuration.h 845 B

123456789101112131415161718192021222324
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing for details. */
  3. #pragma once
  4. #include <chrono>
  5. #include <ratio>
  6. typedef std::chrono::duration<double, std::ratio<1>> cmDuration;
  7. /*
  8. * This function will return number of seconds in the requested type T.
  9. *
  10. * A duration_cast from duration<double> to duration<T> will not yield what
  11. * one might expect if the double representation does not fit into type T.
  12. * This function aims to safely convert, by clamping the double value between
  13. * the permissible valid values for T.
  14. */
  15. template <typename T>
  16. T cmDurationTo(const cmDuration& duration);
  17. #ifndef CMDURATION_CPP
  18. extern template int cmDurationTo<int>(const cmDuration&);
  19. extern template unsigned int cmDurationTo<unsigned int>(const cmDuration&);
  20. #endif