This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[v3] tr1/type_traits: more tweaks (issue 3.20)


Hi,

tested x86-linux, committing to mainline and 4_0.

Paolo.

/////////////////


2005-04-29  Paolo Carlini  <pcarlini@suse.de>

	* include/tr1/type_traits (is_convertible): Adjust according
	to the resolution of TR1 issue 3.20.
	* testsuite/tr1/4_metaprogramming/relationships_between_types/
	is_convertible/is_convertible.cc: Add tests.
diff -urN libstdc++-v3-orig/include/tr1/type_traits libstdc++-v3/include/tr1/type_traits
--- libstdc++-v3-orig/include/tr1/type_traits	2005-04-27 16:30:53.000000000 +0200
+++ libstdc++-v3/include/tr1/type_traits	2005-04-29 00:04:50.000000000 +0200
@@ -501,7 +501,8 @@
     };
 
   template<typename _From, typename _To,
-	   bool = (is_function<_To>::value || is_array<_To>::value
+	   bool = (is_void<_From>::value || is_void<_To>::value
+		   || is_function<_To>::value || is_array<_To>::value
 		   // This special case is here only to avoid warnings.		   
 		   || (is_floating_point<typename
 		       remove_reference<_From>::type>::value
@@ -515,7 +516,9 @@
 
   template<typename _From, typename _To>
     struct __is_convertible_helper<_From, _To, true>
-    { static const bool __value = __is_int_or_cref<_To>::__value; };
+    { static const bool __value = (is_void<_To>::value
+				   || (__is_int_or_cref<_To>::__value
+				       && !is_void<_From>::value)); };
 
   template<typename _From, typename _To>
     struct is_convertible
diff -urN libstdc++-v3-orig/testsuite/tr1/4_metaprogramming/relationships_between_types/is_convertible/is_convertible.cc libstdc++-v3/testsuite/tr1/4_metaprogramming/relationships_between_types/is_convertible/is_convertible.cc
--- libstdc++-v3-orig/testsuite/tr1/4_metaprogramming/relationships_between_types/is_convertible/is_convertible.cc	2005-02-23 18:23:44.000000000 +0100
+++ libstdc++-v3/testsuite/tr1/4_metaprogramming/relationships_between_types/is_convertible/is_convertible.cc	2005-04-29 00:15:23.000000000 +0200
@@ -54,6 +54,10 @@
   VERIFY( (test_relationship<is_convertible, DerivedType*, ClassType*>(true)) );
   VERIFY( (test_relationship<is_convertible, DerivedType&, ClassType&>(true)) );
 
+  VERIFY( (test_relationship<is_convertible, void, void>(true)) );
+  VERIFY( (test_relationship<is_convertible, int, void>(true)) );
+  VERIFY( (test_relationship<is_convertible, int[4], void>(true)) );  
+
   // Negative tests.
   VERIFY( (test_relationship<is_convertible, const int*, int*>(false)) );
   VERIFY( (test_relationship<is_convertible, int*, float*>(false)) );
@@ -69,7 +73,11 @@
   VERIFY( (test_relationship<is_convertible, int, ClassType>(false)) );
   VERIFY( (test_relationship<is_convertible, ClassType, DerivedType>(false)) );
   VERIFY( (test_relationship<is_convertible, ClassType*, DerivedType*>(false)) );
-  VERIFY( (test_relationship<is_convertible, ClassType&, DerivedType&>(false)) );  
+  VERIFY( (test_relationship<is_convertible, ClassType&, DerivedType&>(false)) );
+
+  VERIFY( (test_relationship<is_convertible, void, int>(false)) );
+  VERIFY( (test_relationship<is_convertible, void, float>(false)) );  
+  VERIFY( (test_relationship<is_convertible, void, int(*)(int)>(false)) );  
 }
 
 int main()

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]