The new clocks in the std
namespace all appear to be statically instantiated. high_resolution_clock
is not a class of clocks with high resolution, but rather the system-wide high resolution clock, with static methods such as now
.
I understand why they did it this way, but I have use for instanced clocks. In my case, I am emulating the presence of N high resolution clocks, one on each emulated board in an emulated device, where N is decided at runtime. In addition, the clock periods are decided at runtime.
My needs are clearly not identical to what the C++11 clocks offer. Is there a common approach to reusing the official classes like time_point<Clock, Duration>
referencing a runtime instance of a clock? I may end up needing to rewrite the entire clock API to suit my needs, but I'd love to reuse the standard work to save time.