Chrono: workaround for gcc 4.6 constexpr problems
This commit is contained in:
parent
e10c287c93
commit
bc4b89c21a
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user