[vlc-commits] vlc_ticks: Simplify C++ integer variants of vlc_tick_from_sec

Hugo Beauzée-Luyssen git at videolan.org
Fri Jun 29 18:26:35 CEST 2018


vlc | branch: master | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Fri Jun 29 18:16:17 2018 +0200| [af03afe3e17069728fac9458fb43ab3921042f82] | committer: Hugo Beauzée-Luyssen

vlc_ticks: Simplify C++ integer variants of vlc_tick_from_sec

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=af03afe3e17069728fac9458fb43ab3921042f82
---

 include/vlc_tick.h | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/include/vlc_tick.h b/include/vlc_tick.h
index 2863060dd4..daa9a13633 100644
--- a/include/vlc_tick.h
+++ b/include/vlc_tick.h
@@ -53,18 +53,15 @@ typedef vlc_tick_t mtime_t; /* deprecated, use vlc_tick_t */
 #define SEC_FROM_VLC_TICK(vtk)   ((vtk) / CLOCK_FREQ)
 
 #ifdef __cplusplus
-static inline vlc_tick_t vlc_tick_from_sec(int64_t sec)
-{
-    return CLOCK_FREQ * sec;
-}
-static inline vlc_tick_t vlc_tick_from_sec(int sec)
-{
-    return CLOCK_FREQ * sec;
-}
-static inline vlc_tick_t vlc_tick_from_sec(uint32_t sec)
+#include <type_traits>
+
+template <typename T>
+static inline auto vlc_tick_from_sec(T sec)
+    -> typename std::enable_if<std::is_integral<T>::value, vlc_tick_t>::type
 {
     return CLOCK_FREQ * sec;
 }
+
 /* seconds in floating point */
 static inline vlc_tick_t vlc_tick_from_sec(double secf)
 {



More information about the vlc-commits mailing list