On 14 November 2017 at 19:06, Jonathan Wakely <jwak...@redhat.com> wrote:
> Both files can use remove_cv_t instead of remove_cv::type (and there's
> no need to std-qualify it in std::gcd).
>
> They could also use is_integral_v and is_same_v but that's
> pre-existing, and less important because there's no 'typename' that
> can be avoided by changing it.

Here's round 2.
diff --git a/libstdc++-v3/include/experimental/numeric 
b/libstdc++-v3/include/experimental/numeric
index c8597fc..f037d8e 100644
--- a/libstdc++-v3/include/experimental/numeric
+++ b/libstdc++-v3/include/experimental/numeric
@@ -55,10 +55,12 @@ inline namespace fundamentals_v2
     constexpr common_type_t<_Mn, _Nn>
     gcd(_Mn __m, _Nn __n)
     {
-      static_assert(is_integral<_Mn>::value, "gcd arguments are integers");
-      static_assert(is_integral<_Nn>::value, "gcd arguments are integers");
-      static_assert(!is_same<_Mn, bool>::value, "gcd arguments are not bools");
-      static_assert(!is_same<_Nn, bool>::value, "gcd arguments are not bools");
+      static_assert(is_integral_v<_Mn>, "gcd arguments are integers");
+      static_assert(is_integral_v<_Nn>, "gcd arguments are integers");
+      static_assert(!is_same_v<remove_cv_t<_Mn>, bool>,
+                   "gcd arguments are not bools");
+      static_assert(!is_same_v<remove_cv_t<_Nn>, bool>,
+                   "gcd arguments are not bools");
       return std::__detail::__gcd(__m, __n);
     }
 
@@ -67,10 +69,12 @@ inline namespace fundamentals_v2
     constexpr common_type_t<_Mn, _Nn>
     lcm(_Mn __m, _Nn __n)
     {
-      static_assert(is_integral<_Mn>::value, "lcm arguments are integers");
-      static_assert(is_integral<_Nn>::value, "lcm arguments are integers");
-      static_assert(!is_same<_Mn, bool>::value, "lcm arguments are not bools");
-      static_assert(!is_same<_Nn, bool>::value, "lcm arguments are not bools");
+      static_assert(is_integral_v<_Mn>, "lcm arguments are integers");
+      static_assert(is_integral_v<_Nn>, "lcm arguments are integers");
+      static_assert(!is_same_v<remove_cv_t<_Mn>, bool>,
+                   "lcm arguments are not bools");
+      static_assert(!is_same_v<remove_cv_t<_Nn>, bool>,
+                   "lcm arguments are not bools");
       return std::__detail::__lcm(__m, __n);
     }
 } // namespace fundamentals_v2
diff --git a/libstdc++-v3/include/std/numeric b/libstdc++-v3/include/std/numeric
index 2b80419..a3a447d 100644
--- a/libstdc++-v3/include/std/numeric
+++ b/libstdc++-v3/include/std/numeric
@@ -131,10 +131,12 @@ namespace __detail
     constexpr common_type_t<_Mn, _Nn>
     gcd(_Mn __m, _Nn __n)
     {
-      static_assert(is_integral<_Mn>::value, "gcd arguments are integers");
-      static_assert(is_integral<_Nn>::value, "gcd arguments are integers");
-      static_assert(!is_same<_Mn, bool>::value, "gcd arguments are not bools");
-      static_assert(!is_same<_Nn, bool>::value, "gcd arguments are not bools");
+      static_assert(is_integral_v<_Mn>, "gcd arguments are integers");
+      static_assert(is_integral_v<_Nn>, "gcd arguments are integers");
+      static_assert(!is_same_v<remove_cv_t<_Mn>, bool>,
+                   "gcd arguments are not bools");
+      static_assert(!is_same_v<remove_cv<_Nn>, bool>,
+                   "gcd arguments are not bools");
       return __detail::__gcd(__m, __n);
     }
 
@@ -143,10 +145,12 @@ namespace __detail
     constexpr common_type_t<_Mn, _Nn>
     lcm(_Mn __m, _Nn __n)
     {
-      static_assert(is_integral<_Mn>::value, "lcm arguments are integers");
-      static_assert(is_integral<_Nn>::value, "lcm arguments are integers");
-      static_assert(!is_same<_Mn, bool>::value, "lcm arguments are not bools");
-      static_assert(!is_same<_Nn, bool>::value, "lcm arguments are not bools");
+      static_assert(is_integral_v<_Mn>, "lcm arguments are integers");
+      static_assert(is_integral_v<_Nn>, "lcm arguments are integers");
+      static_assert(!is_same_v<remove_cv_t<_Mn>, bool>,
+                   "lcm arguments are not bools");
+      static_assert(!is_same_v<remove_cv_t<_Nn>, bool>,
+                   "lcm arguments are not bools");
       return __detail::__lcm(__m, __n);
     }
 
