35 static const constexpr int64_t infinite_min = std::numeric_limits<int64_t>::max() / 8;
36 static const constexpr int64_t infinity = std::numeric_limits<int64_t>::max() / 2;
38 constexpr time_value& operator=(
bool d)
noexcept =
delete;
39 constexpr time_value& operator=(
double d)
noexcept =
delete;
40 constexpr time_value& operator=(
float d)
noexcept =
delete;
41 constexpr time_value& operator=(uint64_t d)
noexcept =
delete;
43 constexpr time_value& operator=(int64_t d)
noexcept
51 constexpr time_value& operator+=(
float d)
noexcept =
delete;
53 constexpr time_value& operator+=(int64_t d)
noexcept
65 if(infinite() || t.infinite())
75 constexpr time_value& operator-=(int64_t d)
noexcept
87 if(infinite() || t.infinite())
95 constexpr time_value& operator-() noexcept
107 assert(!ossia::safe_isnan(d));
108 assert(d <
static_cast<double>(infinite_min));
111 constexpr time_value operator+(int64_t d)
const noexcept
115 constexpr time_value operator+(uint64_t d)
const noexcept
117 assert(d < infinite_min);
118 return *
this + time_value{int64_t(d)};
120 constexpr time_value operator-(int64_t d)
const noexcept
122 return *
this + time_value{-d};
124 constexpr time_value operator-(uint64_t d)
const noexcept
126 assert(d < infinite_min);
127 return *
this + time_value{-int64_t(d)};
130 static constexpr bool
133 if(lhs.infinite() || rhs.infinite())
137 else if(lhs.impl >= 0 && rhs.impl >= 0)
139 uint64_t l = lhs.impl;
140 uint64_t r = rhs.impl;
141 return l + r >= infinite_min;
143 else if(lhs.impl >= 0 && rhs.impl < 0)
145 uint64_t l = lhs.impl;
146 return l + rhs.impl >= infinite_min;
148 else if(lhs.impl < 0 && rhs.impl >= 0)
150 uint64_t r = rhs.impl;
151 return lhs.impl + r >= infinite_min;
153 else if(lhs.impl < 0 && rhs.impl < 0)
156 uint64_t l = -lhs.impl;
157 uint64_t r = -rhs.impl;
158 return l + r >= infinite_min;
164 static constexpr bool
167 if(lhs.infinite() || rhs.infinite())
171 else if(lhs.impl >= 0 && rhs.impl >= 0)
175 else if(lhs.impl >= 0 && rhs.impl < 0)
177 uint64_t l = lhs.impl;
178 uint64_t r = -rhs.impl;
179 return l + r >= infinite_min;
181 else if(lhs.impl < 0 && rhs.impl >= 0)
183 uint64_t l = -lhs.impl;
184 uint64_t r = rhs.impl;
185 return l + r >= infinite_min;
187 else if(lhs.impl < 0 && rhs.impl < 0)
197 if(add_is_infinite(*
this, t))
198 return time_value{infinity};
200 return time_value{impl + t.impl};
207 assert(!ossia::safe_isnan(d));
208 assert(d <
static_cast<double>(infinite_min));
214 if(sub_is_infinite(*
this, t))
217 return time_value{impl - t.impl};
226 constexpr time_value operator*(
double d)
const noexcept
231 constexpr time_value operator*(int32_t d)
const noexcept
233 return time_value{impl * d};
236 constexpr time_value operator*(int64_t d)
const noexcept
238 return time_value{impl * d};
241 constexpr time_value operator*(uint32_t d)
const noexcept
243 return time_value{impl * d};
246 constexpr time_value operator*(uint64_t d)
const noexcept
248 return time_value{int64_t(impl * d)};
251 friend constexpr double operator/(time_value lhs, time_value rhs)
noexcept
253 return double(lhs.impl) / double(rhs.impl);
258 [[nodiscard]]
constexpr bool infinite() const noexcept {
return impl >= infinite_min; }
265 return (infinite() && rhs.infinite()) || (impl == rhs.impl);
269 return (infinite() != rhs.infinite()) || (impl != rhs.impl);
273 return !(infinite() && rhs.infinite()) && (impl < rhs.impl);
277 return !(infinite() && rhs.infinite()) && (impl > rhs.impl);
281 return !(infinite() && rhs.infinite()) && (impl <= rhs.impl);
285 return !(infinite() && rhs.infinite()) && (impl >= rhs.impl);