Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
Standard C++ Library Module Reference Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

generate(), generate_n()

Module:  Standard C++ Library   Library:  Algorithms


Function

Local Index

No Entries

Summary

Algorithm that assigns each element in a range a value produced by repeated application of the given function object

Synopsis

#include <algorithm>

namespace std {
  template <class ForwardIterator, class Generator>
  void generate(ForwardIterator start, ForwardIterator finish,
                Generator gen);

  template <class OutputIterator, class Size, class Generator>
  void generate_n(OutputIterator start, Size n,
                  Generator gen);
}

Description

A value-generator function returns a value each time it is invoked. The algorithms generate() and generate_n() assign each element in the sequence [start, finish) or [start, start + n) the return value of the generator function gen(). The function gen() takes no arguments. (gen() can be a function or a class with an operator() defined that takes no arguments.)

generate_n() assumes that all iterators in the range [start, start + n] are dereferenceable, unless start is an insert iterator.

Complexity

The generate() and generate_n() algorithms invoke gen() and assign its return value exactly finish - start (or n) times.

Example

See Also

Function Objects

Standards Conformance

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



Previous fileTop of DocumentContentsIndex pageNext file

Copyright (c) 1994-2006 Rogue Wave Software, a Quovadx Division.
Licensed under the Apache License, Version 2.0.
Contact Rogue Wave about documentation or support issues. You can also seek help from other developers through the Apache stdcxx community (see below).

For more information on the Rogue Wave Standard C++ Library under open source, see Section 1.2 of the user's guide.