[cfe-commits] [libcxx] r136547 - /libcxx/trunk/include/ext/slist

Sean Hunt scshunt at csclub.uwaterloo.ca
Fri Jul 29 17:47:53 PDT 2011


Author: coppro
Date: Fri Jul 29 19:47:53 2011
New Revision: 136547

URL: http://llvm.org/viewvc/llvm-project?rev=136547&view=rev
Log:
Add the missing default argument for the allocator and use a cleaner
implementation of previous().

Modified:
    libcxx/trunk/include/ext/slist

Modified: libcxx/trunk/include/ext/slist
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/ext/slist?rev=136547&r1=136546&r2=136547&view=diff
==============================================================================
--- libcxx/trunk/include/ext/slist (original)
+++ libcxx/trunk/include/ext/slist Fri Jul 29 19:47:53 2011
@@ -21,7 +21,7 @@
 
 using namespace std;
 
-template <class _Tp, class _Alloc>
+template <class _Tp, class _Alloc = allocator<_Tp> >
 class _LIBCPP_VISIBLE slist : forward_list<_Tp, _Alloc>
 {
 public:
@@ -105,12 +105,9 @@
 inline _LIBCPP_INLINE_VISIBILITY
 typename slist<_Tp, _Alloc>::iterator slist<_Tp, _Alloc>::previous(iterator __pos)
 {
-  iterator __a = begin(), __b = end();
-  while (__a != __pos)
-  {
-    __b = __a;
-    ++__a;
-  }
+  iterator __a = begin(), __b = begin();
+  while (++__a != __pos)
+    ++__b;
   return __b;
 }
 
@@ -118,12 +115,9 @@
 inline _LIBCPP_INLINE_VISIBILITY
 typename slist<_Tp, _Alloc>::const_iterator slist<_Tp, _Alloc>::previous(const_iterator __pos)
 {
-  iterator __a = begin(), __b = end();
-  while (__a != __pos)
-  {
-    __b = __a;
-    ++__a;
-  }
+  iterator __a = begin(), __b = begin();
+  while (++__a != __pos)
+    ++__b;
   return __b;
 }
 





More information about the cfe-commits mailing list