CMake Nightly Date Stamp
[kiteware-cmake.git] / Source / cmDuration.h
blobccd1cc1cc5978c66b36a9c25754d04caddf08bda
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
5 #include <chrono>
6 #include <ratio>
8 using cmDuration = std::chrono::duration<double, std::ratio<1>>;
11 * This function will return number of seconds in the requested type T.
13 * A duration_cast from duration<double> to duration<T> will not yield what
14 * one might expect if the double representation does not fit into type T.
15 * This function aims to safely convert, by clamping the double value between
16 * the permissible valid values for T.
18 template <typename T>
19 T cmDurationTo(const cmDuration& duration);
21 #ifndef CMDURATION_CPP
22 extern template int cmDurationTo<int>(const cmDuration&);
23 extern template unsigned int cmDurationTo<unsigned int>(const cmDuration&);
24 #endif