mirror of https://github.com/AxioDL/metaforce.git
hecl: Allow Time instances to be constexpr
Some constructors accept primitive values. These can be made constexpr.
This commit is contained in:
parent
b5a26d5136
commit
57fa706311
|
@ -485,20 +485,20 @@ class Time final {
|
||||||
time_t ts;
|
time_t ts;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Time() : ts(time(NULL)) {}
|
Time() : ts(std::time(nullptr)) {}
|
||||||
Time(time_t ti) : ts(ti) {}
|
constexpr Time(time_t ti) noexcept : ts{ti} {}
|
||||||
Time(const Time& other) { ts = other.ts; }
|
constexpr Time(const Time& other) noexcept : ts{other.ts} {}
|
||||||
time_t getTs() const { return ts; }
|
[[nodiscard]] constexpr time_t getTs() const { return ts; }
|
||||||
Time& operator=(const Time& other) {
|
constexpr Time& operator=(const Time& other) noexcept {
|
||||||
ts = other.ts;
|
ts = other.ts;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
bool operator==(const Time& other) const { return ts == other.ts; }
|
[[nodiscard]] constexpr bool operator==(const Time& other) const noexcept { return ts == other.ts; }
|
||||||
bool operator!=(const Time& other) const { return ts != other.ts; }
|
[[nodiscard]] constexpr bool operator!=(const Time& other) const noexcept { return ts != other.ts; }
|
||||||
bool operator<(const Time& other) const { return ts < other.ts; }
|
[[nodiscard]] constexpr bool operator<(const Time& other) const noexcept { return ts < other.ts; }
|
||||||
bool operator>(const Time& other) const { return ts > other.ts; }
|
[[nodiscard]] constexpr bool operator>(const Time& other) const noexcept { return ts > other.ts; }
|
||||||
bool operator<=(const Time& other) const { return ts <= other.ts; }
|
[[nodiscard]] constexpr bool operator<=(const Time& other) const noexcept { return ts <= other.ts; }
|
||||||
bool operator>=(const Time& other) const { return ts >= other.ts; }
|
[[nodiscard]] constexpr bool operator>=(const Time& other) const noexcept { return ts >= other.ts; }
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue