Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-03 08:13:24

0001 // -*- C++ -*-
0002 //===----------------------------------------------------------------------===//
0003 //
0004 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0005 // See https://llvm.org/LICENSE.txt for license information.
0006 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0007 //
0008 //===----------------------------------------------------------------------===//
0009 
0010 #ifndef _LIBCPP___CXX03___CHRONO_DAY_H
0011 #define _LIBCPP___CXX03___CHRONO_DAY_H
0012 
0013 #include <__cxx03/__chrono/duration.h>
0014 #include <__cxx03/__config>
0015 #include <__cxx03/compare>
0016 
0017 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0018 #  pragma GCC system_header
0019 #endif
0020 
0021 #if _LIBCPP_STD_VER >= 20
0022 
0023 _LIBCPP_BEGIN_NAMESPACE_STD
0024 
0025 namespace chrono {
0026 
0027 class day {
0028 private:
0029   unsigned char __d_;
0030 
0031 public:
0032   day() = default;
0033   _LIBCPP_HIDE_FROM_ABI explicit inline constexpr day(unsigned __val) noexcept
0034       : __d_(static_cast<unsigned char>(__val)) {}
0035   _LIBCPP_HIDE_FROM_ABI inline constexpr day& operator++() noexcept {
0036     ++__d_;
0037     return *this;
0038   }
0039   _LIBCPP_HIDE_FROM_ABI inline constexpr day operator++(int) noexcept {
0040     day __tmp = *this;
0041     ++(*this);
0042     return __tmp;
0043   }
0044   _LIBCPP_HIDE_FROM_ABI inline constexpr day& operator--() noexcept {
0045     --__d_;
0046     return *this;
0047   }
0048   _LIBCPP_HIDE_FROM_ABI inline constexpr day operator--(int) noexcept {
0049     day __tmp = *this;
0050     --(*this);
0051     return __tmp;
0052   }
0053   _LIBCPP_HIDE_FROM_ABI constexpr day& operator+=(const days& __dd) noexcept;
0054   _LIBCPP_HIDE_FROM_ABI constexpr day& operator-=(const days& __dd) noexcept;
0055   _LIBCPP_HIDE_FROM_ABI explicit inline constexpr operator unsigned() const noexcept { return __d_; }
0056   _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __d_ >= 1 && __d_ <= 31; }
0057 };
0058 
0059 _LIBCPP_HIDE_FROM_ABI inline constexpr bool operator==(const day& __lhs, const day& __rhs) noexcept {
0060   return static_cast<unsigned>(__lhs) == static_cast<unsigned>(__rhs);
0061 }
0062 
0063 _LIBCPP_HIDE_FROM_ABI inline constexpr strong_ordering operator<=>(const day& __lhs, const day& __rhs) noexcept {
0064   return static_cast<unsigned>(__lhs) <=> static_cast<unsigned>(__rhs);
0065 }
0066 
0067 _LIBCPP_HIDE_FROM_ABI inline constexpr day operator+(const day& __lhs, const days& __rhs) noexcept {
0068   return day(static_cast<unsigned>(__lhs) + __rhs.count());
0069 }
0070 
0071 _LIBCPP_HIDE_FROM_ABI inline constexpr day operator+(const days& __lhs, const day& __rhs) noexcept {
0072   return __rhs + __lhs;
0073 }
0074 
0075 _LIBCPP_HIDE_FROM_ABI inline constexpr day operator-(const day& __lhs, const days& __rhs) noexcept {
0076   return __lhs + -__rhs;
0077 }
0078 
0079 _LIBCPP_HIDE_FROM_ABI inline constexpr days operator-(const day& __lhs, const day& __rhs) noexcept {
0080   return days(static_cast<int>(static_cast<unsigned>(__lhs)) - static_cast<int>(static_cast<unsigned>(__rhs)));
0081 }
0082 
0083 _LIBCPP_HIDE_FROM_ABI inline constexpr day& day::operator+=(const days& __dd) noexcept {
0084   *this = *this + __dd;
0085   return *this;
0086 }
0087 
0088 _LIBCPP_HIDE_FROM_ABI inline constexpr day& day::operator-=(const days& __dd) noexcept {
0089   *this = *this - __dd;
0090   return *this;
0091 }
0092 
0093 } // namespace chrono
0094 
0095 _LIBCPP_END_NAMESPACE_STD
0096 
0097 #endif // _LIBCPP_STD_VER >= 20
0098 
0099 #endif // _LIBCPP___CXX03___CHRONO_DAY_H