Standard Template Library Programmer's Guide
Здесь есть возможность читать онлайн «Standard Template Library Programmer's Guide» весь текст электронной книги совершенно бесплатно (целиком полную версию без сокращений). В некоторых случаях можно слушать аудио, скачать через торрент в формате fb2 и присутствует краткое содержание. Жанр: Программирование, Справочники, на английском языке. Описание произведения, (предисловие) а так же отзывы посетителей доступны на портале библиотеки ЛибКат.
- Название:Standard Template Library Programmer's Guide
- Автор:
- Жанр:
- Год:неизвестен
- ISBN:нет данных
- Рейтинг книги:4 / 5. Голосов: 1
-
Избранное:Добавить в избранное
- Отзывы:
-
Ваша оценка:
- 80
- 1
- 2
- 3
- 4
- 5
Standard Template Library Programmer's Guide: краткое содержание, описание и аннотация
Предлагаем к чтению аннотацию, описание, краткое содержание или предисловие (зависит от того, что написал сам автор книги «Standard Template Library Programmer's Guide»). Если вы не нашли необходимую информацию о книге — напишите в комментариях, мы постараемся отыскать её.
Standard Template Library Programmer's Guide — читать онлайн бесплатно полную книгу (весь текст) целиком
Ниже представлен текст книги, разбитый по страницам. Система сохранения места последней прочитанной страницы, позволяет с удобством читать онлайн бесплатно книгу «Standard Template Library Programmer's Guide», без необходимости каждый раз заново искать на чём Вы остановились. Поставьте закладку, и сможете в любой момент перейти на страницу, на которой закончили чтение.
Интервал:
Закладка:
[3] After executing ++i , it is not required that copies of the old value of i be dereferenceable or that they be in the domain of operator== .
[4] It is not guaranteed that it is possible to pass through the same input iterator twice.
Output Iterator, Iterator overview
Output Iterator
Category: iterators
Component type: concept
An Output Iterator is a type that provides a mechanism for storing (but not necessarily accessing) a sequence of values. Output Iterators are in some sense the converse of Input Iterators, but they have a far more restrictive interface: they do not necessarily support member access or equality, and they do not necessarily have either an associated distance type or even a value type [1]. Intuitively, one picture of an Output Iterator is a tape: you can write a value to the current location and you can advance to the next location, but you cannot read values and you cannot back up or rewind.
Assignable, DefaultConstructible
None. [1]
X
A type that is a model of Output Iterator
x, y
Object of type X
If x is an Output Iterator of type X , then the expression *x = t; stores the value t into x . Note that operator= , like other C++ functions, may be overloaded; it may, in fact, even be a template function. In general, then, t may be any of several different types. A type T belongs to the set of value types of X if, for an object t of type T , *x = t; is well-defined and does not require performing any non-trivial conversions on t . [1]
An Output Iterator may be singular , meaning that the results of most operations, including copying and dereference assignment, are undefined. The only operation that is guaranteed to be supported is assigning a nonsingular iterator to a singular iterator.
An Output Iterator may be dereferenceable , meaning that assignment through it is defined. Dereferenceable iterators are always nonsingular, but nonsingular iterators are not necessarily dereferenceable.
Name | Expression | Type requirements | Return type |
---|---|---|---|
Default constructor | X x; X() |
||
Copy constructor | X(x) |
X |
|
Copy constructor | X y(x); or X y = x; |
||
Dereference assignment | *x = t |
t is convertible to a type in the set of value types of X . [1] | Result is not used |
Preincrement | ++x |
X& |
|
Postincrement | (void) x++ |
void |
|
Postincrement and assign | *x++ = t; |
Result is not used |
Name | Expression | Precondition | Semantics | Postcondition |
---|---|---|---|---|
Default constructor | X x; X() |
x may be singular | ||
Copy constructor | X(x) |
x is nonsingular | *X(x) = t is equivalent to *x = t [2] | |
Copy constructor | X x(y); or X x = y; |
y is nonsingular | *y = t is equivalent to *x = t [2] | |
Dereference assignment | *x = t |
x is dereferenceable. If there has been a previous assignment through x , then there has been an intervening increment. [3] | ||
Preincrement | ++x |
x is dereferenceable. x has previously been assigned through. If x has previously been incremented, then there has been an intervening assignment through x [3] [4] | x points to the next location into which a value may be stored | |
Postincrement | (void) x++ |
x is dereferenceable. x has previously been assigned through. | Equivalent to (void) ++x | x points to the next location into which a value may be stored |
Postincrement and assign | *x++ = t; |
x is dereferenceable. If there has been a previous assignment through x , then there has been an intervening increment. [3] [4] | Equivalent to {*x = t; ++x; } | x points to the next location into which a value may be stored |
The complexity of operations on output iterators is guaranteed to be amortized constant time.
• ostream_iterator
• insert_iterator
• front_insert_iterator
• back_insert_iterator
Notes
[1] Other iterator types, including Trivial Iterator and Input Iterator, define the notion of a value type , the type returned when an iterator is dereferenced. This notion does not apply to Output Iterators, however, since the dereference operator (unary operator* ) does not return a usable value for Output Iterators. The only context in which the dereference operator may be used is assignment through an output iterator: *x = t . Although Input Iterators and output iterators are roughly symmetrical concepts, there is an important sense in which accessing and storing values are not symmetrical: for an Input Iterator ы operator* must return a unique type, but, for an Output Iterator, in the expression *x = t , there is no reason why operator= must take a unique type. [5] Consequently, there need not be any unique "value type" for Output Iterators.
[2] There should be only one active copy of a single Output Iterator at any one time. That is: after creating and using a copy x of an Output Iterator y , the original output iterator y should no longer be used.
[3] Assignment through an Output Iterator x is expected to alternate with incrementing x , and there must be an assignment through x before x is ever incremented. Any other order of operations results in undefined behavior. That is: {*x = t ; ++x; *x = t2; ++x} is acceptable, but {*x = t; ++x; ++x; *x = t2;} is not.
[4] Note that an Output Iterator need not define comparison for equality. Even if an operator== is defined, x == y need not imply ++x == ++y .
[5] If you are implementing an Output Iterator class X , one sensible way to define *x = t is to define X::operator*() to return an object of some private class X_proxy , and then to define X_proxy::operator= . Note that you may overload X_proxy::operator= , or even define it as a member template; this allows assignment of more than one type through Output Iterators of class X .
Trivial Iterator, Input Iterator, Iterator overview
Forward Iterator
Category: iterators
Component type: concept
A Forward Iterator is an iterator that corresponds to the usual intuitive notion of a linear sequence of values. It is possible to use Forward Iterators (unlike Input Iterators and Output Iterators) in multipass algorithms. Forward Iterators do not, however, allow stepping backwards through a sequence, but only, as the name suggests, forward.
Читать дальшеИнтервал:
Закладка:
Похожие книги на «Standard Template Library Programmer's Guide»
Представляем Вашему вниманию похожие книги на «Standard Template Library Programmer's Guide» списком для выбора. Мы отобрали схожую по названию и смыслу литературу в надежде предоставить читателям больше вариантов отыскать новые, интересные, ещё непрочитанные произведения.
Обсуждение, отзывы о книге «Standard Template Library Programmer's Guide» и просто собственные мнения читателей. Оставьте ваши комментарии, напишите, что Вы думаете о произведении, его смысле или главных героях. Укажите что конкретно понравилось, а что нет, и почему Вы так считаете.