diff options
-rw-r--r-- | src/Chrono.hxx | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/Chrono.hxx b/src/Chrono.hxx index e4a304e2c..cc87c5ba1 100644 --- a/src/Chrono.hxx +++ b/src/Chrono.hxx @@ -20,10 +20,19 @@ #ifndef MPD_CHRONO_HXX #define MPD_CHRONO_HXX +#include "Compiler.h" + #include <chrono> #include <utility> #include <cstdint> +#if defined(__GNUC__) && !GCC_CHECK_VERSION(4,7) && !defined(__clang__) +/* std::chrono::duration operators are "constexpr" since gcc 4.7 */ +#define chrono_constexpr gcc_pure +#else +#define chrono_constexpr constexpr +#endif + /** * A time stamp within a song. Granularity is 1 millisecond and the * maximum value is about 49 days. @@ -99,11 +108,11 @@ public: return count() > 0; } - constexpr SongTime operator+(const SongTime &other) const { + chrono_constexpr SongTime operator+(const SongTime &other) const { return SongTime(*(const Base *)this + (const Base &)other); } - constexpr SongTime operator-(const SongTime &other) const { + chrono_constexpr SongTime operator-(const SongTime &other) const { return SongTime(*(const Base *)this - (const Base &)other); } }; @@ -203,13 +212,15 @@ public: return count() < 0; } - constexpr SignedSongTime operator+(const SignedSongTime &other) const { + chrono_constexpr SignedSongTime operator+(const SignedSongTime &other) const { return SignedSongTime(*(const Base *)this + (const Base &)other); } - constexpr SignedSongTime operator-(const SignedSongTime &other) const { + chrono_constexpr SignedSongTime operator-(const SignedSongTime &other) const { return SignedSongTime(*(const Base *)this - (const Base &)other); } }; +#undef chrono_constexpr + #endif |