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 utility, and in the nonstandard backward-compatibility header function.h.

Requirements on types

The requirement for operator!= is that x == y is a valid expression for objects x and y of type T .

The requirement for operator> is that y < x is a valid expression for objects x and y of type T .

The requirement for operator<= is that y < x is a valid expression for objects x and y of type T .

The requirement for operator>= is that x < y is a valid expression for objects x and y of type T .

Preconditions

The precondition for operator!= is that x and y are in the domain of operator== .

The precondition for operator> , operator<= , and operator>= is that x and y are in the domain of operator< .

Example

template

void relations(T x, T y) {

if (x == y) assert(!(x != y));

else assert(x != y);

if (x < y) {

assert(x <= y);

assert(y > x);

assert(y >= x);

} else if (y < x) {

assert(y <= x);

assert(x < y);

assert(x <= y);

} else {

assert(x <= y);

assert(x >= y);

}

}

See also

Equality Comparable, LessThan Comparable

Classes

pair

Category: utilities

Component type: type

Description

Pair is a heterogeneous pair: it holds one object of type T1 and one of type T2 . A pair is much like a Container, in that it "owns" its elements. It is not actually a model of Container, though, because it does not support the standard methods (such as iterators) for accessing the elements of a Container.

Functions that need to return two values often return a pair .

Example

pair result = do_a_calculation();

if (result.first) do_something_more(result.second);

else report_error();

Definition

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

Template parameters
Parameter Description
T1 The type of the first element stored in the pair
T2 The type of the second element stored in the pair
Model of

Assignable

Type requirements

T1 and T2 must both be models of Assignable. Additional operations have additional requirements. Pair 's default constructor may only be used if both T1 and T2 are DefaultConstructible, operator== may only be used if both T1 and T2 are EqualityComparable, and operator< may only be used if both T1 and T2 are LessThanComparable.

Public base classes

None.

Members
Member Where defined Description
first_type pair See below.
second type pair See below.
pair() pair The default constructor. See below.
pair(const first_type&, const second_type&) pair The pair constructor. See below.
pair(const pair&) Assignable The copy constructor
pair& operator=(const pair&) Assignable The assignment operator
first pair See below.
second pair See below.
bool operator==(const pair&, const pair&) pair See below.
bool operator<(const pair&, const pair&) pair See below.
template pair make_pair(const T1&, const T2&) pair See below.
New members

These members are not defined in the Assignable requirements, but are specific to pair .

Member Description
first_type The type of the pair's first component. This is a typedef for the template parameter T1
second_type The type of the pair's second component. This is a typedef for the template parameter T2
pair() The default constructor. It uses constructs objects of types T1 and T2 using their default constructors. This constructor may only be used if both T1 and T2 are DefaultConstructible.
pair(const first_type& x, const second_type& y) The pair constructor. Constructs a pair such that first is constructed from x and second is constructed from y .
first Public member variable of type first_type : the first object stored in the pair .
second Public member variable of type second_type : The second object stored in the pair .
template bool operator==(const pair& x, const pair& y); The equality operator. The return value is true if and only the first elements of x and y are equal, and the second elements of x and y are equal. This operator may only be used if both T1 and T2 are EqualityComparable . This is a global function, not a member function.
template bool operator<(const pair& x, const pair& y); The comparison operator. It uses lexicographic comparison: the return value is true if the first element of x is less than the first element of y , and false if the first element of y is less than the first element of x . If neither of these is the case, then operator< returns the result of comparing the second elements of x and y . This operator may only be used if both T1 and T2 are LessThanComparable . This is a global function, not a member function.
template pair make_pair(const T1& x, const T2& x) Equivalent to pair(x, y) . This is a global function, not a member function. It exists only for the sake of convenience.
See also

Assignable, Default Constructible, LessThan Comparable

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

Интервал:

Закладка:

Сделать

Похожие книги на «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