您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 

66 行
1.5 KiB

  1. #pragma once
  2. #include <chrono>
  3. #include <utility>
  4. namespace cppcore
  5. {
  6. namespace __impl
  7. {
  8. /**
  9. * @brief Helper class to convert time values.
  10. */
  11. template<class From, class To>
  12. struct op_convert_time;
  13. }
  14. /**
  15. * @brief Cast a chrono duration to a timeval.
  16. *
  17. * @param[in] d Chrono duration to cast.
  18. *
  19. * @return Casted timeval.
  20. */
  21. template<typename T, typename Rep, typename Period>
  22. inline auto duration_cast(const std::chrono::duration<Rep, Period>& d)
  23. -> std::enable_if_t<std::is_same<T, ::timeval>::value, ::timeval>;
  24. /**
  25. * @brief Cast a chrono duration to a timespec.
  26. *
  27. * @param[in] d Chrono duration to cast.
  28. *
  29. * @return Casted timespec.
  30. */
  31. template<typename T, typename Rep, typename Period>
  32. inline auto duration_cast(const std::chrono::duration<Rep, Period>& d)
  33. -> std::enable_if_t<std::is_same<T, ::timespec>::value, ::timespec>;
  34. /**
  35. * @brief Cast a timeval to a chrono duration.
  36. *
  37. * @param[in] tv Timeval to cast to chrono duration.
  38. *
  39. * @return Casted chrono duration.
  40. */
  41. template<typename Duration>
  42. Duration duration_cast(const ::timeval& tv);
  43. /**
  44. * @brief Cast a timespec to a chrono duration.
  45. *
  46. * @param[in] ts Timespec to cast to chrono duration.
  47. *
  48. * @return Casted chrono duration.
  49. */
  50. template<typename Duration>
  51. Duration duration_cast(const ::timespec& ts);
  52. }
  53. #include "time.inl"