chrono 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713
  1. // -*- C++ -*-
  2. //===----------------------------------------------------------------------===//
  3. //
  4. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  5. // See https://llvm.org/LICENSE.txt for license information.
  6. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  7. //
  8. //===----------------------------------------------------------------------===//
  9. #ifndef _LIBCPP_CHRONO
  10. #define _LIBCPP_CHRONO
  11. /*
  12. chrono synopsis
  13. namespace std
  14. {
  15. namespace chrono
  16. {
  17. template <class ToDuration, class Rep, class Period>
  18. constexpr
  19. ToDuration
  20. duration_cast(const duration<Rep, Period>& fd);
  21. template <class Rep> struct treat_as_floating_point : is_floating_point<Rep> {};
  22. template <class Rep> inline constexpr bool treat_as_floating_point_v
  23. = treat_as_floating_point<Rep>::value; // C++17
  24. template <class Rep>
  25. struct duration_values
  26. {
  27. public:
  28. static constexpr Rep zero(); // noexcept in C++20
  29. static constexpr Rep max(); // noexcept in C++20
  30. static constexpr Rep min(); // noexcept in C++20
  31. };
  32. // duration
  33. template <class Rep, class Period = ratio<1>>
  34. class duration
  35. {
  36. static_assert(!__is_duration<Rep>::value, "A duration representation can not be a duration");
  37. static_assert(__is_ratio<Period>::value, "Second template parameter of duration must be a std::ratio");
  38. static_assert(Period::num > 0, "duration period must be positive");
  39. public:
  40. typedef Rep rep;
  41. typedef typename _Period::type period;
  42. constexpr duration() = default;
  43. template <class Rep2>
  44. constexpr explicit duration(const Rep2& r,
  45. typename enable_if
  46. <
  47. is_convertible<Rep2, rep>::value &&
  48. (treat_as_floating_point<rep>::value ||
  49. !treat_as_floating_point<rep>::value && !treat_as_floating_point<Rep2>::value)
  50. >::type* = 0);
  51. // conversions
  52. template <class Rep2, class Period2>
  53. constexpr duration(const duration<Rep2, Period2>& d,
  54. typename enable_if
  55. <
  56. treat_as_floating_point<rep>::value ||
  57. ratio_divide<Period2, period>::type::den == 1
  58. >::type* = 0);
  59. // observer
  60. constexpr rep count() const;
  61. // arithmetic
  62. constexpr common_type<duration>::type operator+() const;
  63. constexpr common_type<duration>::type operator-() const;
  64. constexpr duration& operator++(); // constexpr in C++17
  65. constexpr duration operator++(int); // constexpr in C++17
  66. constexpr duration& operator--(); // constexpr in C++17
  67. constexpr duration operator--(int); // constexpr in C++17
  68. constexpr duration& operator+=(const duration& d); // constexpr in C++17
  69. constexpr duration& operator-=(const duration& d); // constexpr in C++17
  70. duration& operator*=(const rep& rhs); // constexpr in C++17
  71. duration& operator/=(const rep& rhs); // constexpr in C++17
  72. duration& operator%=(const rep& rhs); // constexpr in C++17
  73. duration& operator%=(const duration& rhs); // constexpr in C++17
  74. // special values
  75. static constexpr duration zero(); // noexcept in C++20
  76. static constexpr duration min(); // noexcept in C++20
  77. static constexpr duration max(); // noexcept in C++20
  78. };
  79. typedef duration<long long, nano> nanoseconds;
  80. typedef duration<long long, micro> microseconds;
  81. typedef duration<long long, milli> milliseconds;
  82. typedef duration<long long > seconds;
  83. typedef duration< long, ratio< 60> > minutes;
  84. typedef duration< long, ratio<3600> > hours;
  85. template <class Clock, class Duration = typename Clock::duration>
  86. class time_point
  87. {
  88. public:
  89. typedef Clock clock;
  90. typedef Duration duration;
  91. typedef typename duration::rep rep;
  92. typedef typename duration::period period;
  93. private:
  94. duration d_; // exposition only
  95. public:
  96. time_point(); // has value "epoch" // constexpr in C++14
  97. explicit time_point(const duration& d); // same as time_point() + d // constexpr in C++14
  98. // conversions
  99. template <class Duration2>
  100. time_point(const time_point<clock, Duration2>& t); // constexpr in C++14
  101. // observer
  102. duration time_since_epoch() const; // constexpr in C++14
  103. // arithmetic
  104. time_point& operator+=(const duration& d); // constexpr in C++17
  105. time_point& operator-=(const duration& d); // constexpr in C++17
  106. // special values
  107. static constexpr time_point min(); // noexcept in C++20
  108. static constexpr time_point max(); // noexcept in C++20
  109. };
  110. } // chrono
  111. // common_type traits
  112. template <class Rep1, class Period1, class Rep2, class Period2>
  113. struct common_type<chrono::duration<Rep1, Period1>, chrono::duration<Rep2, Period2>>;
  114. template <class Clock, class Duration1, class Duration2>
  115. struct common_type<chrono::time_point<Clock, Duration1>, chrono::time_point<Clock, Duration2>>;
  116. namespace chrono {
  117. // duration arithmetic
  118. template <class Rep1, class Period1, class Rep2, class Period2>
  119. constexpr
  120. typename common_type<duration<Rep1, Period1>, duration<Rep2, Period2>>::type
  121. operator+(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
  122. template <class Rep1, class Period1, class Rep2, class Period2>
  123. constexpr
  124. typename common_type<duration<Rep1, Period1>, duration<Rep2, Period2>>::type
  125. operator-(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
  126. template <class Rep1, class Period, class Rep2>
  127. constexpr
  128. duration<typename common_type<Rep1, Rep2>::type, Period>
  129. operator*(const duration<Rep1, Period>& d, const Rep2& s);
  130. template <class Rep1, class Period, class Rep2>
  131. constexpr
  132. duration<typename common_type<Rep1, Rep2>::type, Period>
  133. operator*(const Rep1& s, const duration<Rep2, Period>& d);
  134. template <class Rep1, class Period, class Rep2>
  135. constexpr
  136. duration<typename common_type<Rep1, Rep2>::type, Period>
  137. operator/(const duration<Rep1, Period>& d, const Rep2& s);
  138. template <class Rep1, class Period1, class Rep2, class Period2>
  139. constexpr
  140. typename common_type<Rep1, Rep2>::type
  141. operator/(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
  142. // duration comparisons
  143. template <class Rep1, class Period1, class Rep2, class Period2>
  144. constexpr
  145. bool operator==(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
  146. template <class Rep1, class Period1, class Rep2, class Period2>
  147. constexpr
  148. bool operator!=(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
  149. template <class Rep1, class Period1, class Rep2, class Period2>
  150. constexpr
  151. bool operator< (const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
  152. template <class Rep1, class Period1, class Rep2, class Period2>
  153. constexpr
  154. bool operator<=(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
  155. template <class Rep1, class Period1, class Rep2, class Period2>
  156. constexpr
  157. bool operator> (const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
  158. template <class Rep1, class Period1, class Rep2, class Period2>
  159. constexpr
  160. bool operator>=(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
  161. // duration_cast
  162. template <class ToDuration, class Rep, class Period>
  163. ToDuration duration_cast(const duration<Rep, Period>& d);
  164. template <class ToDuration, class Rep, class Period>
  165. constexpr ToDuration floor(const duration<Rep, Period>& d); // C++17
  166. template <class ToDuration, class Rep, class Period>
  167. constexpr ToDuration ceil(const duration<Rep, Period>& d); // C++17
  168. template <class ToDuration, class Rep, class Period>
  169. constexpr ToDuration round(const duration<Rep, Period>& d); // C++17
  170. // duration I/O is elsewhere
  171. // time_point arithmetic (all constexpr in C++14)
  172. template <class Clock, class Duration1, class Rep2, class Period2>
  173. time_point<Clock, typename common_type<Duration1, duration<Rep2, Period2>>::type>
  174. operator+(const time_point<Clock, Duration1>& lhs, const duration<Rep2, Period2>& rhs);
  175. template <class Rep1, class Period1, class Clock, class Duration2>
  176. time_point<Clock, typename common_type<duration<Rep1, Period1>, Duration2>::type>
  177. operator+(const duration<Rep1, Period1>& lhs, const time_point<Clock, Duration2>& rhs);
  178. template <class Clock, class Duration1, class Rep2, class Period2>
  179. time_point<Clock, typename common_type<Duration1, duration<Rep2, Period2>>::type>
  180. operator-(const time_point<Clock, Duration1>& lhs, const duration<Rep2, Period2>& rhs);
  181. template <class Clock, class Duration1, class Duration2>
  182. typename common_type<Duration1, Duration2>::type
  183. operator-(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
  184. // time_point comparisons (all constexpr in C++14)
  185. template <class Clock, class Duration1, class Duration2>
  186. bool operator==(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
  187. template <class Clock, class Duration1, class Duration2>
  188. bool operator!=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
  189. template <class Clock, class Duration1, class Duration2>
  190. bool operator< (const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
  191. template <class Clock, class Duration1, class Duration2>
  192. bool operator<=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
  193. template <class Clock, class Duration1, class Duration2>
  194. bool operator> (const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
  195. template <class Clock, class Duration1, class Duration2>
  196. bool operator>=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
  197. // time_point_cast (constexpr in C++14)
  198. template <class ToDuration, class Clock, class Duration>
  199. time_point<Clock, ToDuration> time_point_cast(const time_point<Clock, Duration>& t);
  200. template <class ToDuration, class Clock, class Duration>
  201. constexpr time_point<Clock, ToDuration>
  202. floor(const time_point<Clock, Duration>& tp); // C++17
  203. template <class ToDuration, class Clock, class Duration>
  204. constexpr time_point<Clock, ToDuration>
  205. ceil(const time_point<Clock, Duration>& tp); // C++17
  206. template <class ToDuration, class Clock, class Duration>
  207. constexpr time_point<Clock, ToDuration>
  208. round(const time_point<Clock, Duration>& tp); // C++17
  209. template <class Rep, class Period>
  210. constexpr duration<Rep, Period> abs(duration<Rep, Period> d); // C++17
  211. // Clocks
  212. class system_clock
  213. {
  214. public:
  215. typedef microseconds duration;
  216. typedef duration::rep rep;
  217. typedef duration::period period;
  218. typedef chrono::time_point<system_clock> time_point;
  219. static const bool is_steady = false; // constexpr in C++14
  220. static time_point now() noexcept;
  221. static time_t to_time_t (const time_point& __t) noexcept;
  222. static time_point from_time_t(time_t __t) noexcept;
  223. };
  224. template <class Duration>
  225. using sys_time = time_point<system_clock, Duration>; // C++20
  226. using sys_seconds = sys_time<seconds>; // C++20
  227. using sys_days = sys_time<days>; // C++20
  228. class file_clock // C++20
  229. {
  230. public:
  231. typedef see-below rep;
  232. typedef nano period;
  233. typedef chrono::duration<rep, period> duration;
  234. typedef chrono::time_point<file_clock> time_point;
  235. static constexpr bool is_steady = false;
  236. static time_point now() noexcept;
  237. template<class Duration>
  238. static sys_time<see-below> to_sys(const file_time<Duration>&);
  239. template<class Duration>
  240. static file_time<see-below> from_sys(const sys_time<Duration>&);
  241. };
  242. template<class Duration>
  243. using file_time = time_point<file_clock, Duration>; // C++20
  244. class steady_clock
  245. {
  246. public:
  247. typedef nanoseconds duration;
  248. typedef duration::rep rep;
  249. typedef duration::period period;
  250. typedef chrono::time_point<steady_clock, duration> time_point;
  251. static const bool is_steady = true; // constexpr in C++14
  252. static time_point now() noexcept;
  253. };
  254. typedef steady_clock high_resolution_clock;
  255. // 25.7.8, local time // C++20
  256. struct local_t {};
  257. template<class Duration>
  258. using local_time = time_point<local_t, Duration>;
  259. using local_seconds = local_time<seconds>;
  260. using local_days = local_time<days>;
  261. // 25.8.2, class last_spec // C++20
  262. struct last_spec;
  263. // 25.8.3, class day // C++20
  264. class day;
  265. constexpr bool operator==(const day& x, const day& y) noexcept;
  266. constexpr bool operator!=(const day& x, const day& y) noexcept;
  267. constexpr bool operator< (const day& x, const day& y) noexcept;
  268. constexpr bool operator> (const day& x, const day& y) noexcept;
  269. constexpr bool operator<=(const day& x, const day& y) noexcept;
  270. constexpr bool operator>=(const day& x, const day& y) noexcept;
  271. constexpr day operator+(const day& x, const days& y) noexcept;
  272. constexpr day operator+(const days& x, const day& y) noexcept;
  273. constexpr day operator-(const day& x, const days& y) noexcept;
  274. constexpr days operator-(const day& x, const day& y) noexcept;
  275. // 25.8.4, class month // C++20
  276. class month;
  277. constexpr bool operator==(const month& x, const month& y) noexcept;
  278. constexpr bool operator!=(const month& x, const month& y) noexcept;
  279. constexpr bool operator< (const month& x, const month& y) noexcept;
  280. constexpr bool operator> (const month& x, const month& y) noexcept;
  281. constexpr bool operator<=(const month& x, const month& y) noexcept;
  282. constexpr bool operator>=(const month& x, const month& y) noexcept;
  283. constexpr month operator+(const month& x, const months& y) noexcept;
  284. constexpr month operator+(const months& x, const month& y) noexcept;
  285. constexpr month operator-(const month& x, const months& y) noexcept;
  286. constexpr months operator-(const month& x, const month& y) noexcept;
  287. // 25.8.5, class year // C++20
  288. class year;
  289. constexpr bool operator==(const year& x, const year& y) noexcept;
  290. constexpr bool operator!=(const year& x, const year& y) noexcept;
  291. constexpr bool operator< (const year& x, const year& y) noexcept;
  292. constexpr bool operator> (const year& x, const year& y) noexcept;
  293. constexpr bool operator<=(const year& x, const year& y) noexcept;
  294. constexpr bool operator>=(const year& x, const year& y) noexcept;
  295. constexpr year operator+(const year& x, const years& y) noexcept;
  296. constexpr year operator+(const years& x, const year& y) noexcept;
  297. constexpr year operator-(const year& x, const years& y) noexcept;
  298. constexpr years operator-(const year& x, const year& y) noexcept;
  299. // 25.8.6, class weekday // C++20
  300. class weekday;
  301. constexpr bool operator==(const weekday& x, const weekday& y) noexcept;
  302. constexpr bool operator!=(const weekday& x, const weekday& y) noexcept;
  303. constexpr weekday operator+(const weekday& x, const days& y) noexcept;
  304. constexpr weekday operator+(const days& x, const weekday& y) noexcept;
  305. constexpr weekday operator-(const weekday& x, const days& y) noexcept;
  306. constexpr days operator-(const weekday& x, const weekday& y) noexcept;
  307. // 25.8.7, class weekday_indexed // C++20
  308. class weekday_indexed;
  309. constexpr bool operator==(const weekday_indexed& x, const weekday_indexed& y) noexcept;
  310. constexpr bool operator!=(const weekday_indexed& x, const weekday_indexed& y) noexcept;
  311. // 25.8.8, class weekday_last // C++20
  312. class weekday_last;
  313. constexpr bool operator==(const weekday_last& x, const weekday_last& y) noexcept;
  314. constexpr bool operator!=(const weekday_last& x, const weekday_last& y) noexcept;
  315. // 25.8.9, class month_day // C++20
  316. class month_day;
  317. constexpr bool operator==(const month_day& x, const month_day& y) noexcept;
  318. constexpr bool operator!=(const month_day& x, const month_day& y) noexcept;
  319. constexpr bool operator< (const month_day& x, const month_day& y) noexcept;
  320. constexpr bool operator> (const month_day& x, const month_day& y) noexcept;
  321. constexpr bool operator<=(const month_day& x, const month_day& y) noexcept;
  322. constexpr bool operator>=(const month_day& x, const month_day& y) noexcept;
  323. // 25.8.10, class month_day_last // C++20
  324. class month_day_last;
  325. constexpr bool operator==(const month_day_last& x, const month_day_last& y) noexcept;
  326. constexpr bool operator!=(const month_day_last& x, const month_day_last& y) noexcept;
  327. constexpr bool operator< (const month_day_last& x, const month_day_last& y) noexcept;
  328. constexpr bool operator> (const month_day_last& x, const month_day_last& y) noexcept;
  329. constexpr bool operator<=(const month_day_last& x, const month_day_last& y) noexcept;
  330. constexpr bool operator>=(const month_day_last& x, const month_day_last& y) noexcept;
  331. // 25.8.11, class month_weekday // C++20
  332. class month_weekday;
  333. constexpr bool operator==(const month_weekday& x, const month_weekday& y) noexcept;
  334. constexpr bool operator!=(const month_weekday& x, const month_weekday& y) noexcept;
  335. // 25.8.12, class month_weekday_last // C++20
  336. class month_weekday_last;
  337. constexpr bool operator==(const month_weekday_last& x, const month_weekday_last& y) noexcept;
  338. constexpr bool operator!=(const month_weekday_last& x, const month_weekday_last& y) noexcept;
  339. // 25.8.13, class year_month // C++20
  340. class year_month;
  341. constexpr bool operator==(const year_month& x, const year_month& y) noexcept;
  342. constexpr bool operator!=(const year_month& x, const year_month& y) noexcept;
  343. constexpr bool operator< (const year_month& x, const year_month& y) noexcept;
  344. constexpr bool operator> (const year_month& x, const year_month& y) noexcept;
  345. constexpr bool operator<=(const year_month& x, const year_month& y) noexcept;
  346. constexpr bool operator>=(const year_month& x, const year_month& y) noexcept;
  347. constexpr year_month operator+(const year_month& ym, const months& dm) noexcept;
  348. constexpr year_month operator+(const months& dm, const year_month& ym) noexcept;
  349. constexpr year_month operator-(const year_month& ym, const months& dm) noexcept;
  350. constexpr months operator-(const year_month& x, const year_month& y) noexcept;
  351. constexpr year_month operator+(const year_month& ym, const years& dy) noexcept;
  352. constexpr year_month operator+(const years& dy, const year_month& ym) noexcept;
  353. constexpr year_month operator-(const year_month& ym, const years& dy) noexcept;
  354. // 25.8.14, class year_month_day class // C++20
  355. year_month_day;
  356. constexpr bool operator==(const year_month_day& x, const year_month_day& y) noexcept;
  357. constexpr bool operator!=(const year_month_day& x, const year_month_day& y) noexcept;
  358. constexpr bool operator< (const year_month_day& x, const year_month_day& y) noexcept;
  359. constexpr bool operator> (const year_month_day& x, const year_month_day& y) noexcept;
  360. constexpr bool operator<=(const year_month_day& x, const year_month_day& y) noexcept;
  361. constexpr bool operator>=(const year_month_day& x, const year_month_day& y) noexcept;
  362. constexpr year_month_day operator+(const year_month_day& ymd, const months& dm) noexcept;
  363. constexpr year_month_day operator+(const months& dm, const year_month_day& ymd) noexcept;
  364. constexpr year_month_day operator+(const year_month_day& ymd, const years& dy) noexcept;
  365. constexpr year_month_day operator+(const years& dy, const year_month_day& ymd) noexcept;
  366. constexpr year_month_day operator-(const year_month_day& ymd, const months& dm) noexcept;
  367. constexpr year_month_day operator-(const year_month_day& ymd, const years& dy) noexcept;
  368. // 25.8.15, class year_month_day_last // C++20
  369. class year_month_day_last;
  370. constexpr bool operator==(const year_month_day_last& x,
  371. const year_month_day_last& y) noexcept;
  372. constexpr bool operator!=(const year_month_day_last& x,
  373. const year_month_day_last& y) noexcept;
  374. constexpr bool operator< (const year_month_day_last& x,
  375. const year_month_day_last& y) noexcept;
  376. constexpr bool operator> (const year_month_day_last& x,
  377. const year_month_day_last& y) noexcept;
  378. constexpr bool operator<=(const year_month_day_last& x,
  379. const year_month_day_last& y) noexcept;
  380. constexpr bool operator>=(const year_month_day_last& x,
  381. const year_month_day_last& y) noexcept;
  382. constexpr year_month_day_last
  383. operator+(const year_month_day_last& ymdl, const months& dm) noexcept;
  384. constexpr year_month_day_last
  385. operator+(const months& dm, const year_month_day_last& ymdl) noexcept;
  386. constexpr year_month_day_last
  387. operator+(const year_month_day_last& ymdl, const years& dy) noexcept;
  388. constexpr year_month_day_last
  389. operator+(const years& dy, const year_month_day_last& ymdl) noexcept;
  390. constexpr year_month_day_last
  391. operator-(const year_month_day_last& ymdl, const months& dm) noexcept;
  392. constexpr year_month_day_last
  393. operator-(const year_month_day_last& ymdl, const years& dy) noexcept;
  394. // 25.8.16, class year_month_weekday // C++20
  395. class year_month_weekday;
  396. constexpr bool operator==(const year_month_weekday& x,
  397. const year_month_weekday& y) noexcept;
  398. constexpr bool operator!=(const year_month_weekday& x,
  399. const year_month_weekday& y) noexcept;
  400. constexpr year_month_weekday
  401. operator+(const year_month_weekday& ymwd, const months& dm) noexcept;
  402. constexpr year_month_weekday
  403. operator+(const months& dm, const year_month_weekday& ymwd) noexcept;
  404. constexpr year_month_weekday
  405. operator+(const year_month_weekday& ymwd, const years& dy) noexcept;
  406. constexpr year_month_weekday
  407. operator+(const years& dy, const year_month_weekday& ymwd) noexcept;
  408. constexpr year_month_weekday
  409. operator-(const year_month_weekday& ymwd, const months& dm) noexcept;
  410. constexpr year_month_weekday
  411. operator-(const year_month_weekday& ymwd, const years& dy) noexcept;
  412. // 25.8.17, class year_month_weekday_last // C++20
  413. class year_month_weekday_last;
  414. constexpr bool operator==(const year_month_weekday_last& x,
  415. const year_month_weekday_last& y) noexcept;
  416. constexpr bool operator!=(const year_month_weekday_last& x,
  417. const year_month_weekday_last& y) noexcept;
  418. constexpr year_month_weekday_last
  419. operator+(const year_month_weekday_last& ymwdl, const months& dm) noexcept;
  420. constexpr year_month_weekday_last
  421. operator+(const months& dm, const year_month_weekday_last& ymwdl) noexcept;
  422. constexpr year_month_weekday_last
  423. operator+(const year_month_weekday_last& ymwdl, const years& dy) noexcept;
  424. constexpr year_month_weekday_last
  425. operator+(const years& dy, const year_month_weekday_last& ymwdl) noexcept;
  426. constexpr year_month_weekday_last
  427. operator-(const year_month_weekday_last& ymwdl, const months& dm) noexcept;
  428. constexpr year_month_weekday_last
  429. operator-(const year_month_weekday_last& ymwdl, const years& dy) noexcept;
  430. // 25.8.18, civil calendar conventional syntax operators // C++20
  431. constexpr year_month
  432. operator/(const year& y, const month& m) noexcept;
  433. constexpr year_month
  434. operator/(const year& y, int m) noexcept;
  435. constexpr month_day
  436. operator/(const month& m, const day& d) noexcept;
  437. constexpr month_day
  438. operator/(const month& m, int d) noexcept;
  439. constexpr month_day
  440. operator/(int m, const day& d) noexcept;
  441. constexpr month_day
  442. operator/(const day& d, const month& m) noexcept;
  443. constexpr month_day
  444. operator/(const day& d, int m) noexcept;
  445. constexpr month_day_last
  446. operator/(const month& m, last_spec) noexcept;
  447. constexpr month_day_last
  448. operator/(int m, last_spec) noexcept;
  449. constexpr month_day_last
  450. operator/(last_spec, const month& m) noexcept;
  451. constexpr month_day_last
  452. operator/(last_spec, int m) noexcept;
  453. constexpr month_weekday
  454. operator/(const month& m, const weekday_indexed& wdi) noexcept;
  455. constexpr month_weekday
  456. operator/(int m, const weekday_indexed& wdi) noexcept;
  457. constexpr month_weekday
  458. operator/(const weekday_indexed& wdi, const month& m) noexcept;
  459. constexpr month_weekday
  460. operator/(const weekday_indexed& wdi, int m) noexcept;
  461. constexpr month_weekday_last
  462. operator/(const month& m, const weekday_last& wdl) noexcept;
  463. constexpr month_weekday_last
  464. operator/(int m, const weekday_last& wdl) noexcept;
  465. constexpr month_weekday_last
  466. operator/(const weekday_last& wdl, const month& m) noexcept;
  467. constexpr month_weekday_last
  468. operator/(const weekday_last& wdl, int m) noexcept;
  469. constexpr year_month_day
  470. operator/(const year_month& ym, const day& d) noexcept;
  471. constexpr year_month_day
  472. operator/(const year_month& ym, int d) noexcept;
  473. constexpr year_month_day
  474. operator/(const year& y, const month_day& md) noexcept;
  475. constexpr year_month_day
  476. operator/(int y, const month_day& md) noexcept;
  477. constexpr year_month_day
  478. operator/(const month_day& md, const year& y) noexcept;
  479. constexpr year_month_day
  480. operator/(const month_day& md, int y) noexcept;
  481. constexpr year_month_day_last
  482. operator/(const year_month& ym, last_spec) noexcept;
  483. constexpr year_month_day_last
  484. operator/(const year& y, const month_day_last& mdl) noexcept;
  485. constexpr year_month_day_last
  486. operator/(int y, const month_day_last& mdl) noexcept;
  487. constexpr year_month_day_last
  488. operator/(const month_day_last& mdl, const year& y) noexcept;
  489. constexpr year_month_day_last
  490. operator/(const month_day_last& mdl, int y) noexcept;
  491. constexpr year_month_weekday
  492. operator/(const year_month& ym, const weekday_indexed& wdi) noexcept;
  493. constexpr year_month_weekday
  494. operator/(const year& y, const month_weekday& mwd) noexcept;
  495. constexpr year_month_weekday
  496. operator/(int y, const month_weekday& mwd) noexcept;
  497. constexpr year_month_weekday
  498. operator/(const month_weekday& mwd, const year& y) noexcept;
  499. constexpr year_month_weekday
  500. operator/(const month_weekday& mwd, int y) noexcept;
  501. constexpr year_month_weekday_last
  502. operator/(const year_month& ym, const weekday_last& wdl) noexcept;
  503. constexpr year_month_weekday_last
  504. operator/(const year& y, const month_weekday_last& mwdl) noexcept;
  505. constexpr year_month_weekday_last
  506. operator/(int y, const month_weekday_last& mwdl) noexcept;
  507. constexpr year_month_weekday_last
  508. operator/(const month_weekday_last& mwdl, const year& y) noexcept;
  509. constexpr year_month_weekday_last
  510. operator/(const month_weekday_last& mwdl, int y) noexcept;
  511. // 26.9, class template hh_mm_ss
  512. template <class Duration>
  513. class hh_mm_ss
  514. {
  515. bool is_neg; // exposition only
  516. chrono::hours h; // exposition only
  517. chrono::minutes m; // exposition only
  518. chrono::seconds s; // exposition only
  519. precision ss; // exposition only
  520. public:
  521. static unsigned constexpr fractional_width = see below;
  522. using precision = see below;
  523. constexpr hh_mm_ss() noexcept : hh_mm_ss{Duration::zero()} {}
  524. constexpr explicit hh_mm_ss(Duration d) noexcept;
  525. constexpr bool is_negative() const noexcept;
  526. constexpr chrono::hours hours() const noexcept;
  527. constexpr chrono::minutes minutes() const noexcept;
  528. constexpr chrono::seconds seconds() const noexcept;
  529. constexpr precision subseconds() const noexcept;
  530. constexpr explicit operator precision() const noexcept;
  531. constexpr precision to_duration() const noexcept;
  532. };
  533. // 26.10, 12/24 hour functions
  534. constexpr bool is_am(hours const& h) noexcept;
  535. constexpr bool is_pm(hours const& h) noexcept;
  536. constexpr hours make12(const hours& h) noexcept;
  537. constexpr hours make24(const hours& h, bool is_pm) noexcept;
  538. // 25.10.5, class time_zone // C++20
  539. enum class choose {earliest, latest};
  540. class time_zone;
  541. bool operator==(const time_zone& x, const time_zone& y) noexcept;
  542. bool operator!=(const time_zone& x, const time_zone& y) noexcept;
  543. bool operator<(const time_zone& x, const time_zone& y) noexcept;
  544. bool operator>(const time_zone& x, const time_zone& y) noexcept;
  545. bool operator<=(const time_zone& x, const time_zone& y) noexcept;
  546. bool operator>=(const time_zone& x, const time_zone& y) noexcept;
  547. // calendrical constants
  548. inline constexpr last_spec last{}; // C++20
  549. inline constexpr chrono::weekday Sunday{0}; // C++20
  550. inline constexpr chrono::weekday Monday{1}; // C++20
  551. inline constexpr chrono::weekday Tuesday{2}; // C++20
  552. inline constexpr chrono::weekday Wednesday{3}; // C++20
  553. inline constexpr chrono::weekday Thursday{4}; // C++20
  554. inline constexpr chrono::weekday Friday{5}; // C++20
  555. inline constexpr chrono::weekday Saturday{6}; // C++20
  556. inline constexpr chrono::month January{1}; // C++20
  557. inline constexpr chrono::month February{2}; // C++20
  558. inline constexpr chrono::month March{3}; // C++20
  559. inline constexpr chrono::month April{4}; // C++20
  560. inline constexpr chrono::month May{5}; // C++20
  561. inline constexpr chrono::month June{6}; // C++20
  562. inline constexpr chrono::month July{7}; // C++20
  563. inline constexpr chrono::month August{8}; // C++20
  564. inline constexpr chrono::month September{9}; // C++20
  565. inline constexpr chrono::month October{10}; // C++20
  566. inline constexpr chrono::month November{11}; // C++20
  567. inline constexpr chrono::month December{12}; // C++20
  568. } // chrono
  569. inline namespace literals {
  570. inline namespace chrono_literals {
  571. constexpr chrono::hours operator ""h(unsigned long long); // C++14
  572. constexpr chrono::duration<unspecified , ratio<3600,1>> operator ""h(long double); // C++14
  573. constexpr chrono::minutes operator ""min(unsigned long long); // C++14
  574. constexpr chrono::duration<unspecified , ratio<60,1>> operator ""min(long double); // C++14
  575. constexpr chrono::seconds operator ""s(unsigned long long); // C++14
  576. constexpr chrono::duration<unspecified > operator ""s(long double); // C++14
  577. constexpr chrono::milliseconds operator ""ms(unsigned long long); // C++14
  578. constexpr chrono::duration<unspecified , milli> operator ""ms(long double); // C++14
  579. constexpr chrono::microseconds operator ""us(unsigned long long); // C++14
  580. constexpr chrono::duration<unspecified , micro> operator ""us(long double); // C++14
  581. constexpr chrono::nanoseconds operator ""ns(unsigned long long); // C++14
  582. constexpr chrono::duration<unspecified , nano> operator ""ns(long double); // C++14
  583. constexpr chrono::day operator ""d(unsigned long long d) noexcept; // C++20
  584. constexpr chrono::year operator ""y(unsigned long long y) noexcept; // C++20
  585. } // chrono_literals
  586. } // literals
  587. } // std
  588. */
  589. #include <__chrono/calendar.h>
  590. #include <__chrono/convert_to_timespec.h>
  591. #include <__chrono/duration.h>
  592. #include <__chrono/file_clock.h>
  593. #include <__chrono/high_resolution_clock.h>
  594. #include <__chrono/steady_clock.h>
  595. #include <__chrono/system_clock.h>
  596. #include <__chrono/time_point.h>
  597. #include <__config>
  598. #include <compare>
  599. #include <version>
  600. #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
  601. # pragma GCC system_header
  602. #endif
  603. #endif // _LIBCPP_CHRONO