Back to home page

EIC code displayed by LXR

 
 

    


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

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 // For information see https://libcxx.llvm.org/DesignDocs/TimeZone.html
0011 
0012 #ifndef _LIBCPP___CHRONO_LEAP_SECOND_H
0013 #define _LIBCPP___CHRONO_LEAP_SECOND_H
0014 
0015 #include <version>
0016 // Enable the contents of the header only when libc++ was built with experimental features enabled.
0017 #if _LIBCPP_HAS_EXPERIMENTAL_TZDB
0018 
0019 #  include <__chrono/duration.h>
0020 #  include <__chrono/system_clock.h>
0021 #  include <__chrono/time_point.h>
0022 #  include <__compare/ordering.h>
0023 #  include <__compare/three_way_comparable.h>
0024 #  include <__config>
0025 #  include <__utility/private_constructor_tag.h>
0026 
0027 #  if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0028 #    pragma GCC system_header
0029 #  endif
0030 
0031 _LIBCPP_BEGIN_NAMESPACE_STD
0032 
0033 #  if _LIBCPP_STD_VER >= 20
0034 
0035 namespace chrono {
0036 
0037 class leap_second {
0038 public:
0039   [[nodiscard]]
0040   _LIBCPP_HIDE_FROM_ABI explicit constexpr leap_second(__private_constructor_tag, sys_seconds __date, seconds __value)
0041       : __date_(__date), __value_(__value) {}
0042 
0043   _LIBCPP_HIDE_FROM_ABI leap_second(const leap_second&)            = default;
0044   _LIBCPP_HIDE_FROM_ABI leap_second& operator=(const leap_second&) = default;
0045 
0046   [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr sys_seconds date() const noexcept { return __date_; }
0047 
0048   [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr seconds value() const noexcept { return __value_; }
0049 
0050 private:
0051   sys_seconds __date_;
0052   seconds __value_;
0053 
0054   // The function
0055   //   template<class Duration>
0056   //    requires three_way_comparable_with<sys_seconds, sys_time<Duration>>
0057   //    constexpr auto operator<=>(const leap_second& x, const sys_time<Duration>& y) noexcept;
0058   //
0059   // Has constraints that are recursive (LWG4139). The proposed resolution is
0060   // to make the funcion a hidden friend. For consistency make this change for
0061   // all comparison functions.
0062 
0063   _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const leap_second& __x, const leap_second& __y) {
0064     return __x.date() == __y.date();
0065   }
0066 
0067   _LIBCPP_HIDE_FROM_ABI friend constexpr strong_ordering operator<=>(const leap_second& __x, const leap_second& __y) {
0068     return __x.date() <=> __y.date();
0069   }
0070 
0071   template <class _Duration>
0072   _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const leap_second& __x, const sys_time<_Duration>& __y) {
0073     return __x.date() == __y;
0074   }
0075 
0076   template <class _Duration>
0077   _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator<(const leap_second& __x, const sys_time<_Duration>& __y) {
0078     return __x.date() < __y;
0079   }
0080 
0081   template <class _Duration>
0082   _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator<(const sys_time<_Duration>& __x, const leap_second& __y) {
0083     return __x < __y.date();
0084   }
0085 
0086   template <class _Duration>
0087   _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator>(const leap_second& __x, const sys_time<_Duration>& __y) {
0088     return __y < __x;
0089   }
0090 
0091   template <class _Duration>
0092   _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator>(const sys_time<_Duration>& __x, const leap_second& __y) {
0093     return __y < __x;
0094   }
0095 
0096   template <class _Duration>
0097   _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator<=(const leap_second& __x, const sys_time<_Duration>& __y) {
0098     return !(__y < __x);
0099   }
0100 
0101   template <class _Duration>
0102   _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator<=(const sys_time<_Duration>& __x, const leap_second& __y) {
0103     return !(__y < __x);
0104   }
0105 
0106   template <class _Duration>
0107   _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator>=(const leap_second& __x, const sys_time<_Duration>& __y) {
0108     return !(__x < __y);
0109   }
0110 
0111   template <class _Duration>
0112   _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator>=(const sys_time<_Duration>& __x, const leap_second& __y) {
0113     return !(__x < __y);
0114   }
0115 
0116   template <class _Duration>
0117     requires three_way_comparable_with<sys_seconds, sys_time<_Duration>>
0118   _LIBCPP_HIDE_FROM_ABI friend constexpr auto operator<=>(const leap_second& __x, const sys_time<_Duration>& __y) {
0119     return __x.date() <=> __y;
0120   }
0121 };
0122 
0123 } // namespace chrono
0124 
0125 #  endif // _LIBCPP_STD_VER >= 20
0126 
0127 _LIBCPP_END_NAMESPACE_STD
0128 
0129 #endif // _LIBCPP_HAS_EXPERIMENTAL_TZDB
0130 
0131 #endif // _LIBCPP___CHRONO_LEAP_SECOND_H