[libc-commits] [libc] c28a522 - [libc][NFC] moving template specialization outside class declaration

Guillaume Chatelet via libc-commits libc-commits at lists.llvm.org
Tue Feb 8 02:35:58 PST 2022


Author: Guillaume Chatelet
Date: 2022-02-08T10:35:44Z
New Revision: c28a522fc75ca10335615d01306c56f77e07b056

URL: https://github.com/llvm/llvm-project/commit/c28a522fc75ca10335615d01306c56f77e07b056
DIFF: https://github.com/llvm/llvm-project/commit/c28a522fc75ca10335615d01306c56f77e07b056.diff

LOG: [libc][NFC] moving template specialization outside class declaration

This is necessary to get llvm-libc compile with GCC.
This patch is extracted from D119002.

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

Added: 
    

Modified: 
    libc/utils/MPFRWrapper/MPFRUtils.cpp

Removed: 
    


################################################################################
diff  --git a/libc/utils/MPFRWrapper/MPFRUtils.cpp b/libc/utils/MPFRWrapper/MPFRUtils.cpp
index 3c57211bc35a4..502a15f6c090b 100644
--- a/libc/utils/MPFRWrapper/MPFRUtils.cpp
+++ b/libc/utils/MPFRWrapper/MPFRUtils.cpp
@@ -392,16 +392,6 @@ class MPFRNumber {
   // These functions are useful for debugging.
   template <typename T> T as() const;
 
-  template <> float as<float>() const {
-    return mpfr_get_flt(value, mpfr_rounding);
-  }
-  template <> double as<double>() const {
-    return mpfr_get_d(value, mpfr_rounding);
-  }
-  template <> long double as<long double>() const {
-    return mpfr_get_ld(value, mpfr_rounding);
-  }
-
   void dump(const char *msg) const { mpfr_printf("%s%.128Rf\n", msg, value); }
 
   // Return the ULP (units-in-the-last-place) 
diff erence between the
@@ -488,6 +478,18 @@ class MPFRNumber {
   }
 };
 
+template <> float MPFRNumber::as<float>() const {
+  return mpfr_get_flt(value, mpfr_rounding);
+}
+
+template <> double MPFRNumber::as<double>() const {
+  return mpfr_get_d(value, mpfr_rounding);
+}
+
+template <> long double MPFRNumber::as<long double>() const {
+  return mpfr_get_ld(value, mpfr_rounding);
+}
+
 namespace internal {
 
 template <typename InputType>


        


More information about the libc-commits mailing list