| 121 | /// - Arithmetic with other time_points and durations |
| 122 | template<typename Clock, typename Duration = typename Clock::duration> |
| 123 | class time_point { |
| 124 | public: |
| 125 | using clock = Clock; |
| 126 | using duration = Duration; |
| 127 | using rep = typename Duration::rep; |
| 128 | using period = typename Duration::period; |
| 129 | |
| 130 | /// Default constructor - epoch time point |
| 131 | constexpr time_point() FL_NOEXCEPT : mDuration() {} |
| 132 | |
| 133 | /// Construct from a duration since epoch |
| 134 | constexpr explicit time_point(const Duration& d) FL_NOEXCEPT : mDuration(d) {} |
| 135 | |
| 136 | /// Get the duration since epoch |
| 137 | constexpr Duration time_since_epoch() const FL_NOEXCEPT { return mDuration; } |
| 138 | |
| 139 | // Comparison operators |
| 140 | constexpr bool operator<=(const time_point& rhs) const FL_NOEXCEPT { |
| 141 | return mDuration.count() <= rhs.mDuration.count(); |
| 142 | } |
| 143 | constexpr bool operator<(const time_point& rhs) const FL_NOEXCEPT { |
| 144 | return mDuration.count() < rhs.mDuration.count(); |
| 145 | } |
| 146 | constexpr bool operator>=(const time_point& rhs) const FL_NOEXCEPT { |
| 147 | return mDuration.count() >= rhs.mDuration.count(); |
| 148 | } |
| 149 | constexpr bool operator>(const time_point& rhs) const FL_NOEXCEPT { |
| 150 | return mDuration.count() > rhs.mDuration.count(); |
| 151 | } |
| 152 | constexpr bool operator==(const time_point& rhs) const FL_NOEXCEPT { |
| 153 | return mDuration.count() == rhs.mDuration.count(); |
| 154 | } |
| 155 | constexpr bool operator!=(const time_point& rhs) const FL_NOEXCEPT { |
| 156 | return mDuration.count() != rhs.mDuration.count(); |
| 157 | } |
| 158 | |
| 159 | /// Subtract two time_points to get a duration |
| 160 | constexpr Duration operator-(const time_point& rhs) const FL_NOEXCEPT { |
| 161 | return Duration(mDuration.count() - rhs.mDuration.count()); |
| 162 | } |
| 163 | |
| 164 | /// Add a duration to a time_point |
| 165 | constexpr time_point operator+(const Duration& d) const FL_NOEXCEPT { |
| 166 | return time_point(Duration(mDuration.count() + d.count())); |
| 167 | } |
| 168 | |
| 169 | /// Subtract a duration from a time_point |
| 170 | constexpr time_point operator-(const Duration& d) const FL_NOEXCEPT { |
| 171 | return time_point(Duration(mDuration.count() - d.count())); |
| 172 | } |
| 173 | |
| 174 | private: |
| 175 | Duration mDuration; |
| 176 | }; |
| 177 | |
| 178 | // Forward declarations for clock types (now() implemented after fl::micros() declaration) |
| 179 | struct steady_clock; // IWYU pragma: keep |