You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stdcxx.apache.org by se...@apache.org on 2005/12/08 03:27:23 UTC
svn commit: r354938 - /incubator/stdcxx/trunk/include/rw/_algobase.h
Author: sebor
Date: Wed Dec 7 18:27:16 2005
New Revision: 354938
URL: http://svn.apache.org/viewcvs?rev=354938&view=rev
Log:
2005-12-07 Martin Sebor <se...@roguewave.com>
STDCXX-84
* _algobase.h (fill_n): Removed the assumption that the Size argument
is modifiable and can be predecremented and instead converted it to
ptrdiff_t and manipulated the converted object.
Modified:
incubator/stdcxx/trunk/include/rw/_algobase.h
Modified: incubator/stdcxx/trunk/include/rw/_algobase.h
URL: http://svn.apache.org/viewcvs/incubator/stdcxx/trunk/include/rw/_algobase.h?rev=354938&r1=354937&r2=354938&view=diff
==============================================================================
--- incubator/stdcxx/trunk/include/rw/_algobase.h (original)
+++ incubator/stdcxx/trunk/include/rw/_algobase.h Wed Dec 7 18:27:16 2005
@@ -6,7 +6,7 @@
* This is an internal header file used to implement the C++ Standard
* Library. It should never be #included directly by a program.
*
- * $Id: //stdlib/dev/include/rw/_algobase.h#25 $
+ * $Id$
*
***************************************************************************
*
@@ -115,10 +115,14 @@
template <class _OutputIter, class _Size, class _TypeT>
-inline void fill_n (_OutputIter __first, _Size __n, const _TypeT& __value)
+inline void fill_n (_OutputIter __first, _Size __n, const _TypeT &__val)
{
- for (;__n > 0;--__n, ++__first)
- *__first = __value;
+ // Size must be convertible to integral type but need not itself be one
+ // Complexity:
+ // Exactly n if n is positive, or 0 otherwise, assignments.
+ // (see lwg issue 426 for the complexity when n is not positive)
+ for (_RWSTD_PTRDIFF_T __inx = __n; 0 < __inx; --__inx, ++__first)
+ *__first = __val;
}