diff --git a/libstdc++-v3/testsuite/26_numerics/gcd/gcd_neg.cc 
b/libstdc++-v3/testsuite/26_numerics/gcd/gcd_neg.cc
index 30524a1b..63a8afa 100644
--- a/libstdc++-v3/testsuite/26_numerics/gcd/gcd_neg.cc
+++ b/libstdc++-v3/testsuite/26_numerics/gcd/gcd_neg.cc
@@ -26,14 +26,29 @@ test01()
   std::gcd(true, 1);    // { dg-error "from here" }
   std::gcd(1, true);    // { dg-error "from here" }
   std::gcd(true, true); // { dg-error "from here" }
+  std::gcd<const bool, int>(true, 1);    // { dg-error "from here" }
+  std::gcd<int, const bool>(1, true);    // { dg-error "from here" }
+  std::gcd<const bool, const bool>(true, true); // { dg-error "from here" }
+  std::gcd<const bool&, int>(true, 1);    // { dg-error "from here" }
+  std::gcd<int, const bool&>(1, true);    // { dg-error "from here" }
+  std::gcd<const bool&, const bool&>(true, true); // { dg-error "from here" }
+  std::gcd<const volatile bool, int>(true, 1);    // { dg-error "from here" }
+  std::gcd<int, const volatile bool>(1, true);    // { dg-error "from here" }
+  std::gcd<const volatile bool,
+          const volatile bool>(true, true); // { dg-error "from here" }
+  std::gcd<volatile bool, int>(true, 1);    // { dg-error "from here" }
+  std::gcd<int, volatile bool>(1, true);    // { dg-error "from here" }
+  std::gcd<volatile bool,
+          volatile bool>(true, true); // { dg-error "from here" }
   std::gcd(0.1, 1);     // { dg-error "from here" }
   std::gcd(1, 0.1);     // { dg-error "from here" }
   std::gcd(0.1, 0.1);   // { dg-error "from here" }
+  std::gcd<const int&, const int&>(0.1, 0.1);   // { dg-error "from here" }
 }
 
 // { dg-error "integers" "" { target *-*-* } 134 }
 // { dg-error "integers" "" { target *-*-* } 135 }
 // { dg-error "not bools" "" { target *-*-* } 136 }
-// { dg-error "not bools" "" { target *-*-* } 137 }
+// { dg-error "not bools" "" { target *-*-* } 138 }
 // { dg-prune-output "deleted function" }
 // { dg-prune-output "invalid operands" }
diff --git a/libstdc++-v3/testsuite/26_numerics/lcm/lcm_neg.cc 
b/libstdc++-v3/testsuite/26_numerics/lcm/lcm_neg.cc
index e16e6ae..d25a92d 100644
--- a/libstdc++-v3/testsuite/26_numerics/lcm/lcm_neg.cc
+++ b/libstdc++-v3/testsuite/26_numerics/lcm/lcm_neg.cc
@@ -26,14 +26,29 @@ test01()
   std::lcm(true, 1);    // { dg-error "from here" }
   std::lcm(1, true);    // { dg-error "from here" }
   std::lcm(true, true); // { dg-error "from here" }
+  std::lcm<const bool, int>(true, 1);    // { dg-error "from here" }
+  std::lcm<int, const bool>(1, true);    // { dg-error "from here" }
+  std::lcm<const bool, const bool>(true, true); // { dg-error "from here" }
+  std::lcm<const bool&, int>(true, 1);    // { dg-error "from here" }
+  std::lcm<int, const bool&>(1, true);    // { dg-error "from here" }
+  std::lcm<const bool&, const bool&>(true, true); // { dg-error "from here" }
+  std::lcm<const volatile bool, int>(true, 1);    // { dg-error "from here" }
+  std::lcm<int, const volatile bool>(1, true);    // { dg-error "from here" }
+  std::lcm<const volatile bool,
+          const volatile bool>(true, true); // { dg-error "from here" }
+  std::lcm<volatile bool, int>(true, 1);    // { dg-error "from here" }
+  std::lcm<int, volatile bool>(1, true);    // { dg-error "from here" }
+  std::lcm<volatile bool,
+          volatile bool>(true, true); // { dg-error "from here" }
   std::lcm(0.1, 1);     // { dg-error "from here" }
   std::lcm(1, 0.1);     // { dg-error "from here" }
   std::lcm(0.1, 0.1);   // { dg-error "from here" }
+  std::lcm<const int&, const int&>(0.1, 0.1);   // { dg-error "from here" }
 }
 
-// { dg-error "integers" "" { target *-*-* } 146 }
-// { dg-error "integers" "" { target *-*-* } 147 }
-// { dg-error "not bools" "" { target *-*-* } 148 }
-// { dg-error "not bools" "" { target *-*-* } 149 }
+// { dg-error "integers" "" { target *-*-* } 148 }
+// { dg-error "integers" "" { target *-*-* } 149 }
+// { dg-error "not bools" "" { target *-*-* } 150 }
+// { dg-error "not bools" "" { target *-*-* } 152 }
 // { dg-prune-output "deleted function" }
 // { dg-prune-output "invalid operands" }

Reply via email to