Revert "[InstCombine] Support gep nuw in icmp folds" (#118698)
[llvm-project.git] / libcxx / include / __chrono / leap_second.h
blobb01d9fbca8c2f1bbe93a0ea259c037ebb3e1a864
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 //===----------------------------------------------------------------------===//
10 // For information see https://libcxx.llvm.org/DesignDocs/TimeZone.html
12 #ifndef _LIBCPP___CHRONO_LEAP_SECOND_H
13 #define _LIBCPP___CHRONO_LEAP_SECOND_H
15 #include <version>
16 // Enable the contents of the header only when libc++ was built with experimental features enabled.
17 #if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
19 # include <__chrono/duration.h>
20 # include <__chrono/system_clock.h>
21 # include <__chrono/time_point.h>
22 # include <__compare/ordering.h>
23 # include <__compare/three_way_comparable.h>
24 # include <__config>
25 # include <__utility/private_constructor_tag.h>
27 # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
28 # pragma GCC system_header
29 # endif
31 _LIBCPP_BEGIN_NAMESPACE_STD
33 # if _LIBCPP_STD_VER >= 20
35 namespace chrono {
37 class leap_second {
38 public:
39 [[nodiscard]]
40 _LIBCPP_HIDE_FROM_ABI explicit constexpr leap_second(__private_constructor_tag, sys_seconds __date, seconds __value)
41 : __date_(__date), __value_(__value) {}
43 _LIBCPP_HIDE_FROM_ABI leap_second(const leap_second&) = default;
44 _LIBCPP_HIDE_FROM_ABI leap_second& operator=(const leap_second&) = default;
46 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr sys_seconds date() const noexcept { return __date_; }
48 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr seconds value() const noexcept { return __value_; }
50 private:
51 sys_seconds __date_;
52 seconds __value_;
54 // The function
55 // template<class Duration>
56 // requires three_way_comparable_with<sys_seconds, sys_time<Duration>>
57 // constexpr auto operator<=>(const leap_second& x, const sys_time<Duration>& y) noexcept;
59 // Has constraints that are recursive (LWG4139). The proposed resolution is
60 // to make the funcion a hidden friend. For consistency make this change for
61 // all comparison functions.
63 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const leap_second& __x, const leap_second& __y) {
64 return __x.date() == __y.date();
67 _LIBCPP_HIDE_FROM_ABI friend constexpr strong_ordering operator<=>(const leap_second& __x, const leap_second& __y) {
68 return __x.date() <=> __y.date();
71 template <class _Duration>
72 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const leap_second& __x, const sys_time<_Duration>& __y) {
73 return __x.date() == __y;
76 template <class _Duration>
77 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator<(const leap_second& __x, const sys_time<_Duration>& __y) {
78 return __x.date() < __y;
81 template <class _Duration>
82 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator<(const sys_time<_Duration>& __x, const leap_second& __y) {
83 return __x < __y.date();
86 template <class _Duration>
87 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator>(const leap_second& __x, const sys_time<_Duration>& __y) {
88 return __y < __x;
91 template <class _Duration>
92 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator>(const sys_time<_Duration>& __x, const leap_second& __y) {
93 return __y < __x;
96 template <class _Duration>
97 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator<=(const leap_second& __x, const sys_time<_Duration>& __y) {
98 return !(__y < __x);
101 template <class _Duration>
102 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator<=(const sys_time<_Duration>& __x, const leap_second& __y) {
103 return !(__y < __x);
106 template <class _Duration>
107 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator>=(const leap_second& __x, const sys_time<_Duration>& __y) {
108 return !(__x < __y);
111 template <class _Duration>
112 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator>=(const sys_time<_Duration>& __x, const leap_second& __y) {
113 return !(__x < __y);
116 template <class _Duration>
117 requires three_way_comparable_with<sys_seconds, sys_time<_Duration>>
118 _LIBCPP_HIDE_FROM_ABI friend constexpr auto operator<=>(const leap_second& __x, const sys_time<_Duration>& __y) {
119 return __x.date() <=> __y;
123 } // namespace chrono
125 # endif // _LIBCPP_STD_VER >= 20
127 _LIBCPP_END_NAMESPACE_STD
129 #endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
131 #endif // _LIBCPP___CHRONO_LEAP_SECOND_H