From 39542de69d8729b5f7c1271a0494f1a221434075 Mon Sep 17 00:00:00 2001
From: Max Kellermann <max@musicpd.org>
Date: Fri, 21 Sep 2018 20:18:22 +0200
Subject: [PATCH] Chrono: add static method Cast()

---
 src/Chrono.hxx | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/Chrono.hxx b/src/Chrono.hxx
index 106c10445..b57ff3e62 100644
--- a/src/Chrono.hxx
+++ b/src/Chrono.hxx
@@ -42,6 +42,11 @@ public:
 		return SongTime(Base::zero());
 	}
 
+	template<typename D>
+	static constexpr SongTime Cast(D src) {
+		return SongTime(std::chrono::duration_cast<Base>(src));
+	}
+
 	static constexpr SongTime FromS(unsigned s) {
 		return SongTime(rep(s) * 1000);
 	}
@@ -138,6 +143,11 @@ public:
 		return SignedSongTime(-1);
 	}
 
+	template<typename D>
+	static constexpr SongTime Cast(D src) {
+		return SongTime(std::chrono::duration_cast<Base>(src));
+	}
+
 	static constexpr SignedSongTime FromS(int s) {
 		return SignedSongTime(rep(s) * 1000);
 	}