hecl: Allow Time instances to be constexpr

Some constructors accept primitive values. These can be made constexpr.
This commit is contained in:
Lioncash 2020-04-05 09:34:22 -04:00
parent b5a26d5136
commit 57fa706311
1 changed files with 11 additions and 11 deletions

View File

@ -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; }
}; };
/** /**