[v3] Tidy std::is_signed

Paolo Carlini paolo.carlini@oracle.com
Mon Apr 22 16:21:00 GMT 2013


Hi,

the other day, while Daniel was discussing a simply wording issue, I 
noticed that our implementation is unnecessarily complicated.

Tested x86_64-linux.

Thanks,
Paolo.

//////////////////////////
-------------- next part --------------
2013-04-22  Paolo Carlini  <paolo.carlini@oracle.com>

	* include/std/type_traits (is_signed): Simplify.
	* testsuite/20_util/make_signed/requirements/typedefs_neg.cc:
	Adjust dg-error line numbers.
	* testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc:
	Likewise.
	* testsuite/20_util/declval/requirements/1_neg.cc: Likewise.
-------------- next part --------------
Index: include/std/type_traits
===================================================================
--- include/std/type_traits	(revision 198097)
+++ include/std/type_traits	(working copy)
@@ -538,18 +538,13 @@
     { };
 
   template<typename _Tp,
-	   bool = is_integral<_Tp>::value,
-	   bool = is_floating_point<_Tp>::value>
+	   bool = is_arithmetic<_Tp>::value>
     struct __is_signed_helper
     : public false_type { };
 
   template<typename _Tp>
-    struct __is_signed_helper<_Tp, false, true>
-    : public true_type { };
-
-  template<typename _Tp>
-    struct __is_signed_helper<_Tp, true, false>
-    : public integral_constant<bool, static_cast<bool>(_Tp(-1) < _Tp(0))>
+    struct __is_signed_helper<_Tp, true>
+    : public integral_constant<bool, _Tp(-1) < _Tp(0)>
     { };
 
   /// is_signed
Index: testsuite/20_util/make_signed/requirements/typedefs_neg.cc
===================================================================
--- testsuite/20_util/make_signed/requirements/typedefs_neg.cc	(revision 198008)
+++ testsuite/20_util/make_signed/requirements/typedefs_neg.cc	(working copy)
@@ -48,5 +48,5 @@
 // { dg-error "required from here" "" { target *-*-* } 40 }
 // { dg-error "required from here" "" { target *-*-* } 42 }
 
-// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1599 }
-// { dg-error "declaration of" "" { target *-*-* } 1563 }
+// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1594 }
+// { dg-error "declaration of" "" { target *-*-* } 1558 }
Index: testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc
===================================================================
--- testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc	(revision 198008)
+++ testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc	(working copy)
@@ -48,5 +48,5 @@
 // { dg-error "required from here" "" { target *-*-* } 40 }
 // { dg-error "required from here" "" { target *-*-* } 42 }
 
-// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1517 }
-// { dg-error "declaration of" "" { target *-*-* } 1481 }
+// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1512 }
+// { dg-error "declaration of" "" { target *-*-* } 1476 }
Index: testsuite/20_util/declval/requirements/1_neg.cc
===================================================================
--- testsuite/20_util/declval/requirements/1_neg.cc	(revision 198008)
+++ testsuite/20_util/declval/requirements/1_neg.cc	(working copy)
@@ -19,7 +19,7 @@
 // with this library; see the file COPYING3.  If not see
 // <http://www.gnu.org/licenses/>.
 
-// { dg-error "static assertion failed" "" { target *-*-* } 1857 }
+// { dg-error "static assertion failed" "" { target *-*-* } 1852 }
 
 #include <utility>
 


More information about the Gcc-patches mailing list