Patchwork [v3] "SFINAE-friendly" std::common_type and more

login
register
mail settings
Submitter Paolo Carlini
Date Oct. 10, 2012, 12:03 p.m.
Message ID <5075640A.9080902@oracle.com>
Download mbox | patch
Permalink /patch/190618/
State New
Headers show

Comments

Paolo Carlini - Oct. 10, 2012, 12:03 p.m.
... tested x86_64-linux. Committed to mainline.

Paolo.

////////////////////
2012-10-10  Paolo Carlini  <paolo.carlini@oracle.com>

	* include/std/type_traits (__do_common_type_impl): Revert for now
	LWG 2141-related change.
	* testsuite/20_util/common_type/requirements/typedefs-1.cc: Likewise.
	* testsuite/20_util/common_type/requirements/sfinae_friendly_1.cc:
	Adjust.
Daniel Krügler - Oct. 10, 2012, 12:06 p.m.
2012/10/10 Paolo Carlini <paolo.carlini@oracle.com>:
> ... tested x86_64-linux. Committed to mainline.

I'd like to mention that this patch does not reflect what the core
language says, e.g.

static_assert(is_type<std::common_type<int&&, int&&>, int>(), "");

Should assert, the correct result being int&&. The test currently
holds because of compiler bug 53000.

- Daniel
Paolo Carlini - Oct. 10, 2012, 12:14 p.m.
On 10/10/2012 02:06 PM, Daniel Krügler wrote:
> 2012/10/10 Paolo Carlini <paolo.carlini@oracle.com>:
>> ... tested x86_64-linux. Committed to mainline.
> I'd like to mention that this patch does not reflect what the core
> language says, e.g.
>
> static_assert(is_type<std::common_type<int&&, int&&>, int>(), "");
>
> Should assert, the correct result being int&&. The test currently
> holds because of compiler bug 53000.
If you like, please send a patchlet using the HAS_53000_FIXED 
infrastructure which you already added to mark such cases in a clear way!

Paolo.

Patch

Index: testsuite/20_util/common_type/requirements/sfinae_friendly_1.cc
===================================================================
--- testsuite/20_util/common_type/requirements/sfinae_friendly_1.cc	(revision 192306)
+++ testsuite/20_util/common_type/requirements/sfinae_friendly_1.cc	(working copy)
@@ -172,7 +172,7 @@ 
 static_assert(is_type<std::common_type<int, int, int, int>, int>(), "");
 static_assert(is_type<std::common_type<int, int, int, int, int>, int>(), "");
 static_assert(is_type<std::common_type<S, S>, S>(), "");
-static_assert(is_type<std::common_type<const S, const S>, S>(), "");
+static_assert(is_type<std::common_type<const S, const S>, const S>(), "");
 static_assert(is_type<std::common_type<std::initializer_list<int>,
 	      std::initializer_list<int>>, std::initializer_list<int>>(), "");
 static_assert(is_type<std::common_type<B, D>, B>(), "");
@@ -188,10 +188,10 @@ 
 static_assert(is_type<std::common_type<void, void>, void>(), "");
 static_assert(is_type<std::common_type<const void, const void>, void>(), "");
 static_assert(is_type<std::common_type<int&, int&&>, int>(), "");
-static_assert(is_type<std::common_type<int&, int&>, int>(), "");
+static_assert(is_type<std::common_type<int&, int&>, int&>(), "");
 static_assert(is_type<std::common_type<int&&, int&&>, int>(), "");
-static_assert(is_type<std::common_type<U&, const U&&>, U>(), "");
-static_assert(is_type<std::common_type<U&, U&>, U>(), "");
+static_assert(is_type<std::common_type<U&, const U&&>, const U>(), "");
+static_assert(is_type<std::common_type<U&, U&>, U&>(), "");
 static_assert(is_type<std::common_type<U&&, U&&>, U>(), "");
 static_assert(is_type<std::common_type<int B::*, int D::*>, int D::*>(), "");
 static_assert(is_type<std::common_type<int D::*, int B::*>, int D::*>(), "");
@@ -204,14 +204,14 @@ 
 static_assert(is_type<std::common_type<int[3], int[3]>, int*>(), "");
 static_assert(is_type<std::common_type<int[1], const int[3]>,
 	      const int*>(), "");
