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:24:47 UTC
svn commit: r354936 - /incubator/stdcxx/trunk/include/algorithm
Author: sebor
Date: Wed Dec 7 18:24:41 2005
New Revision: 354936
URL: http://svn.apache.org/viewcvs?rev=354936&view=rev
Log:
2005-12-07 Martin Sebor <se...@roguewave.com>
STDCXX-83
* algorithm (generate_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/algorithm
Modified: incubator/stdcxx/trunk/include/algorithm
URL: http://svn.apache.org/viewcvs/incubator/stdcxx/trunk/include/algorithm?rev=354936&r1=354935&r2=354936&view=diff
==============================================================================
--- incubator/stdcxx/trunk/include/algorithm (original)
+++ incubator/stdcxx/trunk/include/algorithm Wed Dec 7 18:24:41 2005
@@ -4,7 +4,7 @@
* algorithm - declarations and inline definitions of the C++ Standard
* Library algorithms
*
- * $Id: //stdlib/dev/include/algorithm#50 $
+ * $Id$
*
***************************************************************************
*
@@ -416,7 +416,11 @@
template <class _OutputIter, class _Size, class _Generator>
inline void generate_n (_OutputIter __first, _Size __n, _Generator __gen)
{
- for (; __n > 0; --__n, ++__first)
+ // 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 = __gen ();
}