feat: add precise integer time (TimeDuration, TimeStamp) - #31
Merged
Conversation
Add the opt-in header utl/time_point.hpp with TimeDuration and TimeStamp: nanosecond-native int64 wrappers over Time<int64_t> with affine semantics (TimeStamp - TimeStamp -> TimeDuration, TimeStamp +/- TimeDuration -> TimeStamp, TimeStamp + TimeStamp deleted), scaling and comparison operators, the nanoseconds/microseconds/milliseconds/seconds factories, and a to_time() bridge to the dimensional Time<double> (seconds). These types deliberately avoid inv()/sqrt/float division and are not pulled in by utl.hpp, so the existing floating-point unit machinery and the single-header amalgamation are unaffected. Documented in the user guide. First piece of the v4.0.0 precise-time roadmap; chrono interop follows.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
FUTURE_WORK v4.0.0 — first piece of the precise-time roadmap.
Opt-in
utl/time_point.hppadds two nanosecond-native (int64) wrappers overTime<int64_t>:TimeDuration—+,-, unary-, integer scaling*//, comparisons;ns()/us()/ms()/s()integer accessors;to_time() -> Time<double>seconds bridge;nanoseconds/microseconds/milliseconds/secondsfactories.TimeStamp— affine point:Stamp - Stamp -> TimeDuration,Stamp +/- TimeDuration -> Stamp, comparisons, andStamp + Stampdeleted (adding absolute times is meaningless).Per the agreed design: native integer mode, no
inv()/sqrt/float ops, and it does not affect existing functionality —utl.hppdoes not include it, so the float/double unit machinery and the single-header amalgamation are untouched.Absolute<Unit>was dropped as unnecessary.New test
t_time_point. Verified: build (Werror), 49 tests, clang-format, single-header--checkin sync, mdbook;TimeStamp + TimeStampconfirmed rejected.chrono interop is the next PR.