247 lines
8.7 KiB
HTML
247 lines
8.7 KiB
HTML
<!--
|
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
|
contributor license agreements. See the NOTICE file distributed
|
|
with this work for additional information regarding copyright
|
|
ownership. The ASF licenses this file to you under the Apache
|
|
License, Version 2.0 (the License); you may not use this file
|
|
except in compliance with the License. You may obtain a copy of
|
|
the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
implied. See the License for the specific language governing
|
|
permissions and limitations under the License.
|
|
|
|
Copyright 1999-2007 Rogue Wave Software, Inc.
|
|
-->
|
|
|
|
<HTML>
|
|
<HEAD>
|
|
<TITLE>pair</TITLE>
|
|
<LINK REL=StyleSheet HREF="../rw.css" TYPE="text/css" TITLE="Apache stdcxx Stylesheet"></HEAD>
|
|
<BODY BGCOLOR=#FFFFFF>
|
|
<A HREF="overflow-error.html"><IMG SRC="images/bprev.gif" WIDTH=20 HEIGHT=21 ALT="Previous file" BORDER=O></A><A HREF="noframes.html"><IMG SRC="images/btop.gif" WIDTH=56 HEIGHT=21 ALT="Top of Document" BORDER=O></A><A HREF="booktoc.html"><IMG SRC="images/btoc.gif" WIDTH=56 HEIGHT=21 ALT="Contents" BORDER=O></A><A HREF="tindex.html"><IMG SRC="images/bindex.gif" WIDTH=56 HEIGHT=21 ALT="Index page" BORDER=O></A><A HREF="partial-sort.html"><IMG SRC="images/bnext.gif" WIDTH=25 HEIGHT=21 ALT="Next file" BORDER=O></A><DIV CLASS="DOCUMENTNAME"><B>Apache C++ Standard Library Reference Guide</B></DIV>
|
|
<H2>pair</H2>
|
|
<P><B>Library:</B> <A HREF="2-4.html">General utilities</A></P>
|
|
|
|
<PRE><HR><B><I>Does not inherit</I></B><HR></PRE>
|
|
|
|
<UL>
|
|
<LI><A HREF="#sec1">Local Index</A></LI>
|
|
<LI><A HREF="#sec2">Summary</A></LI>
|
|
<LI><A HREF="#sec3">Synopsis</A></LI>
|
|
<LI><A HREF="#sec4">Description</A></LI>
|
|
<LI><A HREF="#sec5">Interface</A></LI>
|
|
<LI><A HREF="#sec6">Member Types</A></LI>
|
|
<LI><A HREF="#sec7">Constructors</A></LI>
|
|
<LI><A HREF="#sec8">Destructor</A></LI>
|
|
<LI><A HREF="#sec9">Nonmember Operators</A></LI>
|
|
<LI><A HREF="#sec10">Nonmember Functions</A></LI>
|
|
<LI><A HREF="#sec11">See Also</A></LI>
|
|
<LI><A HREF="#sec12">Standards Conformance</A></LI>
|
|
</UL>
|
|
<A NAME="sec1"><H3>Local Index</H3></A>
|
|
<H4>Members</H4>
|
|
<UL><TABLE CELLPADDING=3>
|
|
<TR><TD VALIGN=top>
|
|
<A HREF="#idx1091">first_type</A><BR>
|
|
</TD>
|
|
<TD VALIGN=top><A HREF="#idx1093">pair()</A><BR>
|
|
</TD>
|
|
<TD VALIGN=top><A HREF="#idx1092">second_type</A><BR>
|
|
</TD>
|
|
<TD VALIGN=top><A HREF="#idx1096">~pair()</A><BR>
|
|
</TD></TR>
|
|
</TABLE></UL>
|
|
<H4>Non-Members</H4>
|
|
<UL><TABLE CELLPADDING=3>
|
|
<TR><TD VALIGN=top>
|
|
<A HREF="#idx1103">make_pair()</A><BR>
|
|
<A HREF="#idx1098">operator!=()</A><BR>
|
|
</TD>
|
|
<TD VALIGN=top><A HREF="#idx1100">operator>()</A><BR>
|
|
<A HREF="#idx1102">operator>=()</A><BR>
|
|
</TD>
|
|
<TD VALIGN=top><A HREF="#idx1099">operator<()</A><BR>
|
|
<A HREF="#idx1101">operator<=()</A><BR>
|
|
</TD>
|
|
<TD VALIGN=top><A HREF="#idx1097">operator==()</A><BR>
|
|
</TD></TR>
|
|
</TABLE></UL>
|
|
|
|
<A NAME="sec2"><H3>Summary</H3></A>
|
|
<P>A template utility class for pairs of values that may be of different types</P>
|
|
<A NAME="sec3"><H3>Synopsis</H3></A>
|
|
|
|
<PRE>#include <utility>
|
|
|
|
namespace std {
|
|
template <class T1, class T2>
|
|
struct pair;
|
|
}
|
|
</PRE>
|
|
<A NAME="sec4"><H3>Description</H3></A>
|
|
<P>The <B><I>pair</I></B> class is a template for encapsulating pairs of values that may be of different types.</P>
|
|
<A NAME="sec5"><H3>Interface</H3></A>
|
|
|
|
<UL><PRE>namespace std {
|
|
|
|
template <class T1, class T2>
|
|
struct pair {
|
|
typedef T1 first_type;
|
|
typedef T2 second_type;
|
|
T1 first;
|
|
T2 second;
|
|
pair();
|
|
pair(const T1&, const T2&);
|
|
template <class V, class U>
|
|
pair (const pair <V, U>& p);
|
|
~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>
|
|
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>
|
|
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></UL>
|
|
<A NAME="sec6"><H3>Member Types</H3></A>
|
|
|
|
<A NAME="idx1091"></A><PRE><B>first_type</B></PRE>
|
|
<UL>
|
|
<P>Type of the first element in a pair.</P>
|
|
</UL>
|
|
|
|
|
|
<A NAME="idx1092"></A><PRE><B>second_type</B></PRE>
|
|
<UL>
|
|
<P>Type of the second element in a pair.</P>
|
|
</UL>
|
|
|
|
<A NAME="sec7"><H3>Constructors</H3></A>
|
|
|
|
<A NAME="idx1093"></A><PRE><B>pair</B>();</PRE>
|
|
<UL>
|
|
<P>Default constructor. Initializes <SAMP>first</SAMP> and <SAMP>second</SAMP> using their default constructors.</P>
|
|
</UL>
|
|
|
|
|
|
<A NAME="idx1094"></A><PRE><B>pair</B>(const T1& x, const T2& y);</PRE>
|
|
<UL>
|
|
<P>Creates a <B><I>pair</I></B> of types <SAMP>T1</SAMP> and <SAMP>T2</SAMP>, making the necessary conversions in<SAMP> x </SAMP>and <SAMP>y</SAMP>.</P>
|
|
</UL>
|
|
|
|
|
|
<A NAME="idx1095"></A><PRE>template <class V, class U>
|
|
<B>pair</B>(const pair <V, U>& p);</PRE>
|
|
<UL>
|
|
<P>Copies <SAMP>first</SAMP> and <SAMP>second</SAMP> from the corresponding elements of <SAMP>p</SAMP>.</P>
|
|
</UL>
|
|
|
|
<A NAME="sec8"><H3>Destructor</H3></A>
|
|
|
|
<A NAME="idx1096"></A><PRE><B>~pair</B> ();</PRE>
|
|
<A NAME="sec9"><H3>Nonmember Operators</H3></A>
|
|
|
|
<A NAME="idx1097"></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>
|
|
|
|
|
|
<A NAME="idx1098"></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>!(x==y)</SAMP>.</P>
|
|
</UL>
|
|
|
|
|
|
<A NAME="idx1099"></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 || (!(y.first < x.first) && x.second < y.second))</SAMP> is <SAMP>true</SAMP>. Otherwise it returns <SAMP>false</SAMP>.</P>
|
|
</UL>
|
|
|
|
|
|
<A NAME="idx1100"></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>y < x</SAMP>.</P>
|
|
</UL>
|
|
|
|
|
|
<A NAME="idx1101"></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>!(y > x)</SAMP>.</P>
|
|
</UL>
|
|
|
|
|
|
<A NAME="idx1102"></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>!(x < y)</SAMP>.</P>
|
|
</UL>
|
|
|
|
<A NAME="sec10"><H3>Nonmember Functions</H3></A>
|
|
|
|
<A NAME="idx1103"></A><PRE>template <class T1, class T2>
|
|
pair<T1,T2>
|
|
<B>make_pair</B>(x,y);</PRE>
|
|
<UL>
|
|
<P>Creates a <B><I>pair</I></B> by deducing and returning the types of <SAMP>x</SAMP> and <SAMP>y</SAMP>.</P>
|
|
</UL>
|
|
|
|
<A NAME="sec11"><H3>See Also</H3></A>
|
|
<P><A HREF="utility-h.html"><utility></A></P>
|
|
<A NAME="sec12"><H3>Standards Conformance</H3></A>
|
|
<P><I>ISO/IEC 14882:1998 -- International Standard for Information Systems --Programming Language C++, Section 20.2.2</I></P>
|
|
|
|
<BR>
|
|
<HR>
|
|
<A HREF="overflow-error.html"><IMG SRC="images/bprev.gif" WIDTH=20 HEIGHT=21 ALT="Previous file" BORDER=O></A><A HREF="noframes.html"><IMG SRC="images/btop.gif" WIDTH=56 HEIGHT=21 ALT="Top of Document" BORDER=O></A><A HREF="booktoc.html"><IMG SRC="images/btoc.gif" WIDTH=56 HEIGHT=21 ALT="Contents" BORDER=O></A><A HREF="tindex.html"><IMG SRC="images/bindex.gif" WIDTH=56 HEIGHT=21 ALT="Index page" BORDER=O></A><A HREF="partial-sort.html"><IMG SRC="images/bnext.gif" WIDTH=20 HEIGHT=21 ALT="Next file" BORDER=O></A>
|
|
|
|
<!-- Google Analytics tracking code -->
|
|
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
|
|
</script>
|
|
<script type="text/javascript">
|
|
_uacct = "UA-1775151-1";
|
|
urchinTracker();
|
|
</script>
|
|
<!-- end of Google Analytics tracking code -->
|
|
|
|
</BODY>
|
|
</HTML>
|