X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Ftime%2Ftimedelta.h;h=1a4274ba3a35c05822ad6f18c43775cf02e592e4;hp=a6c7005b9a35639875e36d85cc6d5b97ed169b5c;hb=HEAD;hpb=5d3a5019399f97af0371f4fd6dc415d36de6ac3a diff --git a/source/time/timedelta.h b/source/time/timedelta.h index a6c7005..2ff4bdd 100644 --- a/source/time/timedelta.h +++ b/source/time/timedelta.h @@ -20,11 +20,11 @@ private: public: /** Constructs a zero TimeDelta. */ - TimeDelta() = default; + constexpr TimeDelta() = default; /** Constructs a TimeDelta from a plain number. The purpose of this is to allow serialization together with the raw() function. */ - explicit TimeDelta(RawTime u): usec(u) { } + explicit constexpr TimeDelta(RawTime u): usec(u) { } /** Returns the raw number stored inside the TimeDelta. This should only be used for serialization and the result should not be interpreted in any way. */ @@ -65,14 +65,14 @@ MSPCORE_API void operator<<(LexicalConverter &, const TimeDelta &); // Constants to be used in creation of TimeDeltas -MSPCORE_API extern const TimeDelta zero; -MSPCORE_API extern const TimeDelta usec; -MSPCORE_API extern const TimeDelta msec; -MSPCORE_API extern const TimeDelta sec; -MSPCORE_API extern const TimeDelta min; -MSPCORE_API extern const TimeDelta hour; -MSPCORE_API extern const TimeDelta day; -MSPCORE_API extern const TimeDelta week; +constexpr TimeDelta zero(0); +constexpr TimeDelta usec(1); +constexpr TimeDelta msec(1000); +constexpr TimeDelta sec(1000000); +constexpr TimeDelta min(60*1000000); +constexpr TimeDelta hour(3600*1000000LL); +constexpr TimeDelta day(86400*1000000LL); +constexpr TimeDelta week(7*86400*1000000LL); inline TimeDelta abs(const TimeDelta &t) { return t>=zero ? t : -t; } using std::abs;