[libcxx-commits] [libcxx] [libc++][chono] Use hidden friends for leap_second comparison. (PR #104713)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Aug 20 08:55:55 PDT 2024
================
@@ -50,70 +50,75 @@ class leap_second {
private:
sys_seconds __date_;
seconds __value_;
-};
-_LIBCPP_HIDE_FROM_ABI inline constexpr bool operator==(const leap_second& __x, const leap_second& __y) {
- return __x.date() == __y.date();
-}
-
-_LIBCPP_HIDE_FROM_ABI inline constexpr strong_ordering operator<=>(const leap_second& __x, const leap_second& __y) {
- return __x.date() <=> __y.date();
-}
-
-template <class _Duration>
-_LIBCPP_HIDE_FROM_ABI constexpr bool operator==(const leap_second& __x, const sys_time<_Duration>& __y) {
- return __x.date() == __y;
-}
-
-template <class _Duration>
-_LIBCPP_HIDE_FROM_ABI constexpr bool operator<(const leap_second& __x, const sys_time<_Duration>& __y) {
- return __x.date() < __y;
-}
-
-template <class _Duration>
-_LIBCPP_HIDE_FROM_ABI constexpr bool operator<(const sys_time<_Duration>& __x, const leap_second& __y) {
- return __x < __y.date();
-}
-
-template <class _Duration>
-_LIBCPP_HIDE_FROM_ABI constexpr bool operator>(const leap_second& __x, const sys_time<_Duration>& __y) {
- return __y < __x;
-}
-
-template <class _Duration>
-_LIBCPP_HIDE_FROM_ABI constexpr bool operator>(const sys_time<_Duration>& __x, const leap_second& __y) {
- return __y < __x;
-}
-
-template <class _Duration>
-_LIBCPP_HIDE_FROM_ABI constexpr bool operator<=(const leap_second& __x, const sys_time<_Duration>& __y) {
- return !(__y < __x);
-}
-
-template <class _Duration>
-_LIBCPP_HIDE_FROM_ABI constexpr bool operator<=(const sys_time<_Duration>& __x, const leap_second& __y) {
- return !(__y < __x);
-}
-
-template <class _Duration>
-_LIBCPP_HIDE_FROM_ABI constexpr bool operator>=(const leap_second& __x, const sys_time<_Duration>& __y) {
- return !(__x < __y);
-}
-
-template <class _Duration>
-_LIBCPP_HIDE_FROM_ABI constexpr bool operator>=(const sys_time<_Duration>& __x, const leap_second& __y) {
- return !(__x < __y);
-}
-
-# ifndef _LIBCPP_COMPILER_GCC
-// This requirement cause a compilation loop in GCC-13 and running out of memory.
-// TODO TZDB Test whether GCC-14 fixes this.
-template <class _Duration>
- requires three_way_comparable_with<sys_seconds, sys_time<_Duration>>
-_LIBCPP_HIDE_FROM_ABI constexpr auto operator<=>(const leap_second& __x, const sys_time<_Duration>& __y) {
- return __x.date() <=> __y;
-}
-# endif
+ // The function
+ // template<class Duration>
+ // requires three_way_comparable_with<sys_seconds, sys_time<Duration>>
+ // constexpr auto operator<=>(const leap_second& x, const sys_time<Duration>& y) noexcept;
+ //
+ // Has constraints that are recursive (LWG4139). The proposed resolution is
+ // to make the funcion a hidden friend. For consistency make this change for
+ // all comparison functions.
----------------
ldionne wrote:
```suggestion
// has constraints that are recursive (LWG4139). The proposed resolution is
// to make the function a hidden friend. For consistency, we do this for all
// comparison functions.
```
https://github.com/llvm/llvm-project/pull/104713
More information about the libcxx-commits
mailing list