From Jason Turner

[time.duration.literals]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpi_6zo5vi/{from.md → to.md} +71 -0
tmp/tmpi_6zo5vi/{from.md → to.md} RENAMED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #### Suffixes for duration literals <a id="time.duration.literals">[[time.duration.literals]]</a>
2
+
3
+ This section describes literal suffixes for constructing duration
4
+ literals. The suffixes `h`, `min`, `s`, `ms`, `us`, `ns` denote duration
5
+ values of the corresponding types `hours`, `minutes`, `seconds`,
6
+ `milliseconds`, `microseconds`, and `nanoseconds` respectively if they
7
+ are applied to integral literals.
8
+
9
+ If any of these suffixes are applied to a floating point literal the
10
+ result is a `chrono::duration` literal with an unspecified floating
11
+ point representation.
12
+
13
+ If any of these suffixes are applied to an integer literal and the
14
+ resulting `chrono::duration` value cannot be represented in the result
15
+ type because of overflow, the program is ill-formed.
16
+
17
+ The following code shows some duration literals.
18
+
19
+ ``` cpp
20
+ using namespace std::chrono_literals;
21
+ auto constexpr aday=24h;
22
+ auto constexpr lesson=45min;
23
+ auto constexpr halfanhour=0.5h;
24
+ ```
25
+
26
+ ``` cpp
27
+ constexpr chrono::hours operator "" h(unsigned long long hours);
28
+ constexpr chrono::duration<unspecified, ratio<3600,1>> operator "" h(long double hours);
29
+ ```
30
+
31
+ *Returns:* A `duration` literal representing `hours` hours.
32
+
33
+ ``` cpp
34
+ constexpr chrono::minutes operator "" min(unsigned long long minutes);
35
+ constexpr chrono::duration<unspecified, ratio<60,1>> operator "" min(long double minutes);
36
+ ```
37
+
38
+ *Returns:* A `duration` literal representing `minutes` minutes.
39
+
40
+ ``` cpp
41
+ constexpr chrono::seconds operator "" s(unsigned long long sec);
42
+ constexpr chrono::duration<unspecified> operator "" s(long double sec);
43
+ ```
44
+
45
+ *Returns:* A `duration` literal representing `sec` seconds.
46
+
47
+ The same suffix `s` is used for `basic_string` but there is no conflict,
48
+ since duration suffixes apply to numbers and string literal suffixes
49
+ apply to character array literals.
50
+
51
+ ``` cpp
52
+ constexpr chrono::milliseconds operator "" ms(unsigned long long msec);
53
+ constexpr chrono::duration<unspecified, milli> operator "" ms(long double msec);
54
+ ```
55
+
56
+ *Returns:* A `duration` literal representing `msec` milliseconds.
57
+
58
+ ``` cpp
59
+ constexpr chrono::microseconds operator "" us(unsigned long long usec);
60
+ constexpr chrono::duration<unspecified, micro> operator "" us(long double usec);
61
+ ```
62
+
63
+ *Returns:* A `duration` literal representing `usec` microseconds.
64
+
65
+ ``` cpp
66
+ constexpr chrono::nanoseconds operator "" ns(unsigned long long nsec);
67
+ constexpr chrono::duration<unspecified, nano> operator "" ns(long double nsec);
68
+ ```
69
+
70
+ *Returns:* A `duration` literal representing `nsec` nanoseconds.
71
+