using std::chrono::seconds;
using std::chrono::microseconds;
- std::ostream& operator<<(std::ostream& m, const mono_time& t) {
+ template<typename Clock,
+ typename std::enable_if<Clock::is_steady>::type*>
+ std::ostream& operator<<(std::ostream& m,
+ const std::chrono::time_point<Clock>& t) {
return m << std::chrono::duration<double>(t.time_since_epoch()).count()
<< "s";
}
return m << std::chrono::duration<double>(t).count() << "s";
}
- std::ostream& operator<<(std::ostream& m, const real_time& t) {
+ template<typename Clock,
+ typename std::enable_if<!Clock::is_steady>::type*>
+ std::ostream& operator<<(std::ostream& m,
+ const std::chrono::time_point<Clock>& t) {
m.setf(std::ios::right);
char oldfill = m.fill();
m.fill('0');
// localtime. this looks like an absolute time.
// aim for http://en.wikipedia.org/wiki/ISO_8601
struct tm bdt;
- time_t tt = ceph::real_clock::to_time_t(t);
+ time_t tt = Clock::to_time_t(t);
localtime_r(&tt, &bdt);
m << std::setw(4) << (bdt.tm_year+1900) // 2007 -> '07'
<< '-' << std::setw(2) << (bdt.tm_mon+1)
m.unsetf(std::ios::right);
return m;
}
-};
+
+ template std::ostream&
+ operator<< <mono_clock>(std::ostream& m, const mono_time& t);
+ template std::ostream&
+ operator<< <real_clock>(std::ostream& m, const real_time& t);
+ template std::ostream&
+ operator<< <coarse_mono_clock>(std::ostream& m, const coarse_mono_time& t);
+ template std::ostream&
+ operator<< <coarse_real_clock>(std::ostream& m, const coarse_real_time& t);
+}
}
std::ostream& operator<<(std::ostream& m, const timespan& t);
- std::ostream& operator<<(std::ostream& m, const real_time& t);
- std::ostream& operator<<(std::ostream& m, const mono_time& t);
+ template<typename Clock,
+ typename std::enable_if<!Clock::is_steady>::type* = nullptr>
+ std::ostream& operator<<(std::ostream& m,
+ const std::chrono::time_point<Clock>& t);
+ template<typename Clock,
+ typename std::enable_if<Clock::is_steady>::type* = nullptr>
+ std::ostream& operator<<(std::ostream& m,
+ const std::chrono::time_point<Clock>& t);
// The way std::chrono handles the return type of subtraction is not
// wonderful. The difference of two unsigned types SHOULD be signed.