Chrono: add static method Cast()

This commit is contained in:
Max Kellermann 2018-09-21 20:18:22 +02:00
parent 1d00d55d53
commit 39542de69d
1 changed files with 10 additions and 0 deletions

View File

@ -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);
}