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», без необходимости каждый раз заново искать на чём Вы остановились. Поставьте закладку, и сможете в любой момент перейти на страницу, на которой закончили чтение.
Интервал:
Закладка:
unary_compose
Categories: functors, adaptors
Component type: type
Unary_compose is a function object adaptor. If f and g are both Adaptable Unary Functions, and if g 's return type is convertible to f 's argument type, then unary_compose can be used to create a function object h such that h(x) is the same as f(g(x)) . [1] As with other function object adaptors, the easiest way to create a unary_compose is to use the helper function compose1 . It is possible to call unary_compose 's constructor directly, but there is usually no reason to do so.
Calculates the negative of the sines of the elements in a vector, where the elements are angles measured in degrees. Since the C library function sin takes its arguments in radians, this operation is the composition of three operations: negation, sin , and the conversion of degrees to radians.
vector angles;
vector sines;
const double pi = 3.14159265358979323846;
…
assert(sines.size() >= angles.size());
transform(angles.begin(), angles.end(), sines.begin(), compose1(negate(), compose1(ptr_fun(sin), bind2nd(multiplies(), pi / 180.))));
Defined in the standard header functional, and in the nonstandard backward-compatibility header function.h. The unary_compose class is an SGI extension; it is not part of the C++ standard.
| Parameter | Description |
|---|---|
AdaptableUnaryFunction1 |
The type of the first operand in the function composition operation. That is, if the composition is written f o g [1], then AdaptableUnaryFunction1 is the type of the function object f . |
AdaptableUnaryFunction2 |
The type of the second operand in the function composition operation. That is, if the composition is written f o g [1], then AdaptableUnaryFunction1 is the type of the function object g . |
Adaptable Unary Function
AdaptableUnaryFunction1 and AdaptableUnaryFunction2 must both be models of Adaptable Unary Function. AdaptableUnaryFunction2::result_type must be convertible to AdaptableUnaryFunction1::argument_type .
unary_function
| Member | Where defined | Description |
|---|---|---|
argument_type |
Adaptable Unary Function | The type of the function object's argument: AdaptableUnaryFunction2::argument_type . |
result_type |
Adaptable Unary Function | The type of the result: AdaptableUnaryFunction1::result_type |
unary_compose(const AdaptableUnaryFunction1& f, const AdaptableUnaryFunction2& g); |
unary_compose |
See below. |
template unary_compose compose1(const AdaptableUnaryFunction1& op1, const AdaptableUnaryFunction2& op2); |
unary_compose |
See below. |
These members are not defined in the Adaptable Unary Function requirements, but are specific to unary_compose .
| Member | Description |
|---|---|
unary_compose(const AdaptableUnaryFunction1& f, const AdaptableUnaryFunction2& g); |
The constructor. Constructs a unary_compose object that represents the function object f o g . [1] |
template unary_compose compose1(const AdaptableUnaryFunction1& op1, const AdaptableUnaryFunction2& op2); |
Creates a unary_compose object. If f and g are, respectively, of classes AdaptableUnaryFunction1 and AdaptableUnaryFunction2 , then compose1(f, g) is equivalent to unary_compose(f, g) , but is more convenient. This is a global function, not a member function. |
[1] This operation is called function composition, hence the name unary_compose . It is often represented in mathematics as the operation f o g , where f o g is a function such that (f o g)(x) == f(g(x)) . Function composition is a very important concept in algebra. It is also extremely important as a method of building software components out of other components, because it makes it possible to construct arbitrarily complicated function objects out of simple ones.
The function object overview, binary_compose , binder1st , binder2nd .
binary_compose
Categories: functors, adaptors
Component type: type
Binary_compose is a function object adaptor. If f is an Adaptable Binary Function and g1 and g2 are both Adaptable Unary Functions, and if g1 's and g2 's return types are convertible to f 's argument types, then binary_compose can be used to create a function object h such that h(x) is the same as f(g1(x), g2(x)) . [1] [2]
Finds the first element in a list that lies in the range from 1 to 10.
list L;
…
list::iterator in_range = find_if(L.begin(), L.end(), compose2(logical_and(), bind2nd(greater_equal(), 1), bind2nd(less_equal(), 10)));
assert(in_range == L.end() || (*in_range >= 1 && *in_range <= 10));
Computes sin(x)/(x + DBL_MIN) for each element of a range.
transform(first, last, first, compose2(divides(), ptr_fun(sin), bind2nd(plus(), DBL_MIN)));
Defined in the standard header functional, and in the nonstandard backward-compatibility header function.h. The binary_compose class is an SGI extension; it is not part of the C++ standard.
| Parameter | Description |
|---|---|
AdaptableBinaryFunction |
The type of the "outer" function in the function composition operation. That is, if the binary_compose is a function object h such that h(x) = f(g1(x), g2(x)) , then AdaptableBinaryFunction is the type of f . |
AdaptableUnaryFunction1 |
The type of the first "inner" function in the function composition operation. That is, if the binary_compose is a function object h such that h(x) = f(g1(x), g2(x)) , then AdaptableBinaryFunction is the type of g1 . |
AdaptableUnaryFunction2 |
The type of the second "inner" function in the function composition operation. That is, if the binary_compose is a function object h such that h(x) = f(g1(x), g2(x)) , then AdaptableBinaryFunction is the type of g2 . |
Adaptable Unary Function
Читать дальшеИнтервал:
Закладка:
Похожие книги на «Standard Template Library Programmer's Guide»
Представляем Вашему вниманию похожие книги на «Standard Template Library Programmer's Guide» списком для выбора. Мы отобрали схожую по названию и смыслу литературу в надежде предоставить читателям больше вариантов отыскать новые, интересные, ещё непрочитанные произведения.
Обсуждение, отзывы о книге «Standard Template Library Programmer's Guide» и просто собственные мнения читателей. Оставьте ваши комментарии, напишите, что Вы думаете о произведении, его смысле или главных героях. Укажите что конкретно понравилось, а что нет, и почему Вы так считаете.