Книга: Standard Template Library Programmer
select2nd
Разделы на этой странице:
select2nd<Pair>
Category: functors
Component type: type
Description
Select2nd is a function object that takes a single argument, a pair [1], and returns the pair's second element.
Example
Print all of a map's values.
int main() {
map<int, double> M;
M[1] = 0.3;
M[47] = 0.8;
M[33] = 0.1;
transform(M.begin(), M.end(), ostream_iterator<double>(cout, " "), select2nd<map<int, double>::value_type>());
// The output is 0.3 0.1 0.8
}
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 |
---|---|
Pair |
The function object's argument type. |
Model of
Adaptable Unary Function
Type requirements
There exist some types U and V such that Pair provides the same interface as a pair<U,V>. [1]
Public base classes
unary_function<Pair, Pair::second_type>
Members
Member | Where defined | Description |
---|---|---|
argument_type |
Adaptable Unary Function | The type of select2nd's argument: Pair |
result_type |
Adaptable Unary Function | The type of the result: Pair::second_type |
const Pair::second_type& operator()(const Pair& p) const |
Adaptable Unary Function | Function call. The return value is p.second. |
New members
All of select2nd's members are defined in the Adaptable Unary Function requirements. Select2nd does not introduce any new members.
Notes
[1] Pair is not actually required to be a pair<U,V>, but merely to support the same interface as pair. In almost all cases the template parameter will be a pair, but it is occasionally useful for it to be something else. One example is a struct that has the members first, second, and third.
See also
identity, select1st, project1st, project2nd
- 1. Оператор Select – базовый оператор языка структурированных запросов
- 2.3.3 Selecting and Pasting
- Максимальное число дескрипторов для функции select
- Software Selection and Installation
- Window Selector
- select
- Selecting backup devices and media
- Selecting Specific Protocols
- Selecting a Group on Which to Operate
- Selecting a backup utility
- Displaying Titles from a Selected Publisher
- Раздел Select