diff options
author | Max Kellermann <max@duempel.org> | 2014-08-30 00:41:56 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2014-08-30 00:41:56 +0200 |
commit | bc4b89c21a8397d540be5989d9c99be90e80e554 (patch) | |
tree | a8042a32ef3573718344fb5728eac3e3db9cd9e9 /src/Chrono.hxx | |
parent | e10c287c93f2553f5b41ad16e5f9976ffb640bfe (diff) |
Chrono: workaround for gcc 4.6 constexpr problems
Diffstat (limited to 'src/Chrono.hxx')
-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 |