Rewrote iota_n to use pre-increment instead of post - now the same as iota. Added a test for 0 as well.

[SVN r85465]
This commit is contained in:
Marshall Clow
2013-08-25 16:29:01 +00:00
parent fc0fe6af52
commit fe51eb60a9
2 changed files with 8 additions and 4 deletions

View File

@ -63,8 +63,8 @@ void iota ( Range &r, T value )
template <typename OutputIterator, typename T>
OutputIterator iota_n ( OutputIterator out, T value, std::size_t n )
{
while ( n-- > 0 )
*out++ = value++;
for ( ; n > 0; --n, ++value )
*out++ = value;
return out;
}