1339. uninitialized_fill_n should return the end of its range

Section: 23.10.11.6 [uninitialized.fill] Status: C++11 Submitter: Jared Hoberock Opened: 2010-07-14 Last modified: 2017-06-16

Priority: Not Prioritized

View all issues with C++11 status.

Discussion:

N3092's specification of uninitialized_fill_n discards useful information and is inconsistent with other algorithms such as fill_n which accept an iterator and a size. As currently specified, unintialized_fill_n requires an additional linear traversal to find the end of the range.

Instead of returning void, unintialized_fill_n should return one past the last iterator it dereferenced.

[ Post-Rapperswil: ]

Moved to Tentatively Ready after 5 positive votes on c++std-lib.

[ Adopted at 2010-11 Batavia ]

Proposed resolution:

In section 23.10 [memory] change:,

template <class ForwardIterator, class Size, class T>
  void ForwardIterator uninitialized_fill_n(ForwardIterator first, Size n, const T& x);

In section [uninitialized.fill.n] change,

template <class ForwardIterator, class Size, class T>
  void ForwardIterator uninitialized_fill_n(ForwardIterator first, Size n, const T& x);

1 Effects:

for (; n--; ++first)
  ::new (static_cast<void*>(&*first))
    typename iterator_traits<ForwardIterator>::value_type(x);
return first;