I like C++11's std::chrono
facilities, which let me work with:
but I occasionally need to work with time intervals, i.e. not just the duration between points, but a duration placed in time, i.e. a pair of either (start timepoint, end timepoint) or (start timepoint, duration). Specifically, I'm writing a library which involves exposing such intervals - which I create, i.e. I don't rely on classes for them defined elsewhere.
IIANM, std::chrono
does not offer any facilities/machinery for that. So - what is the common idiom for representing such time intervals (in a std::chrono
-friendly way), which I might use?
Notes:
Clock
type (including ones not built in to the standard library) and any Rep
type - so that I don't limit the users of my library.Hinnant's date library doesn't seem to contain this.
As pointed out above, Boost has this, but it uses its ptime
type, not Clock
and Rep
as you prefer.
So the justification for creating your own data structure is just that: what you want doesn't seem to already exist anywhere. It looks easy enough.