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», без необходимости каждый раз заново искать на чём Вы остановились. Поставьте закладку, и сможете в любой момент перейти на страницу, на которой закончили чтение.

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

Интервал:

Закладка:

Сделать
Public base classes

binary_function

Members
Member Where defined Description
first_argument_type Adaptable Binary Function The type of the first argument: T
second_argument_type Adaptable Binary Function The type of the second argument: T
result_type Adaptable Binary Function The type of the result: bool
bool operator()(const T& x, const T& y) const Binary Function Function call operator. The return value is x || y .
logical_or() Default Constructible The default constructor.
New members

All of logical_or 's members are defined in the Adaptable Binary Function and Default Constructible requirements. Logical_or does not introduce any new members.

Notes

[1] Logical_and and logical_or are not very useful by themselves. They are mainly useful because, when combined with the function object adaptor binary_compose , they perform logical operations on other function objects.

See also

The function object overview, logical_and , logical_not .

logical_not

Category: functors

Component type: type

Description

Logical_not is a function object; specifically, it is an Adaptable Predicate, which means it is a function object that tests the truth or falsehood of some condition. If f is an object of class logical_not and x is an object of class T (where T is convertible to bool ) then f(x) returns true if and only if x is false .

Example

Transforms a vector of bool into its logical complement.

vector V;

transform(V.begin(), V.end(), V.begin(), logical_not());

Definition

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

Template parameters
Parameter Description
T The type of logical_not 's argument
Model of

Adaptable Predicate, DefaultConstructible

Type requirements

T must be convertible to bool .

Public base classes

unary_function

Members
Member Where defined Description
argument_type Adaptable Unary Function The type of the second argument: T
result_type Adaptable Unary Function The type of the result: bool
bool operator()(const T& x) const Unary Function Function call operator. The return value is !x .
logical_not() Default Constructible The default constructor.
See also

The function object overview, logical_or , logical_and .

Generalized identity operations

identity

Category: functors

Component type: type

Description

Identity is a Unary Function that represents the identity function: it takes a single argument x , and returns x .

Example

int main() {

int x = 137;

identity id;

assert(x == id(x));

}

Definition

Defined in the standard header functional, and in the nonstandard backward-compatibility header function.h. This class is an SGI extension; it is not part of the C++ standard.

Template parameters
Parameter Description
T The function object's argument type, and return type. [1]
Model of

Adaptable Unary Function

Type requirements

None.

Public base classes

unary_function

Members
Member Where defined Description
argument_type Adaptable Unary Function The type of identity 's argument: T .
result_type Adaptable Unary Function The type of the result: T . [1]
const T& operator()(const T&) const Adaptable Unary Function Function call. The return value is simply the argument.
New members

All of identity 's members are defined in the Adaptable Unary Function requirements. Identity does not introduce any new members.

Notes

[1] It is essential that the return type and the argument type are the same: generalizing identity to allow them to differ would not work. The reason is that identity returns a const reference to its argument, rather than a copy of its argument. If identity were allowed to perform a conversion, then this would be a dangling reference.

See also

The function object overview, select1st , select2nd , project1st , project2nd

project1st

Category: functors

Component type: type

Description

Project1st is a function object that takes two arguments and returns its first argument; the second argument is unused. It is essentially a generalization of identity to the case of a Binary Function.

Example

int main() {

vector v1(10, 137);

vector v2(10, (char*) 0);

vector result(10);

transform(v1.begin(), v1.end(), v2.begin(), result.begin(), project1st());

assert(equal(v1.begin(), v1.end(), result.begin()));

}

Definition

Defined in the standard header functional, and in the nonstandard backward-compatibility header function.h. This function object is an SGI extension; it is not part of the C++ standard.

Template parameters
Parameter Description
Arg1 project1st 's first argument type, and its result type.
Arg2 project1st 's second argument type.
Model of

Adaptable Binary Function

Type requirements

None.

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

Интервал:

Закладка:

Сделать

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