📄 pai_5818.htm
字号:
<HTML><TITLE>pair</TITLE><BODY>
<A HREF="ref.htm"><IMG SRC="images/banner.gif"></A>
<P><STRONG>Click on the banner to return to the Class Reference home page.</STRONG></P>
<P>©Copyright 1996 Rogue Wave Software</P>
<H2>pair</H2>
<HR><PRE> Utility Class</PRE><HR>
<A NAME="Summary"><H3>Summary</H3></A>
<P>A template for heterogenous pairs of values.</P>
<H3>Contents</H3>
<UL>
<A HREF="#Synopsis"><LI>Synopsis</LI></A>
<A HREF="#Description"><LI>Description</LI></A>
<A HREF="#Interface"><LI>Interface</LI></A>
<A HREF="#Constructors and Destructors"><LI>Constructors and Destructors</LI></A>
<A HREF="#Non-member Operators"><LI>Non-member Operators</LI></A>
<A HREF="#Non-member Functions"><LI>Non-member Functions</LI></A>
</UL>
<A NAME="Synopsis"><H3>Synopsis</H3></A>
<PRE>#include <utility>
template <class T1, class T2>
struct <B>pair</B> ;</PRE>
<A NAME="Description"><H3>Description</H3></A>
<P>The <B><I>pair</B></I> class provides a template for encapsulating pairs of values that may be of different types.</P>
<A NAME="Interface"><H3>Interface</H3></A>
<PRE>template <class T1, class T2></PRE>
<PRE> struct pair {
T1 first;
T2 second;
pair();
pair (const T1&, const T2&);
~pair();
};
template <class T1, class T2>
bool operator== (const pair<T1, T2>&,
const pair T1, T2>&);
template <class T1, class T2>
bool operator< (const pair<T1, T2>&,
const pair T1, T2>&);
template <class T1, class T2>
pair<T1,T2> make_pair (const T1&, const T2&);
</PRE>
<A NAME="Constructors and Destructors"><H3>Constructors and Destructors</H3></A>
<PRE><B>pair </B>();</PRE>
<UL><P>Default contructor. Initializes <SAMP>first</SAMP> and <SAMP>second</SAMP> using their default constructors.</P>
</UL>
<PRE><B>pair</B> (const T1& x, const T2& y);</PRE>
<UL><P>The constructor creates a pair of types <SAMP>T1</SAMP> and <SAMP>T2</SAMP>, making the necessary conversions in<SAMP> x</SAMP> and <SAMP>y</SAMP>.</P>
</UL>
<PRE><B>~pair</B> ();</PRE>
<UL><P>Destructor.</P>
</UL>
<A NAME="Non-member Operators"><H3>Non-member Operators</H3></A>
<PRE>template <class T1, class T2>
bool <B>operator==</B> (const pair<T1, T2>& x,
const pair T1, T2>& y);</PRE>
<UL><P>Returns <SAMP>true</SAMP> if <SAMP>(x.first == y.first && x.second == y.second</SAMP>) is <SAMP>true</SAMP>. Otherwise it returns <SAMP>false</SAMP>.</P>
</UL>
<PRE>template <class T1, class T2>
bool <B>operator<</B> (const pair<T1, T2>& x,
const pair T1, T2>& y);</PRE>
<UL><P>Returns <SAMP>true</SAMP> if <SAMP>(x.first < y.first || (!(y.first < x.first) && x.second < y.second))</SAMP> is <SAMP>true</SAMP>. Otherwise it returns <SAMP>false</SAMP>.</P>
</UL>
<A NAME="Non-member Functions"><H3>Non-member Functions</H3></A>
<PRE>template <class T1, class T2>
pair<T1,T2>
<B>make_pair</B>(x,y);</PRE>
<UL><P><SAMP>make_pair(x,y)</SAMP> creates a pair by deducing and returning the types of <SAMP>x</SAMP> and <SAMP>y</SAMP>.</P>
</UL>
<HR>
<A HREF="Out_3702.htm"><IMG SRC="images/prev.gif"></A> <A HREF="ref.htm#contents"><IMG SRC="images/toc.gif"></A> <A HREF="par_4963.htm"><IMG SRC="images/next.gif"></A></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -