Commit bc4b89c2 authored by Max Kellermann's avatar Max Kellermann

Chrono: workaround for gcc 4.6 constexpr problems

parent e10c287c
......@@ -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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment