From bc4b89c21a8397d540be5989d9c99be90e80e554 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sat, 30 Aug 2014 00:41:56 +0200 Subject: Chrono: workaround for gcc 4.6 constexpr problems --- src/Chrono.hxx | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'src/Chrono.hxx') 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 #include #include +#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 -- cgit v1.2.3