tmp/tmphb6dvunl/{from.md → to.md}
RENAMED
|
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
### General <a id="time.duration.general">[[time.duration.general]]</a>
|
| 2 |
+
|
| 3 |
+
A `duration` type measures time between two points in time
|
| 4 |
+
(`time_point`s). A `duration` has a representation which holds a count
|
| 5 |
+
of ticks and a tick period. The tick period is the amount of time which
|
| 6 |
+
occurs from one tick to the next, in units of seconds. It is expressed
|
| 7 |
+
as a rational constant using the template `ratio`.
|
| 8 |
+
|
| 9 |
+
``` cpp
|
| 10 |
+
namespace std::chrono {
|
| 11 |
+
template<class Rep, class Period = ratio<1>>
|
| 12 |
+
class duration {
|
| 13 |
+
public:
|
| 14 |
+
using rep = Rep;
|
| 15 |
+
using period = typename Period::type;
|
| 16 |
+
|
| 17 |
+
private:
|
| 18 |
+
rep rep_; // exposition only
|
| 19 |
+
|
| 20 |
+
public:
|
| 21 |
+
// [time.duration.cons], construct/copy/destroy
|
| 22 |
+
constexpr duration() = default;
|
| 23 |
+
template<class Rep2>
|
| 24 |
+
constexpr explicit duration(const Rep2& r);
|
| 25 |
+
template<class Rep2, class Period2>
|
| 26 |
+
constexpr duration(const duration<Rep2, Period2>& d);
|
| 27 |
+
~duration() = default;
|
| 28 |
+
duration(const duration&) = default;
|
| 29 |
+
duration& operator=(const duration&) = default;
|
| 30 |
+
|
| 31 |
+
// [time.duration.observer], observer
|
| 32 |
+
constexpr rep count() const;
|
| 33 |
+
|
| 34 |
+
// [time.duration.arithmetic], arithmetic
|
| 35 |
+
constexpr common_type_t<duration> operator+() const;
|
| 36 |
+
constexpr common_type_t<duration> operator-() const;
|
| 37 |
+
constexpr duration& operator++();
|
| 38 |
+
constexpr duration operator++(int);
|
| 39 |
+
constexpr duration& operator--();
|
| 40 |
+
constexpr duration operator--(int);
|
| 41 |
+
|
| 42 |
+
constexpr duration& operator+=(const duration& d);
|
| 43 |
+
constexpr duration& operator-=(const duration& d);
|
| 44 |
+
|
| 45 |
+
constexpr duration& operator*=(const rep& rhs);
|
| 46 |
+
constexpr duration& operator/=(const rep& rhs);
|
| 47 |
+
constexpr duration& operator%=(const rep& rhs);
|
| 48 |
+
constexpr duration& operator%=(const duration& rhs);
|
| 49 |
+
|
| 50 |
+
// [time.duration.special], special values
|
| 51 |
+
static constexpr duration zero() noexcept;
|
| 52 |
+
static constexpr duration min() noexcept;
|
| 53 |
+
static constexpr duration max() noexcept;
|
| 54 |
+
};
|
| 55 |
+
}
|
| 56 |
+
```
|
| 57 |
+
|
| 58 |
+
`Rep` shall be an arithmetic type or a class emulating an arithmetic
|
| 59 |
+
type. If `duration` is instantiated with a `duration` type as the
|
| 60 |
+
argument for the template parameter `Rep`, the program is ill-formed.
|
| 61 |
+
|
| 62 |
+
If `Period` is not a specialization of `ratio`, the program is
|
| 63 |
+
ill-formed. If `Period::num` is not positive, the program is ill-formed.
|
| 64 |
+
|
| 65 |
+
Members of `duration` do not throw exceptions other than those thrown by
|
| 66 |
+
the indicated operations on their representations.
|
| 67 |
+
|
| 68 |
+
The defaulted copy constructor of duration shall be a constexpr function
|
| 69 |
+
if and only if the required initialization of the member `rep_` for copy
|
| 70 |
+
and move, respectively, would be constexpr-suitable [[dcl.constexpr]].
|
| 71 |
+
|
| 72 |
+
[*Example 1*:
|
| 73 |
+
|
| 74 |
+
``` cpp
|
| 75 |
+
duration<long, ratio<60>> d0; // holds a count of minutes using a long
|
| 76 |
+
duration<long long, milli> d1; // holds a count of milliseconds using a long long
|
| 77 |
+
duration<double, ratio<1, 30>> d2; // holds a count with a tick period of $\frac{1}{30}$ of a second
|
| 78 |
+
// (30 Hz) using a double
|
| 79 |
+
```
|
| 80 |
+
|
| 81 |
+
— *end example*]
|
| 82 |
+
|