From Jason Turner

[time]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpqxkcd0_z/{from.md → to.md} +165 -59
tmp/tmpqxkcd0_z/{from.md → to.md} RENAMED
@@ -33,32 +33,32 @@ namespace chrono {
33
  template <class Rep> struct treat_as_floating_point;
34
  template <class Rep> struct duration_values;
35
 
36
  // [time.duration.nonmember], duration arithmetic
37
  template <class Rep1, class Period1, class Rep2, class Period2>
38
- typename common_type<duration<Rep1, Period1>, duration<Rep2, Period2>>::type
39
  constexpr operator+(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
40
  template <class Rep1, class Period1, class Rep2, class Period2>
41
- typename common_type<duration<Rep1, Period1>, duration<Rep2, Period2>>::type
42
  constexpr operator-(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
43
  template <class Rep1, class Period, class Rep2>
44
- duration<typename common_type<Rep1, Rep2>::type, Period>
45
  constexpr operator*(const duration<Rep1, Period>& d, const Rep2& s);
46
  template <class Rep1, class Rep2, class Period>
47
- duration<typename common_type<Rep1, Rep2>::type, Period>
48
  constexpr operator*(const Rep1& s, const duration<Rep2, Period>& d);
49
  template <class Rep1, class Period, class Rep2>
50
- duration<typename common_type<Rep1, Rep2>::type, Period>
51
  constexpr operator/(const duration<Rep1, Period>& d, const Rep2& s);
52
  template <class Rep1, class Period1, class Rep2, class Period2>
53
- typename common_type<Rep1, Rep2>::type
54
  constexpr operator/(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
55
  template <class Rep1, class Period, class Rep2>
56
- duration<typename common_type<Rep1, Rep2>::type, Period>
57
  constexpr operator%(const duration<Rep1, Period>& d, const Rep2& s);
58
  template <class Rep1, class Period1, class Rep2, class Period2>
59
- typename common_type<duration<Rep1, Period1>, duration<Rep2, Period2>>::type
60
  constexpr operator%(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
61
 
62
  // [time.duration.comparisons], duration comparisons
63
  template <class Rep1, class Period1, class Rep2, class Period2>
64
  constexpr bool operator==(const duration<Rep1, Period1>& lhs,
@@ -91,60 +91,87 @@ typedef duration<signed integer type of at least 35 bits > seconds;
91
  typedef duration<signed integer type of at least 29 bits, ratio< 60>> minutes;
92
  typedef duration<signed integer type of at least 23 bits, ratio<3600>> hours;
93
 
94
  // [time.point.nonmember], time_point arithmetic
95
  template <class Clock, class Duration1, class Rep2, class Period2>
96
- time_point<Clock, typename common_type<Duration1, duration<Rep2, Period2>>::type>
97
  operator+(const time_point<Clock, Duration1>& lhs, const duration<Rep2, Period2>& rhs);
98
  template <class Rep1, class Period1, class Clock, class Duration2>
99
- time_point<Clock, typename common_type<duration<Rep1, Period1>, Duration2>::type>
100
  operator+(const duration<Rep1, Period1>& lhs, const time_point<Clock, Duration2>& rhs);
101
  template <class Clock, class Duration1, class Rep2, class Period2>
102
- time_point<Clock, typename common_type<Duration1, duration<Rep2, Period2>>::type>
103
  operator-(const time_point<Clock, Duration1>& lhs, const duration<Rep2, Period2>& rhs);
104
  template <class Clock, class Duration1, class Duration2>
105
- typename common_type<Duration1, Duration2>::type
106
  operator-(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
107
 
108
  // [time.point.comparisons] time_point comparisons
109
  template <class Clock, class Duration1, class Duration2>
110
- bool operator==(const time_point<Clock, Duration1>& lhs,
111
  const time_point<Clock, Duration2>& rhs);
112
  template <class Clock, class Duration1, class Duration2>
113
- bool operator!=(const time_point<Clock, Duration1>& lhs,
114
  const time_point<Clock, Duration2>& rhs);
115
  template <class Clock, class Duration1, class Duration2>
116
- bool operator< (const time_point<Clock, Duration1>& lhs,
117
  const time_point<Clock, Duration2>& rhs);
118
  template <class Clock, class Duration1, class Duration2>
119
- bool operator<=(const time_point<Clock, Duration1>& lhs,
120
  const time_point<Clock, Duration2>& rhs);
121
  template <class Clock, class Duration1, class Duration2>
122
- bool operator> (const time_point<Clock, Duration1>& lhs,
123
  const time_point<Clock, Duration2>& rhs);
124
  template <class Clock, class Duration1, class Duration2>
125
- bool operator>=(const time_point<Clock, Duration1>& lhs,
126
  const time_point<Clock, Duration2>& rhs);
127
 
128
  // [time.point.cast], time_point_cast
129
-
130
  template <class ToDuration, class Clock, class Duration>
131
- time_point<Clock, ToDuration> time_point_cast(const time_point<Clock, Duration>& t);
 
132
 
133
  // [time.clock], clocks
134
  class system_clock;
135
  class steady_clock;
136
  class high_resolution_clock;
137
 
138
  } // namespace chrono
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
139
  } // namespace std
140
  ```
141
 
142
  ### Clock requirements <a id="time.clock.req">[[time.clock.req]]</a>
143
 
144
  A clock is a bundle consisting of a `duration`, a `time_point`, and a
145
- function `now()` to get the current time_point. The origin of the
146
  clock’s `time_point` is referred to as the clock’s *epoch*. A clock
147
  shall meet the requirements in Table  [[tab:time.clock]].
148
 
149
  In Table  [[tab:time.clock]] `C1` and `C2` denote clock types. `t1` and
150
  `t2` are values returned by `C1::now()` where the call returning `t1`
@@ -169,12 +196,12 @@ A type `TC` meets the `TrivialClock` requirements if:
169
  this means, in particular, that operations on these types will not
170
  throw exceptions.
171
  - lvalues of the types `TC::rep`, `TC::duration`, and `TC::time_point`
172
  are swappable ([[swappable.requirements]]),
173
  - the function `TC::now()` does not throw exceptions, and
174
- - the type `TC::time_point::clock` meets the TrivialClock requirements,
175
- recursively.
176
 
177
  ### Time-related traits <a id="time.traits">[[time.traits]]</a>
178
 
179
  #### `treat_as_floating_point` <a id="time.traits.is_fp">[[time.traits.is_fp]]</a>
180
 
@@ -242,11 +269,11 @@ The value returned shall compare greater than `zero()`.
242
  #### Specializations of `common_type` <a id="time.traits.specializations">[[time.traits.specializations]]</a>
243
 
244
  ``` cpp
245
  template <class Rep1, class Period1, class Rep2, class Period2>
246
  struct common_type<chrono::duration<Rep1, Period1>, chrono::duration<Rep2, Period2>> {
247
- typedef chrono::duration<typename common_type<Rep1, Rep2>::type, see below> type;
248
  };
249
  ```
250
 
251
  The `period` of the `duration` indicated by this specialization of
252
  `common_type` shall be the greatest common divisor of `Period1` and
@@ -262,11 +289,11 @@ this conversion with no truncation error, although floating-point
262
  durations may have round-off errors.
263
 
264
  ``` cpp
265
  template <class Clock, class Duration1, class Duration2>
266
  struct common_type<chrono::time_point<Clock, Duration1>, chrono::time_point<Clock, Duration2>> {
267
- typedef chrono::time_point<Clock, typename common_type<Duration1, Duration2>::type> type;
268
  };
269
  ```
270
 
271
  The common type of two `time_point` types is a `time_point` with the
272
  same clock as the two types and the common type of their two
@@ -337,10 +364,15 @@ is ill-formed.
337
  *Remarks:* If `Period::num` is not positive, the program is ill-formed.
338
 
339
  *Requires:* Members of `duration` shall not throw exceptions other than
340
  those thrown by the indicated operations on their representations.
341
 
 
 
 
 
 
342
  ``` cpp
343
  duration<long, ratio<60>> d0; // holds a count of minutes using a long
344
  duration<long long, milli> d1; // holds a count of milliseconds using a long long
345
  duration<double, ratio<1, 30>> d2; // holds a count with a tick period of $\frac{1}{30}$ of a second
346
  // (30 Hz) using a double
@@ -372,11 +404,12 @@ duration<int, milli> d(3.5); // error
372
  template <class Rep2, class Period2>
373
  constexpr duration(const duration<Rep2, Period2>& d);
374
  ```
375
 
376
  *Remarks:* This constructor shall not participate in overload resolution
377
- unless `treat_as_floating_point<rep>::value` is `true` or both
 
378
  `ratio_divide<Period2, period>::den` is `1` and
379
  `treat_as_floating_point<Rep2>::value` is `false`. This requirement
380
  prevents implicit truncation error when converting between
381
  integral-based `duration` types. Such a construction could easily lead
382
  to confusion about the value of the `duration`.
@@ -510,53 +543,53 @@ static constexpr duration max();
510
  *Returns:* `duration(duration_values<rep>::max())`.
511
 
512
  #### `duration` non-member arithmetic <a id="time.duration.nonmember">[[time.duration.nonmember]]</a>
513
 
514
  In the function descriptions that follow, `CD` represents the return
515
- type of the function. `CR(A,B)` represents `common_type<A, B>::type`.
516
 
517
  ``` cpp
518
  template <class Rep1, class Period1, class Rep2, class Period2>
519
- constexpr typename common_type<duration<Rep1, Period1>, duration<Rep2, Period2> >::type
520
  operator+(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
521
  ```
522
 
523
  *Returns:* CD(CD(lhs).count() + CD(rhs).count()).
524
 
525
  ``` cpp
526
  template <class Rep1, class Period1, class Rep2, class Period2>
527
- constexpr typename common_type<duration<Rep1, Period1>, duration<Rep2, Period2> >::type
528
  operator-(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
529
  ```
530
 
531
  *Returns:* CD(CD(lhs).count() - CD(rhs).count()).
532
 
533
  ``` cpp
534
  template <class Rep1, class Period, class Rep2>
535
- constexpr duration<typename common_type<Rep1, Rep2>::type, Period>
536
  operator*(const duration<Rep1, Period>& d, const Rep2& s);
537
  ```
538
 
539
  *Remarks:* This operator shall not participate in overload resolution
540
  unless `Rep2` is implicitly convertible to `CR(Rep1, Rep2)`.
541
 
542
  *Returns:* CD(CD(d).count() \* s).
543
 
544
  ``` cpp
545
  template <class Rep1, class Rep2, class Period>
546
- constexpr duration<typename common_type<Rep1, Rep2>::type, Period>
547
  operator*(const Rep1& s, const duration<Rep2, Period>& d);
548
  ```
549
 
550
  *Remarks:* This operator shall not participate in overload resolution
551
  unless `Rep1` is implicitly convertible to `CR(Rep1, Rep2)`.
552
 
553
  *Returns:* `d * s`.
554
 
555
  ``` cpp
556
  template <class Rep1, class Period, class Rep2>
557
- constexpr duration<typename common_type<Rep1, Rep2>::type, Period>
558
  operator/(const duration<Rep1, Period>& d, const Rep2& s);
559
  ```
560
 
561
  *Remarks:* This operator shall not participate in overload resolution
562
  unless `Rep2` is implicitly convertible to `CR(Rep1, Rep2)` and `Rep2`
@@ -564,19 +597,19 @@ is not an instantiation of `duration`.
564
 
565
  *Returns:* CD(CD(d).count() / s).
566
 
567
  ``` cpp
568
  template <class Rep1, class Period1, class Rep2, class Period2>
569
- constexpr typename common_type<Rep1, Rep2>::type
570
  operator/(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
571
  ```
572
 
573
  *Returns:* `CD(lhs).count() / CD(rhs).count()`.
574
 
575
  ``` cpp
576
  template <class Rep1, class Period, class Rep2>
577
- constexpr duration<typename common_type<Rep1, Rep2>::type, Period>
578
  operator%(const duration<Rep1, Period>& d, const Rep2& s);
579
  ```
580
 
581
  *Remarks:* This operator shall not participate in overload resolution
582
  unless `Rep2` is implicitly convertible to `CR(Rep1, Rep2)` and `Rep2`
@@ -584,20 +617,20 @@ is not an instantiation of `duration`.
584
 
585
  *Returns:* CD(CD(d).count() % s).
586
 
587
  ``` cpp
588
  template <class Rep1, class Period1, class Rep2, class Period2>
589
- constexpr typename common_type<duration<Rep1, Period1>, duration<Rep2, Period2>>::type
590
  operator%(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
591
  ```
592
 
593
  *Returns:* CD(CD(lhs).count() % CD(rhs).count()).
594
 
595
  #### `duration` comparisons <a id="time.duration.comparisons">[[time.duration.comparisons]]</a>
596
 
597
  In the function descriptions that follow, `CT` represents
598
- `common_type<A, B>::type`, where `A` and `B` are the types of the two
599
  arguments to the function.
600
 
601
  ``` cpp
602
  template <class Rep1, class Period1, class Rep2, class Period2>
603
  constexpr bool operator==(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
@@ -679,10 +712,81 @@ conversions are done with `static_cast`. It avoids multiplications and
679
  divisions when it is known at compile time that one or more arguments
680
  is 1. Intermediate computations are carried out in the widest
681
  representation and only converted to the destination representation at
682
  the final step.
683
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
684
  ### Class template `time_point` <a id="time.point">[[time.point]]</a>
685
 
686
  ``` cpp
687
  template <class Clock, class Duration = typename Clock::duration>
688
  class time_point {
@@ -694,17 +798,17 @@ public:
694
  private:
695
  duration d_; // exposition only
696
 
697
  public:
698
  // [time.point.cons], construct:
699
- time_point(); // has value epoch
700
- explicit time_point(const duration& d); // same as time_point() + d
701
  template <class Duration2>
702
- time_point(const time_point<clock, Duration2>& t);
703
 
704
  // [time.point.observer], observer:
705
- duration time_since_epoch() const;
706
 
707
  // [time.point.arithmetic], arithmetic:
708
  time_point& operator+=(const duration& d);
709
  time_point& operator-=(const duration& d);
710
 
@@ -720,27 +824,27 @@ If `Duration` is not an instance of `duration`, the program is
720
  ill-formed.
721
 
722
  #### `time_point` constructors <a id="time.point.cons">[[time.point.cons]]</a>
723
 
724
  ``` cpp
725
- time_point();
726
  ```
727
 
728
  *Effects:* Constructs an object of type `time_point`, initializing `d_`
729
  with `duration::zero()`. Such a `time_point` object represents the
730
  epoch.
731
 
732
  ``` cpp
733
- time_point(const duration& d);
734
  ```
735
 
736
  *Effects:* Constructs an object of type `time_point`, initializing `d_`
737
  with `d`. Such a `time_point` object represents the epoch `+ d`.
738
 
739
  ``` cpp
740
  template <class Duration2>
741
- time_point(const time_point<clock, Duration2>& t);
742
  ```
743
 
744
  *Remarks:* This constructor shall not participate in overload resolution
745
  unless `Duration2` is implicitly convertible to `duration`.
746
 
@@ -748,11 +852,11 @@ unless `Duration2` is implicitly convertible to `duration`.
748
  with `t.time_since_epoch()`.
749
 
750
  #### `time_point` observer <a id="time.point.observer">[[time.point.observer]]</a>
751
 
752
  ``` cpp
753
- duration time_since_epoch() const;
754
  ```
755
 
756
  *Returns:* `d_`.
757
 
758
  #### `time_point` arithmetic <a id="time.point.arithmetic">[[time.point.arithmetic]]</a>
@@ -789,89 +893,91 @@ static constexpr time_point max();
789
 
790
  #### `time_point` non-member arithmetic <a id="time.point.nonmember">[[time.point.nonmember]]</a>
791
 
792
  ``` cpp
793
  template <class Clock, class Duration1, class Rep2, class Period2>
794
- time_point<Clock, typename common_type<Duration1, duration<Rep2, Period2>>::type>
795
  operator+(const time_point<Clock, Duration1>& lhs, const duration<Rep2, Period2>& rhs);
796
  ```
797
 
798
- *Returns:* `CT(lhs) += rhs`, where `CT` is the type of the return value.
 
799
 
800
  ``` cpp
801
  template <class Rep1, class Period1, class Clock, class Duration2>
802
- time_point<Clock, typename common_type<duration<Rep1, Period1>, Duration2>::type>
803
  operator+(const duration<Rep1, Period1>& lhs, const time_point<Clock, Duration2>& rhs);
804
  ```
805
 
806
  *Returns:* `rhs + lhs`.
807
 
808
  ``` cpp
809
  template <class Clock, class Duration1, class Rep2, class Period2>
810
- time_point<Clock, typename common_type<Duration1, duration<Rep2, Period2>>::type>
811
  operator-(const time_point<Clock, Duration1>& lhs, const duration<Rep2, Period2>& rhs);
812
  ```
813
 
814
  *Returns:* `lhs + (-rhs)`.
815
 
816
  ``` cpp
817
  template <class Clock, class Duration1, class Duration2>
818
- typename common_type<Duration1, Duration2>::type
819
  operator-(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
820
  ```
821
 
822
  *Returns:* `lhs.time_since_epoch() - rhs.time_since_epoch()`.
823
 
824
  #### `time_point` comparisons <a id="time.point.comparisons">[[time.point.comparisons]]</a>
825
 
826
  ``` cpp
827
  template <class Clock, class Duration1, class Duration2>
828
- bool operator==(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
829
  ```
830
 
831
  *Returns:* `lhs.time_since_epoch() == rhs.time_since_epoch()`.
832
 
833
  ``` cpp
834
  template <class Clock, class Duration1, class Duration2>
835
- bool operator!=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
836
  ```
837
 
838
  *Returns:* `!(lhs == rhs)`.
839
 
840
  ``` cpp
841
  template <class Clock, class Duration1, class Duration2>
842
- bool operator<(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
843
  ```
844
 
845
  *Returns:* `lhs.time_since_epoch() < rhs.time_since_epoch()`.
846
 
847
  ``` cpp
848
  template <class Clock, class Duration1, class Duration2>
849
- bool operator<=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
850
  ```
851
 
852
  *Returns:* `!(rhs < lhs)`.
853
 
854
  ``` cpp
855
  template <class Clock, class Duration1, class Duration2>
856
- bool operator>(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
857
  ```
858
 
859
  *Returns:* `rhs < lhs`.
860
 
861
  ``` cpp
862
  template <class Clock, class Duration1, class Duration2>
863
- bool operator>=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
864
  ```
865
 
866
  *Returns:* `!(lhs < rhs)`.
867
 
868
  #### `time_point_cast` <a id="time.point.cast">[[time.point.cast]]</a>
869
 
870
  ``` cpp
871
  template <class ToDuration, class Clock, class Duration>
872
- time_point<Clock, ToDuration> time_point_cast(const time_point<Clock, Duration>& t);
 
873
  ```
874
 
875
  *Remarks:* This function shall not participate in overload resolution
876
  unless `ToDuration` is an instantiation of `duration`.
877
 
@@ -893,11 +999,11 @@ class system_clock {
893
  public:
894
  typedef see below rep;
895
  typedef ratio<unspecified, unspecified> period;
896
  typedef chrono::duration<rep, period> duration;
897
  typedef chrono::time_point<system_clock> time_point;
898
- static const bool is_steady = unspecified;
899
 
900
  static time_point now() noexcept;
901
 
902
  // Map to C API
903
  static time_t to_time_t (const time_point& t) noexcept;
@@ -943,11 +1049,11 @@ class steady_clock {
943
  public:
944
  typedef unspecified rep;
945
  typedef ratio<unspecified, unspecified> period;
946
  typedef chrono::duration<rep, period> duration;
947
  typedef chrono::time_point<unspecified, duration> time_point;
948
- static const bool is_steady = true;
949
 
950
  static time_point now() noexcept;
951
  };
952
  ```
953
 
@@ -962,11 +1068,11 @@ class high_resolution_clock {
962
  public:
963
  typedef unspecified rep;
964
  typedef ratio<unspecified, unspecified> period;
965
  typedef chrono::duration<rep, period> duration;
966
  typedef chrono::time_point<unspecified, duration> time_point;
967
- static const bool is_steady = unspecified;
968
 
969
  static time_point now() noexcept;
970
  };
971
  ```
972
 
 
33
  template <class Rep> struct treat_as_floating_point;
34
  template <class Rep> struct duration_values;
35
 
36
  // [time.duration.nonmember], duration arithmetic
37
  template <class Rep1, class Period1, class Rep2, class Period2>
38
+ common_type_t<duration<Rep1, Period1>, duration<Rep2, Period2>>
39
  constexpr operator+(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
40
  template <class Rep1, class Period1, class Rep2, class Period2>
41
+ common_type_t<duration<Rep1, Period1>, duration<Rep2, Period2>>
42
  constexpr operator-(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
43
  template <class Rep1, class Period, class Rep2>
44
+ duration<common_type_t<Rep1, Rep2>, Period>
45
  constexpr operator*(const duration<Rep1, Period>& d, const Rep2& s);
46
  template <class Rep1, class Rep2, class Period>
47
+ duration<common_type_t<Rep1, Rep2>, Period>
48
  constexpr operator*(const Rep1& s, const duration<Rep2, Period>& d);
49
  template <class Rep1, class Period, class Rep2>
50
+ duration<common_type_t<Rep1, Rep2>, Period>
51
  constexpr operator/(const duration<Rep1, Period>& d, const Rep2& s);
52
  template <class Rep1, class Period1, class Rep2, class Period2>
53
+ common_type_t<Rep1, Rep2>
54
  constexpr operator/(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
55
  template <class Rep1, class Period, class Rep2>
56
+ duration<common_type_t<Rep1, Rep2>, Period>
57
  constexpr operator%(const duration<Rep1, Period>& d, const Rep2& s);
58
  template <class Rep1, class Period1, class Rep2, class Period2>
59
+ common_type_t<duration<Rep1, Period1>, duration<Rep2, Period2>>
60
  constexpr operator%(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
61
 
62
  // [time.duration.comparisons], duration comparisons
63
  template <class Rep1, class Period1, class Rep2, class Period2>
64
  constexpr bool operator==(const duration<Rep1, Period1>& lhs,
 
91
  typedef duration<signed integer type of at least 29 bits, ratio< 60>> minutes;
92
  typedef duration<signed integer type of at least 23 bits, ratio<3600>> hours;
93
 
94
  // [time.point.nonmember], time_point arithmetic
95
  template <class Clock, class Duration1, class Rep2, class Period2>
96
+ constexpr time_point<Clock, common_type_t<Duration1, duration<Rep2, Period2>>>
97
  operator+(const time_point<Clock, Duration1>& lhs, const duration<Rep2, Period2>& rhs);
98
  template <class Rep1, class Period1, class Clock, class Duration2>
99
+ constexpr time_point<Clock, common_type_t<duration<Rep1, Period1>, Duration2>>
100
  operator+(const duration<Rep1, Period1>& lhs, const time_point<Clock, Duration2>& rhs);
101
  template <class Clock, class Duration1, class Rep2, class Period2>
102
+ constexpr time_point<Clock, common_type_t<Duration1, duration<Rep2, Period2>>>
103
  operator-(const time_point<Clock, Duration1>& lhs, const duration<Rep2, Period2>& rhs);
104
  template <class Clock, class Duration1, class Duration2>
105
+ constexpr common_type_t<Duration1, Duration2>
106
  operator-(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
107
 
108
  // [time.point.comparisons] time_point comparisons
109
  template <class Clock, class Duration1, class Duration2>
110
+ constexpr bool operator==(const time_point<Clock, Duration1>& lhs,
111
  const time_point<Clock, Duration2>& rhs);
112
  template <class Clock, class Duration1, class Duration2>
113
+ constexpr bool operator!=(const time_point<Clock, Duration1>& lhs,
114
  const time_point<Clock, Duration2>& rhs);
115
  template <class Clock, class Duration1, class Duration2>
116
+ constexpr bool operator< (const time_point<Clock, Duration1>& lhs,
117
  const time_point<Clock, Duration2>& rhs);
118
  template <class Clock, class Duration1, class Duration2>
119
+ constexpr bool operator<=(const time_point<Clock, Duration1>& lhs,
120
  const time_point<Clock, Duration2>& rhs);
121
  template <class Clock, class Duration1, class Duration2>
122
+ constexpr bool operator> (const time_point<Clock, Duration1>& lhs,
123
  const time_point<Clock, Duration2>& rhs);
124
  template <class Clock, class Duration1, class Duration2>
125
+ constexpr bool operator>=(const time_point<Clock, Duration1>& lhs,
126
  const time_point<Clock, Duration2>& rhs);
127
 
128
  // [time.point.cast], time_point_cast
 
129
  template <class ToDuration, class Clock, class Duration>
130
+ constexpr time_point<Clock, ToDuration>
131
+ time_point_cast(const time_point<Clock, Duration>& t);
132
 
133
  // [time.clock], clocks
134
  class system_clock;
135
  class steady_clock;
136
  class high_resolution_clock;
137
 
138
  } // namespace chrono
139
+
140
+ inline namespace literals {
141
+ inline namespace chrono_literals {
142
+
143
+ // ~[time.duration.literals], suffixes for duration literals
144
+ constexpr chrono::hours operator "" h(unsigned long long);
145
+ constexpr chrono::duration<unspecified, ratio<3600,1>> operator "" h(long double);
146
+ constexpr chrono::minutes operator "" min(unsigned long long);
147
+ constexpr chrono::duration<unspecified, ratio<60,1>> operator "" min(long double);
148
+ constexpr chrono::seconds operator "" s(unsigned long long);
149
+ constexpr chrono::duration<unspecified> operator "" s(long double);
150
+ constexpr chrono::milliseconds operator "" ms(unsigned long long);
151
+ constexpr chrono::duration<unspecified, milli> operator "" ms(long double);
152
+ constexpr chrono::microseconds operator "" us(unsigned long long);
153
+ constexpr chrono::duration<unspecified, micro> operator "" us(long double);
154
+ constexpr chrono::nanoseconds operator "" ns(unsigned long long);
155
+ constexpr chrono::duration<unspecified, nano> operator "" ns(long double);
156
+
157
+ } // namespace chrono_literals
158
+ } // namespace literals
159
+
160
+ namespace chrono {
161
+
162
+ using namespace literals::chrono_literals;
163
+
164
+ } // namespace chrono
165
+
166
  } // namespace std
167
  ```
168
 
169
  ### Clock requirements <a id="time.clock.req">[[time.clock.req]]</a>
170
 
171
  A clock is a bundle consisting of a `duration`, a `time_point`, and a
172
+ function `now()` to get the current `time_point`. The origin of the
173
  clock’s `time_point` is referred to as the clock’s *epoch*. A clock
174
  shall meet the requirements in Table  [[tab:time.clock]].
175
 
176
  In Table  [[tab:time.clock]] `C1` and `C2` denote clock types. `t1` and
177
  `t2` are values returned by `C1::now()` where the call returning `t1`
 
196
  this means, in particular, that operations on these types will not
197
  throw exceptions.
198
  - lvalues of the types `TC::rep`, `TC::duration`, and `TC::time_point`
199
  are swappable ([[swappable.requirements]]),
200
  - the function `TC::now()` does not throw exceptions, and
201
+ - the type `TC::time_point::clock` meets the `TrivialClock`
202
+ requirements, recursively.
203
 
204
  ### Time-related traits <a id="time.traits">[[time.traits]]</a>
205
 
206
  #### `treat_as_floating_point` <a id="time.traits.is_fp">[[time.traits.is_fp]]</a>
207
 
 
269
  #### Specializations of `common_type` <a id="time.traits.specializations">[[time.traits.specializations]]</a>
270
 
271
  ``` cpp
272
  template <class Rep1, class Period1, class Rep2, class Period2>
273
  struct common_type<chrono::duration<Rep1, Period1>, chrono::duration<Rep2, Period2>> {
274
+ typedef chrono::duration<common_type_t<Rep1, Rep2>, see below> type;
275
  };
276
  ```
277
 
278
  The `period` of the `duration` indicated by this specialization of
279
  `common_type` shall be the greatest common divisor of `Period1` and
 
289
  durations may have round-off errors.
290
 
291
  ``` cpp
292
  template <class Clock, class Duration1, class Duration2>
293
  struct common_type<chrono::time_point<Clock, Duration1>, chrono::time_point<Clock, Duration2>> {
294
+ typedef chrono::time_point<Clock, common_type_t<Duration1, Duration2>> type;
295
  };
296
  ```
297
 
298
  The common type of two `time_point` types is a `time_point` with the
299
  same clock as the two types and the common type of their two
 
364
  *Remarks:* If `Period::num` is not positive, the program is ill-formed.
365
 
366
  *Requires:* Members of `duration` shall not throw exceptions other than
367
  those thrown by the indicated operations on their representations.
368
 
369
+ *Remarks:* The defaulted copy constructor of duration shall be a
370
+ `constexpr` function if and only if the required initialization of the
371
+ member `rep_` for copy and move, respectively, would satisfy the
372
+ requirements for a `constexpr` function.
373
+
374
  ``` cpp
375
  duration<long, ratio<60>> d0; // holds a count of minutes using a long
376
  duration<long long, milli> d1; // holds a count of milliseconds using a long long
377
  duration<double, ratio<1, 30>> d2; // holds a count with a tick period of $\frac{1}{30}$ of a second
378
  // (30 Hz) using a double
 
404
  template <class Rep2, class Period2>
405
  constexpr duration(const duration<Rep2, Period2>& d);
406
  ```
407
 
408
  *Remarks:* This constructor shall not participate in overload resolution
409
+ unless no overflow is induced in the conversion and
410
+ `treat_as_floating_point<rep>::value` is `true` or both
411
  `ratio_divide<Period2, period>::den` is `1` and
412
  `treat_as_floating_point<Rep2>::value` is `false`. This requirement
413
  prevents implicit truncation error when converting between
414
  integral-based `duration` types. Such a construction could easily lead
415
  to confusion about the value of the `duration`.
 
543
  *Returns:* `duration(duration_values<rep>::max())`.
544
 
545
  #### `duration` non-member arithmetic <a id="time.duration.nonmember">[[time.duration.nonmember]]</a>
546
 
547
  In the function descriptions that follow, `CD` represents the return
548
+ type of the function. `CR(A,B)` represents `common_type_t<A, B>`.
549
 
550
  ``` cpp
551
  template <class Rep1, class Period1, class Rep2, class Period2>
552
+ constexpr common_type_t<duration<Rep1, Period1>, duration<Rep2, Period2>>
553
  operator+(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
554
  ```
555
 
556
  *Returns:* CD(CD(lhs).count() + CD(rhs).count()).
557
 
558
  ``` cpp
559
  template <class Rep1, class Period1, class Rep2, class Period2>
560
+ constexpr common_type_t<duration<Rep1, Period1>, duration<Rep2, Period2>>
561
  operator-(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
562
  ```
563
 
564
  *Returns:* CD(CD(lhs).count() - CD(rhs).count()).
565
 
566
  ``` cpp
567
  template <class Rep1, class Period, class Rep2>
568
+ constexpr duration<common_type_t<Rep1, Rep2>, Period>
569
  operator*(const duration<Rep1, Period>& d, const Rep2& s);
570
  ```
571
 
572
  *Remarks:* This operator shall not participate in overload resolution
573
  unless `Rep2` is implicitly convertible to `CR(Rep1, Rep2)`.
574
 
575
  *Returns:* CD(CD(d).count() \* s).
576
 
577
  ``` cpp
578
  template <class Rep1, class Rep2, class Period>
579
+ constexpr duration<common_type_t<Rep1, Rep2>, Period>
580
  operator*(const Rep1& s, const duration<Rep2, Period>& d);
581
  ```
582
 
583
  *Remarks:* This operator shall not participate in overload resolution
584
  unless `Rep1` is implicitly convertible to `CR(Rep1, Rep2)`.
585
 
586
  *Returns:* `d * s`.
587
 
588
  ``` cpp
589
  template <class Rep1, class Period, class Rep2>
590
+ constexpr duration<common_type_t<Rep1, Rep2>, Period>
591
  operator/(const duration<Rep1, Period>& d, const Rep2& s);
592
  ```
593
 
594
  *Remarks:* This operator shall not participate in overload resolution
595
  unless `Rep2` is implicitly convertible to `CR(Rep1, Rep2)` and `Rep2`
 
597
 
598
  *Returns:* CD(CD(d).count() / s).
599
 
600
  ``` cpp
601
  template <class Rep1, class Period1, class Rep2, class Period2>
602
+ constexpr common_type_t<Rep1, Rep2>
603
  operator/(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
604
  ```
605
 
606
  *Returns:* `CD(lhs).count() / CD(rhs).count()`.
607
 
608
  ``` cpp
609
  template <class Rep1, class Period, class Rep2>
610
+ constexpr duration<common_type_t<Rep1, Rep2>, Period>
611
  operator%(const duration<Rep1, Period>& d, const Rep2& s);
612
  ```
613
 
614
  *Remarks:* This operator shall not participate in overload resolution
615
  unless `Rep2` is implicitly convertible to `CR(Rep1, Rep2)` and `Rep2`
 
617
 
618
  *Returns:* CD(CD(d).count() % s).
619
 
620
  ``` cpp
621
  template <class Rep1, class Period1, class Rep2, class Period2>
622
+ constexpr common_type_t<duration<Rep1, Period1>, duration<Rep2, Period2>>
623
  operator%(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
624
  ```
625
 
626
  *Returns:* CD(CD(lhs).count() % CD(rhs).count()).
627
 
628
  #### `duration` comparisons <a id="time.duration.comparisons">[[time.duration.comparisons]]</a>
629
 
630
  In the function descriptions that follow, `CT` represents
631
+ `common_type_t<A, B>`, where `A` and `B` are the types of the two
632
  arguments to the function.
633
 
634
  ``` cpp
635
  template <class Rep1, class Period1, class Rep2, class Period2>
636
  constexpr bool operator==(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
 
712
  divisions when it is known at compile time that one or more arguments
713
  is 1. Intermediate computations are carried out in the widest
714
  representation and only converted to the destination representation at
715
  the final step.
716
 
717
+ #### Suffixes for duration literals <a id="time.duration.literals">[[time.duration.literals]]</a>
718
+
719
+ This section describes literal suffixes for constructing duration
720
+ literals. The suffixes `h`, `min`, `s`, `ms`, `us`, `ns` denote duration
721
+ values of the corresponding types `hours`, `minutes`, `seconds`,
722
+ `milliseconds`, `microseconds`, and `nanoseconds` respectively if they
723
+ are applied to integral literals.
724
+
725
+ If any of these suffixes are applied to a floating point literal the
726
+ result is a `chrono::duration` literal with an unspecified floating
727
+ point representation.
728
+
729
+ If any of these suffixes are applied to an integer literal and the
730
+ resulting `chrono::duration` value cannot be represented in the result
731
+ type because of overflow, the program is ill-formed.
732
+
733
+ The following code shows some duration literals.
734
+
735
+ ``` cpp
736
+ using namespace std::chrono_literals;
737
+ auto constexpr aday=24h;
738
+ auto constexpr lesson=45min;
739
+ auto constexpr halfanhour=0.5h;
740
+ ```
741
+
742
+ ``` cpp
743
+ constexpr chrono::hours operator "" h(unsigned long long hours);
744
+ constexpr chrono::duration<unspecified, ratio<3600,1>> operator "" h(long double hours);
745
+ ```
746
+
747
+ *Returns:* A `duration` literal representing `hours` hours.
748
+
749
+ ``` cpp
750
+ constexpr chrono::minutes operator "" min(unsigned long long minutes);
751
+ constexpr chrono::duration<unspecified, ratio<60,1>> operator "" min(long double minutes);
752
+ ```
753
+
754
+ *Returns:* A `duration` literal representing `minutes` minutes.
755
+
756
+ ``` cpp
757
+ constexpr chrono::seconds operator "" s(unsigned long long sec);
758
+ constexpr chrono::duration<unspecified> operator "" s(long double sec);
759
+ ```
760
+
761
+ *Returns:* A `duration` literal representing `sec` seconds.
762
+
763
+ The same suffix `s` is used for `basic_string` but there is no conflict,
764
+ since duration suffixes apply to numbers and string literal suffixes
765
+ apply to character array literals.
766
+
767
+ ``` cpp
768
+ constexpr chrono::milliseconds operator "" ms(unsigned long long msec);
769
+ constexpr chrono::duration<unspecified, milli> operator "" ms(long double msec);
770
+ ```
771
+
772
+ *Returns:* A `duration` literal representing `msec` milliseconds.
773
+
774
+ ``` cpp
775
+ constexpr chrono::microseconds operator "" us(unsigned long long usec);
776
+ constexpr chrono::duration<unspecified, micro> operator "" us(long double usec);
777
+ ```
778
+
779
+ *Returns:* A `duration` literal representing `usec` microseconds.
780
+
781
+ ``` cpp
782
+ constexpr chrono::nanoseconds operator "" ns(unsigned long long nsec);
783
+ constexpr chrono::duration<unspecified, nano> operator "" ns(long double nsec);
784
+ ```
785
+
786
+ *Returns:* A `duration` literal representing `nsec` nanoseconds.
787
+
788
  ### Class template `time_point` <a id="time.point">[[time.point]]</a>
789
 
790
  ``` cpp
791
  template <class Clock, class Duration = typename Clock::duration>
792
  class time_point {
 
798
  private:
799
  duration d_; // exposition only
800
 
801
  public:
802
  // [time.point.cons], construct:
803
+ constexpr time_point(); // has value epoch
804
+ constexpr explicit time_point(const duration& d); // same as time_point() + d
805
  template <class Duration2>
806
+ constexpr time_point(const time_point<clock, Duration2>& t);
807
 
808
  // [time.point.observer], observer:
809
+ constexpr duration time_since_epoch() const;
810
 
811
  // [time.point.arithmetic], arithmetic:
812
  time_point& operator+=(const duration& d);
813
  time_point& operator-=(const duration& d);
814
 
 
824
  ill-formed.
825
 
826
  #### `time_point` constructors <a id="time.point.cons">[[time.point.cons]]</a>
827
 
828
  ``` cpp
829
+ constexpr time_point();
830
  ```
831
 
832
  *Effects:* Constructs an object of type `time_point`, initializing `d_`
833
  with `duration::zero()`. Such a `time_point` object represents the
834
  epoch.
835
 
836
  ``` cpp
837
+ constexpr explicit time_point(const duration& d);
838
  ```
839
 
840
  *Effects:* Constructs an object of type `time_point`, initializing `d_`
841
  with `d`. Such a `time_point` object represents the epoch `+ d`.
842
 
843
  ``` cpp
844
  template <class Duration2>
845
+ constexpr time_point(const time_point<clock, Duration2>& t);
846
  ```
847
 
848
  *Remarks:* This constructor shall not participate in overload resolution
849
  unless `Duration2` is implicitly convertible to `duration`.
850
 
 
852
  with `t.time_since_epoch()`.
853
 
854
  #### `time_point` observer <a id="time.point.observer">[[time.point.observer]]</a>
855
 
856
  ``` cpp
857
+ constexpr duration time_since_epoch() const;
858
  ```
859
 
860
  *Returns:* `d_`.
861
 
862
  #### `time_point` arithmetic <a id="time.point.arithmetic">[[time.point.arithmetic]]</a>
 
893
 
894
  #### `time_point` non-member arithmetic <a id="time.point.nonmember">[[time.point.nonmember]]</a>
895
 
896
  ``` cpp
897
  template <class Clock, class Duration1, class Rep2, class Period2>
898
+ constexpr time_point<Clock, common_type_t<Duration1, duration<Rep2, Period2>>>
899
  operator+(const time_point<Clock, Duration1>& lhs, const duration<Rep2, Period2>& rhs);
900
  ```
901
 
902
+ *Returns:* `CT(lhs.time_since_epoch() + rhs)`, where `CT` is the type of
903
+ the return value.
904
 
905
  ``` cpp
906
  template <class Rep1, class Period1, class Clock, class Duration2>
907
+ constexpr time_point<Clock, common_type_t<duration<Rep1, Period1>, Duration2>>
908
  operator+(const duration<Rep1, Period1>& lhs, const time_point<Clock, Duration2>& rhs);
909
  ```
910
 
911
  *Returns:* `rhs + lhs`.
912
 
913
  ``` cpp
914
  template <class Clock, class Duration1, class Rep2, class Period2>
915
+ constexpr time_point<Clock, common_type_t<Duration1, duration<Rep2, Period2>>>
916
  operator-(const time_point<Clock, Duration1>& lhs, const duration<Rep2, Period2>& rhs);
917
  ```
918
 
919
  *Returns:* `lhs + (-rhs)`.
920
 
921
  ``` cpp
922
  template <class Clock, class Duration1, class Duration2>
923
+ constexpr common_type_t<Duration1, Duration2>
924
  operator-(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
925
  ```
926
 
927
  *Returns:* `lhs.time_since_epoch() - rhs.time_since_epoch()`.
928
 
929
  #### `time_point` comparisons <a id="time.point.comparisons">[[time.point.comparisons]]</a>
930
 
931
  ``` cpp
932
  template <class Clock, class Duration1, class Duration2>
933
+ constexpr bool operator==(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
934
  ```
935
 
936
  *Returns:* `lhs.time_since_epoch() == rhs.time_since_epoch()`.
937
 
938
  ``` cpp
939
  template <class Clock, class Duration1, class Duration2>
940
+ constexpr bool operator!=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
941
  ```
942
 
943
  *Returns:* `!(lhs == rhs)`.
944
 
945
  ``` cpp
946
  template <class Clock, class Duration1, class Duration2>
947
+ constexpr bool operator<(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
948
  ```
949
 
950
  *Returns:* `lhs.time_since_epoch() < rhs.time_since_epoch()`.
951
 
952
  ``` cpp
953
  template <class Clock, class Duration1, class Duration2>
954
+ constexpr bool operator<=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
955
  ```
956
 
957
  *Returns:* `!(rhs < lhs)`.
958
 
959
  ``` cpp
960
  template <class Clock, class Duration1, class Duration2>
961
+ constexpr bool operator>(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
962
  ```
963
 
964
  *Returns:* `rhs < lhs`.
965
 
966
  ``` cpp
967
  template <class Clock, class Duration1, class Duration2>
968
+ constexpr bool operator>=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
969
  ```
970
 
971
  *Returns:* `!(lhs < rhs)`.
972
 
973
  #### `time_point_cast` <a id="time.point.cast">[[time.point.cast]]</a>
974
 
975
  ``` cpp
976
  template <class ToDuration, class Clock, class Duration>
977
+ constexpr time_point<Clock, ToDuration>
978
+ time_point_cast(const time_point<Clock, Duration>& t);
979
  ```
980
 
981
  *Remarks:* This function shall not participate in overload resolution
982
  unless `ToDuration` is an instantiation of `duration`.
983
 
 
999
  public:
1000
  typedef see below rep;
1001
  typedef ratio<unspecified, unspecified> period;
1002
  typedef chrono::duration<rep, period> duration;
1003
  typedef chrono::time_point<system_clock> time_point;
1004
+ static constexpr bool is_steady = unspecified;
1005
 
1006
  static time_point now() noexcept;
1007
 
1008
  // Map to C API
1009
  static time_t to_time_t (const time_point& t) noexcept;
 
1049
  public:
1050
  typedef unspecified rep;
1051
  typedef ratio<unspecified, unspecified> period;
1052
  typedef chrono::duration<rep, period> duration;
1053
  typedef chrono::time_point<unspecified, duration> time_point;
1054
+ static constexpr bool is_steady = true;
1055
 
1056
  static time_point now() noexcept;
1057
  };
1058
  ```
1059
 
 
1068
  public:
1069
  typedef unspecified rep;
1070
  typedef ratio<unspecified, unspecified> period;
1071
  typedef chrono::duration<rep, period> duration;
1072
  typedef chrono::time_point<unspecified, duration> time_point;
1073
+ static constexpr bool is_steady = unspecified;
1074
 
1075
  static time_point now() noexcept;
1076
  };
1077
  ```
1078