Previous fileTop of DocumentContentsIndex pageNext file
Apache C++ Standard Library Reference Guide

fill(), fill_n()

Library:  Algorithms


Function

Local Index

No Entries

Summary

Algorithm that assigns the same value to the elements in a given range

Synopsis

#include <algorithm>

namespace std {
  template <class ForwardIterator, class T>
   void fill(ForwardIterator start, ForwardIterator finish,
             const T& value);

  template <class OutputIterator, class Size, class T>
  void fill_n(OutputIterator start, Size n, const T& value);
}

Description

The fill() and fill_n() algorithms are used to assign a value to the elements in a sequence. fill() assigns the value to all the elements designated by iterators in the range [start, finish).

The fill_n() algorithm assigns the value to all the elements designated by iterators in the range [start, start + n). fill_n() assumes that all iterators in the range [start, start + n) are dereferenceable, unless start is an insert iterator.

Type T must be Assignable, and Size must be convertible to an integral type.

Complexity

fill() makes exactly finish - start assignments, and fill_n() makes exactly n assignments.

Example

See Also

Algorithms

Standards Conformance

ISO/IEC 14882:1998 -- International Standard for Information Systems -- Programming Language C++, Section 25.2.5



Previous fileTop of DocumentContentsIndex pageNext file