<utility>namespace std {
// TEMPLATE CLASSES
template<class T, class U>
struct pair;
// TEMPLATE FUNCTIONS
template<class T, class U>
pair<T, U> make_pair(const T& x, const U& y);
template<class T, class U>
bool operator==(const pair<T, U>& x,
const pair<T, U>& y);
template<class T, class U>
bool operator!=(const pair<T, U>& x,
const pair<T, U>& y);
template<class T, class U>
bool operator<(const pair<T, U>& x,
const pair<T, U>& y);
template<class T, class U>
bool operator>(const pair<T, U>& x,
const pair<T, U>& y);
template<class T, class U>
bool operator<=(const pair<T, U>& x,
const pair<T, U>& y);
template<class T, class U>
bool operator>=(const pair<T, U>& x,
const pair<T, U>& y);
namespace rel_ops {
template<class T>
bool operator!=(const T& x, const T& y);
template<class T>
bool operator<=(const T& x, const T& y);
template<class T>
bool operator>(const T& x, const T& y);
template<class T>
bool operator>=(const T& x, const T& y);
};
};
Include the STL
standard header <utility> to define
several templates of general use throughout the Standard Template
Library.
Four template operators -- operator!=, operator<=,
operator>, and operator>= --
define a total ordering on
pairs of operands of the same type, given definitions of operator==
and operator<.
If an implementation
supports namespaces, these template operators are defined in the rel_ops namespace, nested within
the std namespace. If you wish to make use of these
template operators, write the declaration:
using namespace std::rel_ops;
which promotes the template operators into the current namespace.
make_pairtemplate<class T, class U>
pair<T, U> make_pair(const T& x, const U& y);
The template function returns pair<T, U>(x, y).
operator!=template<class T>
bool operator!=(const T& x, const T& y);
template<class T, class U>
bool operator!=(const pair<T, U>& x,
const pair<T, U>& y);
The template function returns !(x == y).
operator==template<class T, class U>
bool operator==(const pair<T, U>& x,
const pair<T, U>& y);
The template function returns x.first == y.first
&& x.second == y.second.
operator<template<class T, class U>
bool operator<(const pair<T, U>& x,
const pair<T, U>& y);
template<class T, class U>
bool operator<(const pair<T, U>& x,
const pair<T, U>& y);
The template function returns x.first < y.first ||
!(y.first < x.first && x.second < y.second.
operator<=template<class T>
bool operator<=(const T& x, const T& y);
template<class T, class U>
bool operator<=(const pair<T, U>& x,
const pair<T, U>& y);
The template function returns !(y < x).
operator>template<class T>
bool operator>(const T& x, const T& y);
template<class T, class U>
bool operator>(const pair<T, U>& x,
const pair<T, U>& y);
The template function returns y < x.
operator>=template<class T>
bool operator>=(const T& x, const T& y);
template<class T, class U>
bool operator>=(const pair<T, U>& x,
const pair<T, U>& y);
The template function returns !(x < y).
pairtemplate<class T, class U>
struct pair {
typedef T first_type;
typedef U second_type
T first;
U second;
pair();
pair(const T& x, const U& y);
template<class V, class W>
pair(const pair<V, W>& pr);
};
The template class stores a pair of objects, first, of type T,
and second, of
type U. The type definition first_type, is the
same as the template parameter T, while second_type, is the
same as the template parameter U.
The first (default) constructor initializes first
to T() and second to U().
The second constructor initializes first to x
and second to y. The third (template)
constructor initializes first to pr.first
and second to pr.second. T
and U each need supply only a default constructor,
single-argument constructor, and a destructor.
See also the Table of Contents .
Copyright © 1992-1996 by P.J. Plauger. Portions derived from work copyright © 1994 by Hewlett-Packard Company. All rights reserved.