How to create a custom clock for use in std::chrono functions?
问题 I have some arbitrary epoch, like July 13, 1988. Essentially I want to measure the time relative to this. I was thinking of writing a custom clock class, so that I could write code like this: using std::chrono; time_point<My_Clock> tp; std::cout << duration_cast<seconds>(tp.time_since_epoch()).count() << std::endl; Is this possible? If not, what's the cleanest way to accomplish this? 回答1: The hard part of writing this custom clock is figuring out how to write its now() function. In the