[libc++] "Implements" new SI prefixis.
authorMark de Wever <koraq@xs4all.nl>
Sat, 17 Jun 2023 13:50:50 +0000 (15:50 +0200)
committerMark de Wever <koraq@xs4all.nl>
Mon, 19 Jun 2023 15:04:35 +0000 (17:04 +0200)
Like yocto, zepto, zetta, and yotta. The new prefixes quecto, ronto,
ronna, and quetta can't be implemented in a intmax_t. So their
implementation does nothing.

Implements
- P2734R0 Adding the new SI prefixes

Depends on D153192

Reviewed By: #libc, philnik

Differential Revision: https://reviews.llvm.org/D153200

libcxx/docs/FeatureTestMacroTable.rst
libcxx/docs/Status/Cxx2cPapers.csv
libcxx/include/ratio
libcxx/include/version
libcxx/test/std/language.support/support.limits/support.limits.general/ratio.version.compile.pass.cpp
libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp
libcxx/utils/generate_feature_test_macro_components.py

index 4c8e1ff..9fa4495 100644 (file)
@@ -394,7 +394,7 @@ Status
     --------------------------------------------------- -----------------
     ``__cpp_lib_hazard_pointer``                        *unimplemented*
     --------------------------------------------------- -----------------
-    ``__cpp_lib_ratio``                                 *unimplemented*
+    ``__cpp_lib_ratio``                                 ``202306L``
     --------------------------------------------------- -----------------
     ``__cpp_lib_rcu``                                   *unimplemented*
     --------------------------------------------------- -----------------
index 494e70f..cd2e933 100644 (file)
@@ -22,7 +22,7 @@
 "`P1759R6 <https://wg21.link/P1759R6>`__","LWG","Native handles and file streams","Varna June 2023","","",""
 "`P2697R1 <https://wg21.link/P2697R1>`__","LWG","Interfacing ``bitset`` with ``string_view``","Varna June 2023","","",""
 "`P1383R2 <https://wg21.link/P1383R2>`__","LWG","More ``constexpr`` for ``<cmath>`` and ``<complex>``","Varna June 2023","","",""
-"`P2734R0 <https://wg21.link/P2734R0>`__","LWG","Adding the new SI prefixes","Varna June 2023","","",""
+"`P2734R0 <https://wg21.link/P2734R0>`__","LWG","Adding the new SI prefixes","Varna June 2023","|Complete|","Clang 17",""
 "`P2548R6 <https://wg21.link/P2548R6>`__","LWG","``copyable_function``","Varna June 2023","","",""
 "`P2714R1 <https://wg21.link/P2714R1>`__","LWG","Bind front and back to NTTP callables","Varna June 2023","","",""
 "`P2630R4 <https://wg21.link/P2630R4>`__","LWG","``submdspan``","Varna June 2023","","",""
index 327e08c..c9637ab 100644 (file)
@@ -40,6 +40,8 @@ template <class R1, class R2> struct ratio_greater;
 template <class R1, class R2> struct ratio_greater_equal;
 
 // convenience SI typedefs
+using quecto = ratio <1, 1'000'000'000'000'000'000'000'000'000'000>; // Since C++26; not supported
+using ronto = ratio <1, 1'000'000'000'000'000'000'000'000'000>;      // Since C++26; not supported
 typedef ratio<1, 1000000000000000000000000> yocto;  // not supported
 typedef ratio<1,    1000000000000000000000> zepto;  // not supported
 typedef ratio<1,       1000000000000000000> atto;
@@ -60,6 +62,8 @@ typedef ratio<         1000000000000000, 1> peta;
 typedef ratio<      1000000000000000000, 1> exa;
 typedef ratio<   1000000000000000000000, 1> zetta;  // not supported
 typedef ratio<1000000000000000000000000, 1> yotta;  // not supported
+using ronna = ratio <1'000'000'000'000'000'000'000'000'000, 1>;      // Since C++26; not supported
+using quetta = ratio <1'000'000'000'000'000'000'000'000'000'000, 1>; // Since C++26; not supported
 
   // 20.11.5, ratio comparison
   template <class R1, class R2> inline constexpr bool ratio_equal_v
index 10abf69..0cdf06d 100644 (file)
@@ -456,7 +456,7 @@ __cpp_lib_within_lifetime                               202306L <type_traits>
 // # define __cpp_lib_fstream_native_handle                202306L
 // # define __cpp_lib_function_ref                         202306L
 // # define __cpp_lib_hazard_pointer                       202306L
-// # define __cpp_lib_ratio                                202306L
+# define __cpp_lib_ratio                                202306L
 // # define __cpp_lib_rcu                                  202306L
 // # define __cpp_lib_smart_ptr_owner_equality             202306L
 // # define __cpp_lib_sstream_from_string_view             202306L
index f782c24..38adba6 100644 (file)
 
 #elif TEST_STD_VER > 23
 
-# if !defined(_LIBCPP_VERSION)
-#   ifndef __cpp_lib_ratio
-#     error "__cpp_lib_ratio should be defined in c++26"
-#   endif
-#   if __cpp_lib_ratio != 202306L
-#     error "__cpp_lib_ratio should have the value 202306L in c++26"
-#   endif
-# else // _LIBCPP_VERSION
-#   ifdef __cpp_lib_ratio
-#     error "__cpp_lib_ratio should not be defined because it is unimplemented in libc++!"
-#   endif
+# ifndef __cpp_lib_ratio
+#   error "__cpp_lib_ratio should be defined in c++26"
+# endif
+# if __cpp_lib_ratio != 202306L
+#   error "__cpp_lib_ratio should have the value 202306L in c++26"
 # endif
 
 #endif // TEST_STD_VER > 23
index fb7081f..040dc9c 100644 (file)
 #   endif
 # endif
 
-# if !defined(_LIBCPP_VERSION)
-#   ifndef __cpp_lib_ratio
-#     error "__cpp_lib_ratio should be defined in c++26"
-#   endif
-#   if __cpp_lib_ratio != 202306L
-#     error "__cpp_lib_ratio should have the value 202306L in c++26"
-#   endif
-# else // _LIBCPP_VERSION
-#   ifdef __cpp_lib_ratio
-#     error "__cpp_lib_ratio should not be defined because it is unimplemented in libc++!"
-#   endif
+# ifndef __cpp_lib_ratio
+#   error "__cpp_lib_ratio should be defined in c++26"
+# endif
+# if __cpp_lib_ratio != 202306L
+#   error "__cpp_lib_ratio should have the value 202306L in c++26"
 # endif
 
 # ifndef __cpp_lib_raw_memory_algorithms
index 4d454f7..4b83579 100755 (executable)
@@ -847,7 +847,6 @@ feature_test_macros = [
             "name": "__cpp_lib_ratio",
             "values": {"c++26": 202306}, # P2734R0 Adding the new SI prefixes
             "headers": ["ratio"],
-            "unimplemented": True,
         },
         {
             "name": "__cpp_lib_raw_memory_algorithms",