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] Implement DR 706 + decay bit of DR 705


Hi,

tested x86_64-linux, committed to mainline.

Paolo.

///////////////////
2007-11-08  Paolo Carlini  <pcarlini@suse.de>

	* include/std/type_traits (__decay_selector<_Up, false, false>):
	Change according to DR 705.
	* include/bits/stl_pair.h (make_pair(_T1&&, _T2&&)): Change
	according to DR 706.
	* include/tr1_impl/tuple: Tweak.
Index: include/tr1_impl/tuple
===================================================================
--- include/tr1_impl/tuple	(revision 129993)
+++ include/tr1_impl/tuple	(working copy)
@@ -39,9 +39,6 @@
 {
 _GLIBCXX_BEGIN_NAMESPACE_TR1
 
-  template<typename _Tp>
-    class reference_wrapper;
-
   // Adds a const reference to a non-reference type.
   template<typename _Tp>
     struct __add_c_ref
@@ -375,6 +372,10 @@
 	       const tuple<_UElements...>& __u)
     { return !(__t < __u); }
 
+#ifdef _GLIBCXX_INCLUDE_AS_TR1
+  template<typename _Tp>
+    class reference_wrapper;
+
   // Helper which adds a reference to a type when given a reference_wrapper
   template<typename _Tp>
     struct __strip_reference_wrapper
@@ -393,6 +394,7 @@
     {
       typedef _Tp& __type;
     };
+#endif
 
   template<typename... _Elements>
     inline tuple<typename __strip_reference_wrapper<_Elements>::__type...>
Index: include/std/type_traits
===================================================================
--- include/std/type_traits	(revision 129993)
+++ include/std/type_traits	(working copy)
@@ -308,21 +308,21 @@
 	   bool _IsFunction = is_function<_Up>::value> 
     struct __decay_selector;
 
+  // NB: DR 705.
   template<typename _Up> 
     struct __decay_selector<_Up, false, false>
-    { typedef _Up __type; };
+    { typedef typename remove_cv<_Up>::type __type; };
 
   template<typename _Up> 
     struct __decay_selector<_Up, true, false>
     { typedef typename remove_extent<_Up>::type* __type; };
 
-
   template<typename _Up> 
     struct __decay_selector<_Up, false, true>
     { typedef typename add_pointer<_Up>::type __type; };
 
   template<typename _Tp> 
-  struct decay 
+    struct decay 
     { 
     private:
       typedef typename remove_reference<_Tp>::type __remove_type;
Index: include/bits/stl_pair.h
===================================================================
--- include/bits/stl_pair.h	(revision 129994)
+++ include/bits/stl_pair.h	(working copy)
@@ -211,14 +211,44 @@
     make_pair(_T1 __x, _T2 __y)
     { return pair<_T1, _T2>(__x, __y); }
 #else
+  template<typename _Tp>
+    class reference_wrapper;
+
+  // Helper which adds a reference to a type when given a reference_wrapper
+  template<typename _Tp>
+    struct __strip_reference_wrapper
+    {
+      typedef _Tp __type;
+    };
+
+  template<typename _Tp>
+    struct __strip_reference_wrapper<reference_wrapper<_Tp> >
+    {
+      typedef _Tp& __type;
+    };
+
+  template<typename _Tp>
+    struct __strip_reference_wrapper<const reference_wrapper<_Tp> >
+    {
+      typedef _Tp& __type;
+    };
+
+  template<typename _Tp>
+    struct __decay_and_strip
+    {
+      typedef typename __strip_reference_wrapper<
+	typename decay<_Tp>::type>::__type __type;
+    };
+
+  // NB: DR 706.
   template<class _T1, class _T2>
-    inline pair<typename std::decay<_T1>::type,
-		typename std::decay<_T2>::type>
+    inline pair<typename __decay_and_strip<_T1>::__type,
+		typename __decay_and_strip<_T2>::__type>
     make_pair(_T1&& __x, _T2&& __y)
     {
-      return pair<typename std::decay<_T1>::type,
-	          typename std::decay<_T2>::type>(std::forward<_T1>(__x),
-						  std::forward<_T2>(__y));
+      return pair<typename __decay_and_strip<_T1>::__type,
+	          typename __decay_and_strip<_T2>::__type>
+	(std::forward<_T1>(__x), std::forward<_T2>(__y));
     }
 #endif
 
Index: testsuite/20_util/decay/requirements/typedefs.cc
===================================================================
--- testsuite/20_util/decay/requirements/typedefs.cc	(revision 129993)
+++ testsuite/20_util/decay/requirements/typedefs.cc	(working copy)
@@ -34,8 +34,9 @@
   typedef decay<bool>::type     	test1_type;
   VERIFY( (is_same<test1_type, bool>::value) );
 
+  // NB: DR 705.
   typedef decay<const int>::type  	test2_type;
-  VERIFY( (is_same<test2_type, const int>::value) );
+  VERIFY( (is_same<test2_type, int>::value) );
 
   typedef decay<int[4]>::type     	test3_type;
   VERIFY( (is_same<test3_type, std::remove_extent<int[4]>::type*>::value) );

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