Counters: add support for std::chrono::duration
This MR is another step towards Counter-based timers (!787 (merged)):
- The first commit just adds a few additional
static_cast
toCounters.h
to ensure type matches for non-trivial Arithmetic types. I think those should have been there in the first place but problems only start appearing once you use the Counters with non-builtin types that have more strict conversion rules (e.g.std::chrono::duration<long,...>
andstd::chrono::duration<unsigned long,...>
do not implicitly convert) - Add helpers and a test case for using the Counters with
std::chrono::duration
objects. While one could simply accumulatestd::chrono::duration::counts()
without any of these changes, it's convenient to preserve the units as they can readily be used in the statistics printout.
Chrono
header files into the right location. Please advise if they should go somewhere else.
Edited by Frank Winklmeier