Init
This commit is contained in:
403
cppdraft/time/point.md
Normal file
403
cppdraft/time/point.md
Normal file
@@ -0,0 +1,403 @@
|
||||
[time.point]
|
||||
|
||||
# 30 Time library [[time]](./#time)
|
||||
|
||||
## 30.6 Class template time_point [time.point]
|
||||
|
||||
### [30.6.1](#general) General [[time.point.general]](time.point.general)
|
||||
|
||||
[ð](#lib:time_point)
|
||||
|
||||
namespace std::chrono {template<class Clock, class Duration = typename Clock::duration>class time_point {public:using clock = Clock; using duration = Duration; using rep = typename duration::rep; using period = typename duration::period; private: duration d_; // *exposition only*public:// [[time.point.cons]](#cons "30.6.2 Constructors"), constructconstexpr time_point(); // has value epochconstexpr explicit time_point(const duration& d); // same as time_point() + dtemplate<class Duration2>constexpr time_point(const time_point<clock, Duration2>& t); // [[time.point.observer]](#observer "30.6.3 Observer"), observerconstexpr duration time_since_epoch() const; // [[time.point.arithmetic]](#arithmetic "30.6.4 Arithmetic"), arithmeticconstexpr time_point& operator++(); constexpr time_point operator++(int); constexpr time_point& operator--(); constexpr time_point operator--(int); constexpr time_point& operator+=(const duration& d); constexpr time_point& operator-=(const duration& d); // [[time.point.special]](#special "30.6.5 Special values"), special valuesstatic constexpr time_point min() noexcept; static constexpr time_point max() noexcept; };}
|
||||
|
||||
[1](#general-1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L2253)
|
||||
|
||||
If Duration is not a specialization of duration,
|
||||
the program is ill-formed[.](#general-1.sentence-1)
|
||||
|
||||
### [30.6.2](#cons) Constructors [[time.point.cons]](time.point.cons)
|
||||
|
||||
[ð](#lib:time_point,constructor)
|
||||
|
||||
`constexpr time_point();
|
||||
`
|
||||
|
||||
[1](#cons-1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L2265)
|
||||
|
||||
*Effects*: Initializes d_ with duration::zero()[.](#cons-1.sentence-1)
|
||||
|
||||
Such a time_point object represents the epoch[.](#cons-1.sentence-2)
|
||||
|
||||
[ð](#lib:time_point,constructor_)
|
||||
|
||||
`constexpr explicit time_point(const duration& d);
|
||||
`
|
||||
|
||||
[2](#cons-2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L2277)
|
||||
|
||||
*Effects*: Initializes d_ with d[.](#cons-2.sentence-1)
|
||||
|
||||
Such a time_point object represents the epoch + d[.](#cons-2.sentence-2)
|
||||
|
||||
[ð](#lib:time_point,constructor__)
|
||||
|
||||
`template<class Duration2>
|
||||
constexpr time_point(const time_point<clock, Duration2>& t);
|
||||
`
|
||||
|
||||
[3](#cons-3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L2290)
|
||||
|
||||
*Constraints*: is_convertible_v<Duration2, duration> is true[.](#cons-3.sentence-1)
|
||||
|
||||
[4](#cons-4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L2294)
|
||||
|
||||
*Effects*: Initializes d_ with t.time_since_epoch()[.](#cons-4.sentence-1)
|
||||
|
||||
### [30.6.3](#observer) Observer [[time.point.observer]](time.point.observer)
|
||||
|
||||
[ð](#lib:time_since_epoch,time_point)
|
||||
|
||||
`constexpr duration time_since_epoch() const;
|
||||
`
|
||||
|
||||
[1](#observer-1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L2307)
|
||||
|
||||
*Returns*: d_[.](#observer-1.sentence-1)
|
||||
|
||||
### [30.6.4](#arithmetic) Arithmetic [[time.point.arithmetic]](time.point.arithmetic)
|
||||
|
||||
[ð](#lib:operator++,time_point)
|
||||
|
||||
`constexpr time_point& operator++();
|
||||
`
|
||||
|
||||
[1](#arithmetic-1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L2320)
|
||||
|
||||
*Effects*: Equivalent to: ++d_[.](#arithmetic-1.sentence-1)
|
||||
|
||||
[2](#arithmetic-2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L2324)
|
||||
|
||||
*Returns*: *this[.](#arithmetic-2.sentence-1)
|
||||
|
||||
[ð](#lib:operator++,time_point_)
|
||||
|
||||
`constexpr time_point operator++(int);
|
||||
`
|
||||
|
||||
[3](#arithmetic-3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L2335)
|
||||
|
||||
*Effects*: Equivalent to: return time_point{d_++};
|
||||
|
||||
[ð](#lib:operator--,time_point)
|
||||
|
||||
`constexpr time_point& operator--();
|
||||
`
|
||||
|
||||
[4](#arithmetic-4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L2346)
|
||||
|
||||
*Effects*: Equivalent to: --d_[.](#arithmetic-4.sentence-1)
|
||||
|
||||
[5](#arithmetic-5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L2350)
|
||||
|
||||
*Returns*: *this[.](#arithmetic-5.sentence-1)
|
||||
|
||||
[ð](#lib:operator--,time_point_)
|
||||
|
||||
`constexpr time_point operator--(int);
|
||||
`
|
||||
|
||||
[6](#arithmetic-6)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L2361)
|
||||
|
||||
*Effects*: Equivalent to: return time_point{d_--};
|
||||
|
||||
[ð](#lib:operator+=,time_point)
|
||||
|
||||
`constexpr time_point& operator+=(const duration& d);
|
||||
`
|
||||
|
||||
[7](#arithmetic-7)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L2372)
|
||||
|
||||
*Effects*: Equivalent to: d_ += d[.](#arithmetic-7.sentence-1)
|
||||
|
||||
[8](#arithmetic-8)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L2376)
|
||||
|
||||
*Returns*: *this[.](#arithmetic-8.sentence-1)
|
||||
|
||||
[ð](#lib:operator-=,time_point)
|
||||
|
||||
`constexpr time_point& operator-=(const duration& d);
|
||||
`
|
||||
|
||||
[9](#arithmetic-9)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L2387)
|
||||
|
||||
*Effects*: Equivalent to: d_ -= d[.](#arithmetic-9.sentence-1)
|
||||
|
||||
[10](#arithmetic-10)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L2391)
|
||||
|
||||
*Returns*: *this[.](#arithmetic-10.sentence-1)
|
||||
|
||||
### [30.6.5](#special) Special values [[time.point.special]](time.point.special)
|
||||
|
||||
[ð](#lib:min,time_point)
|
||||
|
||||
`static constexpr time_point min() noexcept;
|
||||
`
|
||||
|
||||
[1](#special-1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L2404)
|
||||
|
||||
*Returns*: time_point(duration::min())[.](#special-1.sentence-1)
|
||||
|
||||
[ð](#lib:max,time_point)
|
||||
|
||||
`static constexpr time_point max() noexcept;
|
||||
`
|
||||
|
||||
[2](#special-2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L2415)
|
||||
|
||||
*Returns*: time_point(duration::max())[.](#special-2.sentence-1)
|
||||
|
||||
### [30.6.6](#nonmember) Non-member arithmetic [[time.point.nonmember]](time.point.nonmember)
|
||||
|
||||
[ð](#lib:operator+,time_point)
|
||||
|
||||
`template<class Clock, class Duration1, class Rep2, class Period2>
|
||||
constexpr time_point<Clock, common_type_t<Duration1, duration<Rep2, Period2>>>
|
||||
operator+(const time_point<Clock, Duration1>& lhs, const duration<Rep2, Period2>& rhs);
|
||||
`
|
||||
|
||||
[1](#nonmember-1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L2431)
|
||||
|
||||
*Returns*: CT(lhs.time_since_epoch() + rhs), where CT is the type of the return value[.](#nonmember-1.sentence-1)
|
||||
|
||||
[ð](#lib:operator+,time_point_)
|
||||
|
||||
`template<class Rep1, class Period1, class Clock, class Duration2>
|
||||
constexpr time_point<Clock, common_type_t<duration<Rep1, Period1>, Duration2>>
|
||||
operator+(const duration<Rep1, Period1>& lhs, const time_point<Clock, Duration2>& rhs);
|
||||
`
|
||||
|
||||
[2](#nonmember-2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L2445)
|
||||
|
||||
*Returns*: rhs + lhs[.](#nonmember-2.sentence-1)
|
||||
|
||||
[ð](#lib:operator-,time_point)
|
||||
|
||||
`template<class Clock, class Duration1, class Rep2, class Period2>
|
||||
constexpr time_point<Clock, common_type_t<Duration1, duration<Rep2, Period2>>>
|
||||
operator-(const time_point<Clock, Duration1>& lhs, const duration<Rep2, Period2>& rhs);
|
||||
`
|
||||
|
||||
[3](#nonmember-3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L2459)
|
||||
|
||||
*Returns*: CT(lhs.time_since_epoch() - rhs),
|
||||
where CT is the type of the return value[.](#nonmember-3.sentence-1)
|
||||
|
||||
[ð](#lib:operator-,time_point_)
|
||||
|
||||
`template<class Clock, class Duration1, class Duration2>
|
||||
constexpr common_type_t<Duration1, Duration2>
|
||||
operator-(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
|
||||
`
|
||||
|
||||
[4](#nonmember-4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L2473)
|
||||
|
||||
*Returns*: lhs.time_since_epoch() - rhs.time_since_epoch()[.](#nonmember-4.sentence-1)
|
||||
|
||||
### [30.6.7](#comparisons) Comparisons [[time.point.comparisons]](time.point.comparisons)
|
||||
|
||||
[ð](#lib:operator==,time_point)
|
||||
|
||||
`template<class Clock, class Duration1, class Duration2>
|
||||
constexpr bool operator==(const time_point<Clock, Duration1>& lhs,
|
||||
const time_point<Clock, Duration2>& rhs);
|
||||
`
|
||||
|
||||
[1](#comparisons-1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L2488)
|
||||
|
||||
*Returns*: lhs.time_since_epoch() == rhs.time_since_epoch()[.](#comparisons-1.sentence-1)
|
||||
|
||||
[ð](#lib:operator%3c,time_point)
|
||||
|
||||
`template<class Clock, class Duration1, class Duration2>
|
||||
constexpr bool operator<(const time_point<Clock, Duration1>& lhs,
|
||||
const time_point<Clock, Duration2>& rhs);
|
||||
`
|
||||
|
||||
[2](#comparisons-2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L2501)
|
||||
|
||||
*Returns*: lhs.time_since_epoch() < rhs.time_since_epoch()[.](#comparisons-2.sentence-1)
|
||||
|
||||
[ð](#lib:operator%3e,time_point)
|
||||
|
||||
`template<class Clock, class Duration1, class Duration2>
|
||||
constexpr bool operator>(const time_point<Clock, Duration1>& lhs,
|
||||
const time_point<Clock, Duration2>& rhs);
|
||||
`
|
||||
|
||||
[3](#comparisons-3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L2514)
|
||||
|
||||
*Returns*: rhs < lhs[.](#comparisons-3.sentence-1)
|
||||
|
||||
[ð](#lib:operator%3c=,time_point)
|
||||
|
||||
`template<class Clock, class Duration1, class Duration2>
|
||||
constexpr bool operator<=(const time_point<Clock, Duration1>& lhs,
|
||||
const time_point<Clock, Duration2>& rhs);
|
||||
`
|
||||
|
||||
[4](#comparisons-4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L2527)
|
||||
|
||||
*Returns*: !(rhs < lhs)[.](#comparisons-4.sentence-1)
|
||||
|
||||
[ð](#lib:operator%3e=,time_point)
|
||||
|
||||
`template<class Clock, class Duration1, class Duration2>
|
||||
constexpr bool operator>=(const time_point<Clock, Duration1>& lhs,
|
||||
const time_point<Clock, Duration2>& rhs);
|
||||
`
|
||||
|
||||
[5](#comparisons-5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L2540)
|
||||
|
||||
*Returns*: !(lhs < rhs)[.](#comparisons-5.sentence-1)
|
||||
|
||||
[ð](#lib:operator%3e=,time_point_)
|
||||
|
||||
`template<class Clock, class Duration1,
|
||||
[three_way_comparable_with](cmp.concept#concept:three_way_comparable_with "17.12.4 Concept three_way_comparable [cmp.concept]")<Duration1> Duration2>
|
||||
constexpr auto operator<=>(const time_point<Clock, Duration1>& lhs,
|
||||
const time_point<Clock, Duration2>& rhs);
|
||||
`
|
||||
|
||||
[6](#comparisons-6)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L2554)
|
||||
|
||||
*Returns*: lhs.time_since_epoch() <=> rhs.time_since_epoch()[.](#comparisons-6.sentence-1)
|
||||
|
||||
### [30.6.8](#cast) Conversions [[time.point.cast]](time.point.cast)
|
||||
|
||||
[ð](#lib:time_point,time_point_cast)
|
||||
|
||||
`template<class ToDuration, class Clock, class Duration>
|
||||
constexpr time_point<Clock, ToDuration> time_point_cast(const time_point<Clock, Duration>& t);
|
||||
`
|
||||
|
||||
[1](#cast-1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L2569)
|
||||
|
||||
*Constraints*: ToDuration is a specialization of duration[.](#cast-1.sentence-1)
|
||||
|
||||
[2](#cast-2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L2573)
|
||||
|
||||
*Returns*: time_point<Clock, ToDuration>(duration_cast<ToDuration>(t.time_since_epoch()))
|
||||
|
||||
[ð](#lib:floor,time_point)
|
||||
|
||||
`template<class ToDuration, class Clock, class Duration>
|
||||
constexpr time_point<Clock, ToDuration> floor(const time_point<Clock, Duration>& tp);
|
||||
`
|
||||
|
||||
[3](#cast-3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L2587)
|
||||
|
||||
*Constraints*: ToDuration is a specialization of duration[.](#cast-3.sentence-1)
|
||||
|
||||
[4](#cast-4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L2591)
|
||||
|
||||
*Returns*: time_point<Clock, ToDuration>(floor<ToDuration>(tp.time_since_epoch()))[.](#cast-4.sentence-1)
|
||||
|
||||
[ð](#lib:ceil,time_point)
|
||||
|
||||
`template<class ToDuration, class Clock, class Duration>
|
||||
constexpr time_point<Clock, ToDuration> ceil(const time_point<Clock, Duration>& tp);
|
||||
`
|
||||
|
||||
[5](#cast-5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L2603)
|
||||
|
||||
*Constraints*: ToDuration is a specialization of duration[.](#cast-5.sentence-1)
|
||||
|
||||
[6](#cast-6)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L2607)
|
||||
|
||||
*Returns*: time_point<Clock, ToDuration>(ceil<ToDuration>(tp.time_since_epoch()))[.](#cast-6.sentence-1)
|
||||
|
||||
[ð](#lib:round,time_point)
|
||||
|
||||
`template<class ToDuration, class Clock, class Duration>
|
||||
constexpr time_point<Clock, ToDuration> round(const time_point<Clock, Duration>& tp);
|
||||
`
|
||||
|
||||
[7](#cast-7)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L2619)
|
||||
|
||||
*Constraints*: ToDuration is a specialization of duration, andtreat_as_floating_point_v<typename ToDuration::rep> is false[.](#cast-7.sentence-1)
|
||||
|
||||
[8](#cast-8)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L2624)
|
||||
|
||||
*Returns*: time_point<Clock, ToDuration>(round<ToDuration>(tp.time_since_epoch()))[.](#cast-8.sentence-1)
|
||||
Reference in New Issue
Block a user