std::atomic<std::chrono::high_resolution_clock::time_point> can not compile

Your choices:

  • forget about making it atomic and use a mutex to serialise access

  • pick some integral unit of time (e.g. milliseconds since epoch) and convert to/from that on the fly, storing the integral value in some integral type you've worked out has sufficient capacity to cover the range of dates you're handling (perhaps std::atomic_ullong)

  • (nutty suggestion removed)


Use std::atomic<std::chrono::high_resolution_clock::duration> and set it to time_point::time_since_epoch() when storing; when loading, construct a time_point from the duration in the atomic with the standard conversion constructor for that. It's a little irritating that this is necessary, but at least it's type safe and there are no uncertainties about the size or resolution of the atomic type.