]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - libstdc++-v3/libsupc++/compare
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / libsupc++ / compare
index 066867e9ce179c624406baa968318889ff6d6037..686aa6d218fe54646a21d29e882d729f00cc8577 100644 (file)
@@ -1,6 +1,6 @@
 // -*- C++ -*- operator<=> three-way comparison support.
 
-// Copyright (C) 2019-2022 Free Software Foundation, Inc.
+// Copyright (C) 2019-2024 Free Software Foundation, Inc.
 //
 // This file is part of GCC.
 //
 
 #pragma GCC system_header
 
+#define __glibcxx_want_three_way_comparison
+#include <bits/version.h>
+
 #if __cplusplus > 201703L && __cpp_impl_three_way_comparison >= 201907L
 
 #include <concepts>
 
-#if __cpp_lib_concepts
-# define __cpp_lib_three_way_comparison 201907L
-#endif
-
 namespace std _GLIBCXX_VISIBILITY(default)
 {
   // [cmp.categories], comparison category types
@@ -54,7 +53,7 @@ namespace std _GLIBCXX_VISIBILITY(default)
 
     struct __unspec
     {
-      constexpr __unspec(__unspec*) noexcept { }
+      consteval __unspec(__unspec*) noexcept { }
     };
   }
 
@@ -448,7 +447,8 @@ namespace std _GLIBCXX_VISIBILITY(default)
     using common_comparison_category_t
       = typename common_comparison_category<_Ts...>::type;
 
-#if __cpp_lib_concepts
+#if __cpp_lib_three_way_comparison >= 201907L
+  // C++ >= 20 && impl_3way_comparison >= 201907 && lib_concepts
   namespace __detail
   {
     template<typename _Tp, typename _Cat>
@@ -566,7 +566,9 @@ namespace std _GLIBCXX_VISIBILITY(default)
     using is_transparent = void;
   };
 
-  namespace __cmp_cust
+  /// @cond undocumented
+  // Namespace for helpers for the <compare> customization points.
+  namespace __compare
   {
     template<floating_point _Tp>
       constexpr weak_ordering
@@ -610,6 +612,8 @@ namespace std _GLIBCXX_VISIBILITY(default)
          }
       }
 
+    void strong_order() = delete;
+
     template<typename _Tp, typename _Up>
       concept __adl_strong = requires(_Tp&& __t, _Up&& __u)
        {
@@ -617,6 +621,8 @@ namespace std _GLIBCXX_VISIBILITY(default)
                                       static_cast<_Up&&>(__u)));
        };
 
+    void weak_order() = delete;
+
     template<typename _Tp, typename _Up>
       concept __adl_weak = requires(_Tp&& __t, _Up&& __u)
        {
@@ -624,6 +630,8 @@ namespace std _GLIBCXX_VISIBILITY(default)
                                   static_cast<_Up&&>(__u)));
        };
 
+    void partial_order() = delete;
+
     template<typename _Tp, typename _Up>
       concept __adl_partial = requires(_Tp&& __t, _Up&& __u)
        {
@@ -672,7 +680,7 @@ namespace std _GLIBCXX_VISIBILITY(default)
        _X86_80bit,  // x86 80-bit extended precision
        _M68k_80bit, // m68k 80-bit extended precision
        _Dbldbl, // IBM 128-bit double-double
-       // TODO: _Bfloat16,
+       _Bfloat16,   // std::bfloat16_t
       };
 
 #ifndef __cpp_using_enum
@@ -684,6 +692,7 @@ namespace std _GLIBCXX_VISIBILITY(default)
       static constexpr _Fp_fmt _X86_80bit = _Fp_fmt::_X86_80bit;
       static constexpr _Fp_fmt _M68k_80bit = _Fp_fmt::_M68k_80bit;
       static constexpr _Fp_fmt _Dbldbl = _Fp_fmt::_Dbldbl;
+      static constexpr _Fp_fmt _Bfloat16 = _Fp_fmt::_Bfloat16;
 #endif
 
       // Identify the format used by a floating-point type.
@@ -714,6 +723,10 @@ namespace std _GLIBCXX_VISIBILITY(default)
          if constexpr (__is_same(_Tp, __float80))
            return _X86_80bit;
 #endif
+#ifdef __STDCPP_BFLOAT16_T__
+         if constexpr (__is_same(_Tp, decltype(0.0bf16)))
+           return _Bfloat16;
+#endif
 
          constexpr int __width = sizeof(_Tp) * __CHAR_BIT__;
 
@@ -995,7 +1008,7 @@ namespace std _GLIBCXX_VISIBILITY(default)
        noexcept(_S_noexcept<_Tp, _Up>())
        {
          if constexpr (floating_point<decay_t<_Tp>>)
-           return __cmp_cust::__fp_weak_ordering(__e, __f);
+           return __compare::__fp_weak_ordering(__e, __f);
          else if constexpr (__adl_weak<_Tp, _Up>)
            return weak_ordering(weak_order(static_cast<_Tp&&>(__e),
                                            static_cast<_Up&&>(__f)));
@@ -1167,27 +1180,29 @@ namespace std _GLIBCXX_VISIBILITY(default)
              : partial_ordering::unordered;
        }
     };
-  } // namespace __cmp_cust
+  } // namespace @endcond
 
   // [cmp.alg], comparison algorithms
-  inline namespace __cmp_alg
+
+  inline namespace _Cpo
   {
-    inline constexpr __cmp_cust::_Strong_order strong_order{};
+    inline constexpr __compare::_Strong_order strong_order{};
 
-    inline constexpr __cmp_cust::_Weak_order weak_order{};
+    inline constexpr __compare::_Weak_order weak_order{};
 
-    inline constexpr __cmp_cust::_Partial_order partial_order{};
+    inline constexpr __compare::_Partial_order partial_order{};
 
-    inline constexpr __cmp_cust::_Strong_fallback
-    compare_strong_order_fallback{};
+    inline constexpr __compare::_Strong_fallback
+      compare_strong_order_fallback{};
 
-    inline constexpr __cmp_cust::_Weak_fallback
-    compare_weak_order_fallback{};
+    inline constexpr __compare::_Weak_fallback
+      compare_weak_order_fallback{};
 
-    inline constexpr __cmp_cust::_Partial_fallback
-    compare_partial_order_fallback{};
+    inline constexpr __compare::_Partial_fallback
+      compare_partial_order_fallback{};
   }
 
+  /// @cond undocumented
   namespace __detail
   {
     // [expos.only.func] synth-three-way
@@ -1234,7 +1249,8 @@ namespace std _GLIBCXX_VISIBILITY(default)
        = decltype(__detail::__synth3way(std::declval<_Tp&>(),
                                         std::declval<_Up&>()));
   } // namespace __detail
-#endif // concepts
+  /// @endcond
+#endif // __cpp_lib_three_way_comparison >= 201907L
 } // namespace std
 
 #endif // C++20