Add the missing default argument for the allocator and use a cleaner

implementation of previous().

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@136547 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Sean Hunt 2011-07-30 00:47:53 +00:00
parent b59b929cc9
commit 8f0396e443

View File

@ -21,7 +21,7 @@ namespace __gnu_cxx {
using namespace std; using namespace std;
template <class _Tp, class _Alloc> template <class _Tp, class _Alloc = allocator<_Tp> >
class _LIBCPP_VISIBLE slist : forward_list<_Tp, _Alloc> class _LIBCPP_VISIBLE slist : forward_list<_Tp, _Alloc>
{ {
public: public:
@ -105,12 +105,9 @@ template <class _Tp, class _Alloc>
inline _LIBCPP_INLINE_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY
typename slist<_Tp, _Alloc>::iterator slist<_Tp, _Alloc>::previous(iterator __pos) typename slist<_Tp, _Alloc>::iterator slist<_Tp, _Alloc>::previous(iterator __pos)
{ {
iterator __a = begin(), __b = end(); iterator __a = begin(), __b = begin();
while (__a != __pos) while (++__a != __pos)
{ ++__b;
__b = __a;
++__a;
}
return __b; return __b;
} }
@ -118,12 +115,9 @@ template <class _Tp, class _Alloc>
inline _LIBCPP_INLINE_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY
typename slist<_Tp, _Alloc>::const_iterator slist<_Tp, _Alloc>::previous(const_iterator __pos) typename slist<_Tp, _Alloc>::const_iterator slist<_Tp, _Alloc>::previous(const_iterator __pos)
{ {
iterator __a = begin(), __b = end(); iterator __a = begin(), __b = begin();
while (__a != __pos) while (++__a != __pos)
{ ++__b;
__b = __a;
++__a;
}
return __b; return __b;
} }