Standard Template Library Programmer's Guide

Здесь есть возможность читать онлайн «Standard Template Library Programmer's Guide» весь текст электронной книги совершенно бесплатно (целиком полную версию без сокращений). В некоторых случаях можно слушать аудио, скачать через торрент в формате fb2 и присутствует краткое содержание. Жанр: Программирование, Справочники, на английском языке. Описание произведения, (предисловие) а так же отзывы посетителей доступны на портале библиотеки ЛибКат.

Standard Template Library Programmer's Guide: краткое содержание, описание и аннотация

Предлагаем к чтению аннотацию, описание, краткое содержание или предисловие (зависит от того, что написал сам автор книги «Standard Template Library Programmer's Guide»). Если вы не нашли необходимую информацию о книге — напишите в комментариях, мы постараемся отыскать её.

This document contains reference on SGI STL implementation

Standard Template Library Programmer's Guide — читать онлайн бесплатно полную книгу (весь текст) целиком

Ниже представлен текст книги, разбитый по страницам. Система сохранения места последней прочитанной страницы, позволяет с удобством читать онлайн бесплатно книгу «Standard Template Library Programmer's Guide», без необходимости каждый раз заново искать на чём Вы остановились. Поставьте закладку, и сможете в любой момент перейти на страницу, на которой закончили чтение.

Тёмная тема
Сбросить

Интервал:

Закладка:

Сделать
Definition

Defined in the standard header iterator, and in the nonstandard backward-compatibility header iterator.h.

Requirements on types

• InputIterator is a model of Input Iterator.

• Distance is an integral type that is convertible to InputIterator 's distance type.

Preconditions

• i is nonsingular.

• Every iterator between i and i+n (inclusive) is nonsingular.

• If InputIterator is a model of input iterator or forward iterator, then n must be nonnegative. If InputIterator is a model of bidirectional iterator or random access iterator, then this precondition does not apply.

Complexity

Constant time if InputIterator is a model of random access iterator, otherwise linear time.

Example

list L;

L.push_back(0);

L.push_back(1);

list::iterator i = L.begin();

advance(i, 2);

assert(i == L.end());

See also

distance , Input iterator, Bidirectional Iterator, Random access iterator, iterator_traits , Iterator overview.

Iterator classes

istream_iterator

Category: iterators

Component type: type

Description

An istream_iterator is an Input Iterator that performs formatted input of objects of type T from a particular istream . When end of stream is reached, the istream_iterator takes on a special end of stream value, which is a past-the-end iterator. Note that all of the restrictions of an Input Iterator must be obeyed, including the restrictions on the ordering of operator* and operator++ operations.

Example

Fill a vector with values read from standard input.

vector V;

copy(istream_iterator(cin), istream_iterator(), back_inserter(V));

Definition

Defined in the standard header iterator, and in the nonstandard backward-compatibility header iterator.h.

Template parameters
Parameter Description Default
T The istream_iterator 's value type. Operator* returns a const T& .
Distance The istream_iterator 's distance type. ptrdiff_t
Model of

Input Iterator

Type requirements

The value type T must be a type such that cin >> T is a valid expression.

The value type T must be a model of Default Constructible.

The distance type must, as described in the Input Iterator requirements, be a signed integral type.

Public base classes

None.

Members
Member Where defined Description
istream_iterator() istream_iterator See below.
istream_iterator(istream&) istream_iterator See below.
istream_iterator(const istream_iterator&) Trivial Iterator The copy constructor
istream_iterator& operator=(const istream_iterator&) Trivial Iterator The assignment operator
const T& operator*() const Input Iterator Returns the next object in the stream.
istream_iterator& operator++() Input Iterator Preincrement.
istream_iterator& operator++(int) Input Iterator Postincrement.
bool operator==(const istream_iterator&, const istream_iterator&) Trivial iterator The equality operator. This is a global function, not a member function.
input_iterator_tag iterator_category(const istream_iterator&) iterator tags Returns the iterator's category.
T* value_type(const istream_iterator&) iterator tags Returns the iterator's value type.
Distance* distance_type(const istream_iterator&) iterator tags Returns the iterator's distance type.
New members

These members are not defined in the Input Iterator requirements, but are specific to istream_iterator .

Function Description
istream_iterator() The default constructor: Constructs an end-of-stream iterator. This is a past-the-end iterator, and it is useful when constructing a "range".
istream_iterator(istream& s) Creates an istream_iterator that reads values from the input stream s . When s reaches end of stream, this iterator will compare equal to an end-of-stream iterator created using the default constructor.
See also

ostream_iterator, Input Iterator, Output Iterator.

ostream_iterator

Category: iterators

Component type: type

Description

An ostream_iterator is an Output Iterator that performs formatted output of objects of type T to a particular ostream . Note that all of the restrictions of an Output Iterator must be obeyed, including the restrictions on the ordering of operator* and operator++ operations.

Example

Copy the elements of a vector to the standard output, one per line.

vector V;

// …

copy(V.begin(), V.end(), ostream_iterator(cout, "\n"));

Definition

Defined in the standard header iterator, and in the nonstandard backward-compatibility header iterator.h.

Template parameters
Parameter Description
T The type of object that will be written to the ostream . The set of value types of an ostream_iterator consists of a single type, T .
Model of

Output Iterator.

Type requirements

T must be a type such that cout << T is a valid expression.

Public base classes

None.

Members
Member Where defined Description
ostream_iterator(ostream&) ostream_iterator See below.
ostream_iterator(ostream&, const char* s) ostream_iterator See below.
ostream_iterator(const ostream_iterator&) Output Iterator The copy constructor
ostream_iterator& operator=(const ostream_iterator&) Output Iterator The assignment operator
ostream_iterator& operator=(const T&) Output Iterator Used to implement the Output Iterator requirement *i = t . [1]
ostream_iterator& operator*() Output Iterator Used to implement the Output Iterator requirement *i = t . [1]
ostream_iterator& operator++() Output Iterator Preincrement
ostream_iterator& operator++(int) Output Iterator Postincrement
output_iterator_tag iterator_category(const ostream_iterator&) iterator tags Returns the iterator's category.
New members

These members are not defined in the Output Iterator requirements, but are specific to ostream_iterator .

Читать дальше
Тёмная тема
Сбросить

Интервал:

Закладка:

Сделать

Похожие книги на «Standard Template Library Programmer's Guide»

Представляем Вашему вниманию похожие книги на «Standard Template Library Programmer's Guide» списком для выбора. Мы отобрали схожую по названию и смыслу литературу в надежде предоставить читателям больше вариантов отыскать новые, интересные, ещё непрочитанные произведения.


Отзывы о книге «Standard Template Library Programmer's Guide»

Обсуждение, отзывы о книге «Standard Template Library Programmer's Guide» и просто собственные мнения читателей. Оставьте ваши комментарии, напишите, что Вы думаете о произведении, его смысле или главных героях. Укажите что конкретно понравилось, а что нет, и почему Вы так считаете.

x