stlab.adobe.com Adobe Systems Incorporated

select1st

functors.gif
type.gif
Category: functors Component type: type

Description

Select1st is a functors that takes a single argument, a pair [1], and returns the pair's first element.

Example

Print all of a Map's keys.

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<int>(cout, " "),
            select1st<Map<int, double>::value_type>());
  // The output is  1 33 47.
}

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 Default
Pair The function object's argument type.  

Model of

AdaptableUnaryFunctionAdaptableUnaryFunctionAdaptableUnaryFunction

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::first_type>

Members

Member Where defined Description
argument_type AdaptableUnaryFunction The type of select1st's argument: Pair
result_type AdaptableUnaryFunction The type of the result: Pair::first_type
const Pair::first_type&
operator()(const Pair& p) const
AdaptableUnaryFunction Function call. The return value is p.first.

New members

All of select1st's members are defined in the AdaptableUnaryFunction requirements. Select1st 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, select2nd, project1st, project2nd

Copyright © 2006-2007 Adobe Systems Incorporated.

Use of this website signifies your agreement to the Terms of Use and Online Privacy Policy.

Search powered by Google