-static_assert(is_type<std::common_type<void(), void()>, void(*)()>(), "");
-static_assert(is_type<std::common_type<void(&)(), void(&)()>, void(*)()>(), "");
+static_assert(is_type<std::common_type<void(), void()>, void(&)()>(), "");
+static_assert(is_type<std::common_type<void(&)(), void(&)()>, void(&)()>(), "");
 static_assert(is_type<std::common_type<void(&)(), void(&&)()>,
-	      void(*)()>(), "");
+	      void(&)()>(), "");
 static_assert(is_type<std::common_type<void(&&)(), void(&)()>,
-	      void(*)()>(), "");
+	      void(&)()>(), "");
 static_assert(is_type<std::common_type<void(&&)(), void(&&)()>,
-	      void(*)()>(), "");
+	      void(&)()>(), "");
 static_assert(is_type<std::common_type<ImplicitTo<int>, int>, int>(), "");
 static_assert(is_type<std::common_type<ImplicitTo<int>, ImplicitTo<int>>,
 	      ImplicitTo<int>>(), "");
@@ -222,7 +222,7 @@ 
 static_assert(is_type<std::common_type<decltype(lmd1), decltype(lmd1)>,
 	      decltype(lmd1)>(), "");
 static_assert(is_type<std::common_type<decltype(lmd1)&, decltype(lmd1)&>,
-	      decltype(lmd1)>(), "");
+	      decltype(lmd1)&>(), "");
 static_assert(is_type<std::common_type<decltype(lmd1)&, decltype(lmd2)&>,
 	      void(*)(int, double)>(), "");
 static_assert(is_type<std::common_type<decltype(nullptr), void*>, void*>(), "");
@@ -237,9 +237,9 @@ 
 	      int (B::*)() const>(), "");
 static_assert(is_type<std::common_type<decltype(nullptr), const int B::*>,
 	      const int B::*>(), "");
-static_assert(is_type<std::common_type<Abstract&, Abstract&>, Abstract>(), "");
-static_assert(is_type<std::common_type<Ukn&, Ukn&>, Ukn>(), "");
-static_assert(is_type<std::common_type<ImplicitTo<B&>, B&>, B>(), "");
+static_assert(is_type<std::common_type<Abstract&, Abstract&>, Abstract&>(), "");
+static_assert(is_type<std::common_type<Ukn&, Ukn&>, Ukn&>(), "");
+static_assert(is_type<std::common_type<ImplicitTo<B&>, B&>, B&>(), "");
 static_assert(is_type<std::common_type<ImplicitTo<B&>&, B&&>, B>(), "");
 static_assert(is_type<std::common_type<UConv1, const Abstract*&>,
 	      const Abstract*>(), "");
@@ -328,7 +328,7 @@ 
   static_assert(is_type<std::common_type<decltype(local_lmd1)&,
 		        decltype(local_lmd1)>, decltype(local_lmd1)>(), "");
   static_assert(is_type<std::common_type<decltype(local_lmd1)&,
-			decltype(local_lmd1)&>, decltype(local_lmd1)>(), "");
+			decltype(local_lmd1)&>, decltype(local_lmd1)&>(), "");
 
   static_assert(!has_type<std::common_type<decltype(local_lmd1),
 		decltype(lmd1)>>(), "");
Index: testsuite/20_util/common_type/requirements/typedefs-1.cc
===================================================================
--- testsuite/20_util/common_type/requirements/typedefs-1.cc	(revision 192306)
+++ testsuite/20_util/common_type/requirements/typedefs-1.cc	(working copy)
@@ -105,7 +105,7 @@ 
   COMMON_TYPE_TEST_ALL_2(int, int, int, 1);
   COMMON_TYPE_TEST_ALL_2(int, double, double, 2);
   COMMON_TYPE_TEST_2(NO_CV, A, A, A, 3);
-  COMMON_TYPE_TEST_2(const, A, A, A, 4);
+  COMMON_TYPE_TEST_2(const, A, A, const A, 4);
   COMMON_TYPE_TEST_2(NO_CV, B, A, A, 5);  
 }
 
Index: include/std/type_traits
===================================================================
--- include/std/type_traits	(revision 192306)
+++ include/std/type_traits	(working copy)
@@ -1792,9 +1792,9 @@ 
   struct __do_common_type_impl
   {
     template<typename _Tp, typename _Up>
-      static __success_type<typename decay<
-        decltype(true ? std::declval<_Tp>() : std::declval<_Up>())
-      >::type> _S_test(int);
+      static __success_type<decltype
+			    (true ? std::declval<_Tp>()
+			     : std::declval<_Up>())> _S_test(int);
 
     template<typename, typename>
       static __failure_type _S_test(...);