resolve cyclic dependency with zstd
[platform/upstream/cmake.git] / Source / cmDuration.h
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
5 #include <chrono>
6 #include <ratio>
7
8 using cmDuration = std::chrono::duration<double, std::ratio<1>>;
9
10 /*
11  * This function will return number of seconds in the requested type T.
12  *
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.
17  */
18 template <typename T>
19 T cmDurationTo(const cmDuration& duration);
20
21 #ifndef CMDURATION_CPP
22 extern template int cmDurationTo<int>(const cmDuration&);
23 extern template unsigned int cmDurationTo<unsigned int>(const cmDuration&);
24 #endif