This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ 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]

Re: [Patch] Clean up tr1/tuple


Hi again Doug,

Should we rename the get()'s above to __get_helper, and put in
forwarding get()'s with exact signatures?

Just tested the below, looks ok to you?


Paolo.

/////////////
2007-03-19  Paolo Carlini  <pcarlini@suse.de>

	* include/tr1/tuple (get(_Tuple_impl<>&, get(const _Tuple_impl<>&):
	Rename as __get_helper.
	(get(tuple<>&, get(const tuple<>&)): Forward to the latter.
Index: tuple
===================================================================
--- tuple	(revision 123017)
+++ tuple	(working copy)
@@ -269,22 +269,40 @@
   template<typename... _Elements>
     const int tuple_size<tuple<_Elements...> >::value;
 
-  // Returns a const reference to the ith element of a tuple.
-  // Any const or non-const ref elements are returned with their original type.
   template<int __i, typename _Head, typename... _Tail>
     inline typename __add_ref<_Head>::type
-    get(_Tuple_impl<__i, _Head, _Tail...>& __t)
+    __get_helper(_Tuple_impl<__i, _Head, _Tail...>& __t)
     {
       return __t._M_head;
     }
 
   template<int __i, typename _Head, typename... _Tail>
     inline typename __add_c_ref<_Head>::type
-    get(const _Tuple_impl<__i, _Head, _Tail...>& __t)
+    __get_helper(const _Tuple_impl<__i, _Head, _Tail...>& __t)
     {
       return __t._M_head;
     }
 
+  // Return a reference (const reference) to the ith element of a tuple.
+  // Any const or non-const ref elements are returned with their original type.
+  template<int __i, typename... _Elements>
+    inline typename __add_ref<
+                      typename tuple_element<__i, tuple<_Elements...> >::type
+                    >::type
+    get(tuple<_Elements...>& __t)
+    { 
+      return __get_helper<__i>(__t); 
+    }
+
+  template<int __i, typename... _Elements>
+    inline typename __add_c_ref<
+                      typename tuple_element<__i, tuple<_Elements...> >::type
+                    >::type
+    get(const tuple<_Elements...>& __t)
+    {
+      return __get_helper<__i>(__t);
+    }
+
   // This class helps construct the various comparison operations on tuples
   template<int __check_equal_size, int __i, int __j,
 	   typename _Tp, typename _Up>

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