Revert "[InstCombine] Support gep nuw in icmp folds" (#118698)
[llvm-project.git] / libcxx / include / __chrono / day.h
blobf5b14689a78acfdae9e69b667dd3bd1a6175f612
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 #ifndef _LIBCPP___CHRONO_DAY_H
11 #define _LIBCPP___CHRONO_DAY_H
13 #include <__chrono/duration.h>
14 #include <__compare/ordering.h>
15 #include <__config>
17 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18 # pragma GCC system_header
19 #endif
21 #if _LIBCPP_STD_VER >= 20
23 _LIBCPP_BEGIN_NAMESPACE_STD
25 namespace chrono {
27 class day {
28 private:
29 unsigned char __d_;
31 public:
32 day() = default;
33 _LIBCPP_HIDE_FROM_ABI explicit inline constexpr day(unsigned __val) noexcept
34 : __d_(static_cast<unsigned char>(__val)) {}
35 _LIBCPP_HIDE_FROM_ABI inline constexpr day& operator++() noexcept {
36 ++__d_;
37 return *this;
39 _LIBCPP_HIDE_FROM_ABI inline constexpr day operator++(int) noexcept {
40 day __tmp = *this;
41 ++(*this);
42 return __tmp;
44 _LIBCPP_HIDE_FROM_ABI inline constexpr day& operator--() noexcept {
45 --__d_;
46 return *this;
48 _LIBCPP_HIDE_FROM_ABI inline constexpr day operator--(int) noexcept {
49 day __tmp = *this;
50 --(*this);
51 return __tmp;
53 _LIBCPP_HIDE_FROM_ABI constexpr day& operator+=(const days& __dd) noexcept;
54 _LIBCPP_HIDE_FROM_ABI constexpr day& operator-=(const days& __dd) noexcept;
55 _LIBCPP_HIDE_FROM_ABI explicit inline constexpr operator unsigned() const noexcept { return __d_; }
56 _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __d_ >= 1 && __d_ <= 31; }
59 _LIBCPP_HIDE_FROM_ABI inline constexpr bool operator==(const day& __lhs, const day& __rhs) noexcept {
60 return static_cast<unsigned>(__lhs) == static_cast<unsigned>(__rhs);
63 _LIBCPP_HIDE_FROM_ABI inline constexpr strong_ordering operator<=>(const day& __lhs, const day& __rhs) noexcept {
64 return static_cast<unsigned>(__lhs) <=> static_cast<unsigned>(__rhs);
67 _LIBCPP_HIDE_FROM_ABI inline constexpr day operator+(const day& __lhs, const days& __rhs) noexcept {
68 return day(static_cast<unsigned>(__lhs) + __rhs.count());
71 _LIBCPP_HIDE_FROM_ABI inline constexpr day operator+(const days& __lhs, const day& __rhs) noexcept {
72 return __rhs + __lhs;
75 _LIBCPP_HIDE_FROM_ABI inline constexpr day operator-(const day& __lhs, const days& __rhs) noexcept {
76 return __lhs + -__rhs;
79 _LIBCPP_HIDE_FROM_ABI inline constexpr days operator-(const day& __lhs, const day& __rhs) noexcept {
80 return days(static_cast<int>(static_cast<unsigned>(__lhs)) - static_cast<int>(static_cast<unsigned>(__rhs)));
83 _LIBCPP_HIDE_FROM_ABI inline constexpr day& day::operator+=(const days& __dd) noexcept {
84 *this = *this + __dd;
85 return *this;
88 _LIBCPP_HIDE_FROM_ABI inline constexpr day& day::operator-=(const days& __dd) noexcept {
89 *this = *this - __dd;
90 return *this;
93 } // namespace chrono
95 _LIBCPP_END_NAMESPACE_STD
97 #endif // _LIBCPP_STD_VER >= 20
99 #endif // _LIBCPP___CHRONO_DAY_H