2007-11-06 12:13:52 +00:00
< html >
< head >
< meta http-equiv = "Content-Type" content = "text/html; charset=ISO-8859-1" >
< title > pair</ title >
2007-11-07 03:46:23 +00:00
< link rel = "stylesheet" href = "../../../../../../doc/html/boostbook.css" type = "text/css" >
2007-11-06 12:13:52 +00:00
< meta name = "generator" content = "DocBook XSL Stylesheets V1.66.1" >
< link rel = "start" href = "../../index.html" title = "Chapter 1. Fusion 2.0" >
< link rel = "up" href = "../support.html" title = "Support" >
< link rel = "prev" href = "deduce_sequence.html" title = "deduce_sequence" >
< link rel = "next" href = "../iterator.html" title = "Iterator" >
</ head >
< body bgcolor = "white" text = "black" link = "#0000FF" vlink = "#840084" alink = "#0000FF" >
< table cellpadding = "2" width = "100%" >< tr >
< td valign = "top" >< img alt = "Boost C++ Libraries" width = "277" height = "86" src = "../../../../../../boost.png" ></ td >
2008-07-17 23:59:22 +00:00
< td align = "center" >< a href = "../../../../../../index.html" > Home</ a ></ td >
2007-11-06 12:13:52 +00:00
< td align = "center" >< a href = "../../../../../libraries.htm" > Libraries</ a ></ td >
2008-07-17 23:59:22 +00:00
< td align = "center" >< a href = "http://www.boost.org/users/people.html" > People</ a ></ td >
< td align = "center" >< a href = "http://www.boost.org/users/faq.html" > FAQ</ a ></ td >
2007-11-06 12:13:52 +00:00
< td align = "center" >< a href = "../../../../../../more/index.htm" > More</ a ></ td >
</ tr ></ table >
< hr >
< div class = "spirit-nav" >
< a accesskey = "p" href = "deduce_sequence.html" >< img src = "../../../../../../doc/html/images/prev.png" alt = "Prev" ></ a >< a accesskey = "u" href = "../support.html" >< img src = "../../../../../../doc/html/images/up.png" alt = "Up" ></ a >< a accesskey = "h" href = "../../index.html" >< img src = "../../../../../../doc/html/images/home.png" alt = "Home" ></ a >< a accesskey = "n" href = "../iterator.html" >< img src = "../../../../../../doc/html/images/next.png" alt = "Next" ></ a >
</ div >
< div class = "section" lang = "en" >
< div class = "titlepage" >< div >< div >< h3 class = "title" >
< a name = "fusion.support.pair" ></ a >< a href = "pair.html" title = "pair" > pair</ a ></ h3 ></ div ></ div ></ div >
< a name = "fusion.support.pair.description" ></ a >< h4 >
2008-07-21 07:25:52 +00:00
< a name = "id466201" ></ a >
2007-11-06 12:13:52 +00:00
< a href = "pair.html#fusion.support.pair.description" > Description</ a >
</ h4 >
< p >
Fusion < tt class = "computeroutput" >< span class = "identifier" > pair</ span ></ tt > type is a half
runtime pair. A half runtime pair is similar to a < a href = "../adapted/std__pair.html" title = "std::pair" >< tt class = "computeroutput" >< span class = "identifier" > std</ span >< span class = "special" > ::</ span >< span class = "identifier" > pair</ span ></ tt ></ a > ,
but, unlike < a href = "../adapted/std__pair.html" title = "std::pair" >< tt class = "computeroutput" >< span class = "identifier" > std</ span >< span class = "special" > ::</ span >< span class = "identifier" > pair</ span ></ tt ></ a > ,
the first type does not have data. It is used as elements in < span class = "underline" > _map</ span > _s,
for example.
</ p >
< a name = "fusion.support.pair.synopsis" ></ a >< h4 >
2008-07-21 07:25:52 +00:00
< a name = "id466305" ></ a >
2007-11-06 12:13:52 +00:00
< a href = "pair.html#fusion.support.pair.synopsis" > Synopsis</ a >
</ h4 >
< pre class = "programlisting" >
< span class = "keyword" > template</ span > < span class = "special" > < </ span >< span class = "keyword" > typename</ span > < span class = "identifier" > First</ span >< span class = "special" > ,</ span > < span class = "keyword" > typename</ span > < span class = "identifier" > Second</ span >< span class = "special" > > </ span >
< span class = "keyword" > struct</ span > < span class = "identifier" > pair</ span >< span class = "special" > ;</ span >
< span class = "keyword" > namespace</ span > < span class = "identifier" > result_of</ span >
< span class = "special" > {</ span >
2008-07-17 23:59:22 +00:00
< span class = "keyword" > template</ span > < span class = "special" > < </ span >< span class = "keyword" > typename</ span > < span class = "identifier" > Pair</ span >< span class = "special" > > </ span >
2007-11-06 12:13:52 +00:00
< span class = "keyword" > struct</ span > < span class = "identifier" > first</ span >< span class = "special" > ;</ span >
2008-07-17 23:59:22 +00:00
< span class = "keyword" > template</ span > < span class = "special" > < </ span >< span class = "keyword" > typename</ span > < span class = "identifier" > Pair</ span >< span class = "special" > > </ span >
2007-11-06 12:13:52 +00:00
< span class = "keyword" > struct</ span > < span class = "identifier" > second</ span >< span class = "special" > ;</ span >
< span class = "keyword" > template</ span > < span class = "special" > < </ span >< span class = "keyword" > typename</ span > < span class = "identifier" > First</ span >< span class = "special" > ,</ span > < span class = "keyword" > typename</ span > < span class = "identifier" > Second</ span >< span class = "special" > > </ span >
< span class = "keyword" > struct</ span > < span class = "identifier" > make_pair</ span >< span class = "special" > ;</ span >
< span class = "special" > }</ span >
< span class = "keyword" > template</ span > < span class = "special" > < </ span >< span class = "keyword" > typename</ span > < span class = "identifier" > First</ span >< span class = "special" > ,</ span > < span class = "keyword" > typename</ span > < span class = "identifier" > Second</ span >< span class = "special" > > </ span >
< span class = "keyword" > typename</ span > < span class = "identifier" > result_of</ span >< span class = "special" > ::</ span >< span class = "identifier" > make_pair</ span >< span class = "special" > < </ span >< span class = "identifier" > First</ span >< span class = "special" > ,</ span >< span class = "identifier" > Second</ span >< span class = "special" > > ::</ span >< span class = "identifier" > type</ span >
< span class = "identifier" > make_pair</ span >< span class = "special" > (</ span >< span class = "identifier" > Second</ span > < span class = "keyword" > const</ span > < span class = "special" > & );</ span >
</ pre >
< a name = "fusion.support.pair.template_parameters" ></ a >< h4 >
2008-07-21 07:25:52 +00:00
< a name = "id466713" ></ a >
2007-11-06 12:13:52 +00:00
< a href = "pair.html#fusion.support.pair.template_parameters" > Template parameters</ a >
</ h4 >
< div class = "informaltable" >< table class = "table" >
< colgroup >
< col >
< col >
</ colgroup >
< thead >< tr >
< th >
< p >
Parameter
</ p >
</ th >
< th >
< p >
Description
</ p >
</ th >
</ tr ></ thead >
< tbody >
< tr >
< td >
< p >
First
</ p >
</ td >
< td >
< p >
The first type. This is purely a type. No data is held.
</ p >
</ td >
</ tr >
< tr >
< td >
< p >
Second
</ p >
</ td >
< td >
< p >
The second type. This contains data.
</ p >
</ td >
</ tr >
</ tbody >
</ table ></ div >
< div class = "variablelist" >
< p class = "title" >< b > Notation</ b ></ p >
< dl >
< dt >< span class = "term" >< tt class = "computeroutput" >< span class = "identifier" > P</ span ></ tt ></ span ></ dt >
< dd >< p >
Fusion pair type
</ p ></ dd >
< dt >< span class = "term" >< tt class = "computeroutput" >< span class = "identifier" > p</ span ></ tt > ,
< tt class = "computeroutput" >< span class = "identifier" > p2</ span ></ tt ></ span ></ dt >
< dd >< p >
Fusion pairs
</ p ></ dd >
< dt >< span class = "term" >< tt class = "computeroutput" >< span class = "identifier" > F</ span ></ tt > ,
< tt class = "computeroutput" >< span class = "identifier" > S</ span ></ tt ></ span ></ dt >
< dd >< p >
Arbitrary types
</ p ></ dd >
< dt >< span class = "term" >< tt class = "computeroutput" >< span class = "identifier" > s</ span ></ tt ></ span ></ dt >
< dd >< p >
Value of type < tt class = "computeroutput" >< span class = "identifier" > S</ span ></ tt >
</ p ></ dd >
< dt >< span class = "term" >< tt class = "computeroutput" >< span class = "identifier" > o</ span ></ tt ></ span ></ dt >
< dd >< p >
Output stream
</ p ></ dd >
< dt >< span class = "term" >< tt class = "computeroutput" >< span class = "identifier" > i</ span ></ tt ></ span ></ dt >
< dd >< p >
Input stream
</ p ></ dd >
</ dl >
</ div >
< a name = "fusion.support.pair.expression_semantics" ></ a >< h4 >
2008-07-21 07:25:52 +00:00
< a name = "id466993" ></ a >
2007-11-06 12:13:52 +00:00
< a href = "pair.html#fusion.support.pair.expression_semantics" > Expression Semantics</ a >
</ h4 >
< div class = "informaltable" >< table class = "table" >
< colgroup >
< col >
< col >
</ colgroup >
< thead >< tr >
< th >
< p >
Expression
</ p >
</ th >
< th >
< p >
Semantics
</ p >
</ th >
</ tr ></ thead >
< tbody >
< tr >
< td >
< p >
< tt class = "computeroutput" >< span class = "identifier" > P</ span >< span class = "special" > ::</ span >< span class = "identifier" > first_type</ span ></ tt >
</ p >
</ td >
< td >
< p >
The type of the first template parameter, < tt class = "computeroutput" >< span class = "identifier" > F</ span ></ tt > ,
equivalent to < tt class = "computeroutput" >< span class = "identifier" > result_of</ span >< span class = "special" > ::</ span >< span class = "identifier" > first</ span >< span class = "special" > < </ span >< span class = "identifier" > P</ span >< span class = "special" > > ::</ span >< span class = "identifier" > type</ span ></ tt > .
</ p >
</ td >
</ tr >
< tr >
< td >
< p >
< tt class = "computeroutput" >< span class = "identifier" > P</ span >< span class = "special" > ::</ span >< span class = "identifier" > second_type</ span ></ tt >
</ p >
</ td >
< td >
< p >
The type of the second template parameter, < tt class = "computeroutput" >< span class = "identifier" > S</ span ></ tt > ,
equivalent to < tt class = "computeroutput" >< span class = "identifier" > result_of</ span >< span class = "special" > ::</ span >< span class = "identifier" > second</ span >< span class = "special" > < </ span >< span class = "identifier" > P</ span >< span class = "special" > > ::</ span >< span class = "identifier" > type</ span ></ tt > .
</ p >
</ td >
</ tr >
< tr >
< td >
< p >
< tt class = "computeroutput" >< span class = "identifier" > P</ span >< span class = "special" > ()</ span ></ tt >
</ p >
</ td >
< td >
< p >
Default construction.
</ p >
</ td >
</ tr >
< tr >
< td >
< p >
< tt class = "computeroutput" >< span class = "identifier" > P</ span >< span class = "special" > (</ span >< span class = "identifier" > s</ span >< span class = "special" > )</ span ></ tt >
</ p >
</ td >
< td >
< p >
Construct a pair given value for the second type, < tt class = "computeroutput" >< span class = "identifier" > s</ span ></ tt > .
</ p >
</ td >
</ tr >
< tr >
< td >
< p >
< tt class = "computeroutput" >< span class = "identifier" > P</ span >< span class = "special" > (</ span >< span class = "identifier" > p2</ span >< span class = "special" > )</ span ></ tt >
</ p >
</ td >
< td >
< p >
Copy constructs a pair from another pair, < tt class = "computeroutput" >< span class = "identifier" > p2</ span ></ tt > .
</ p >
</ td >
</ tr >
< tr >
< td >
< p >
2007-12-17 09:27:42 +00:00
< tt class = "computeroutput" >< span class = "identifier" > p</ span >< span class = "special" > .</ span >< span class = "identifier" > second</ span ></ tt >
2007-11-06 12:13:52 +00:00
</ p >
</ td >
< td >
< p >
2008-07-17 23:59:22 +00:00
Get the data from < tt class = "computeroutput" >< span class = "identifier" > p1</ span ></ tt > .
</ p >
</ td >
</ tr >
< tr >
< td >
< p >
< tt class = "computeroutput" >< span class = "identifier" > p</ span > < span class = "special" > =</ span >
< span class = "identifier" > p2</ span ></ tt >
</ p >
</ td >
< td >
< p >
Assigns a pair, < tt class = "computeroutput" >< span class = "identifier" > p1</ span ></ tt > ,
from another pair, < tt class = "computeroutput" >< span class = "identifier" > p2</ span ></ tt > .
</ p >
</ td >
</ tr >
< tr >
< td >
< p >
make_pair< F> (s)
</ p >
</ td >
< td >
< p >
Make a pair given the first type, < tt class = "computeroutput" >< span class = "identifier" > F</ span ></ tt > ,
and a value for the second type, < tt class = "computeroutput" >< span class = "identifier" > s</ span ></ tt > .
The second type assumes the type of < tt class = "computeroutput" >< span class = "identifier" > s</ span ></ tt >
</ p >
</ td >
</ tr >
< tr >
< td >
< p >
< tt class = "computeroutput" >< span class = "identifier" > o</ span > < span class = "special" > << </ span >
< span class = "identifier" > p</ span ></ tt >
</ p >
</ td >
< td >
< p >
Output < tt class = "computeroutput" >< span class = "identifier" > p</ span ></ tt > to output
stream, < tt class = "computeroutput" >< span class = "identifier" > o</ span ></ tt > .
</ p >
</ td >
</ tr >
< tr >
< td >
< p >
< tt class = "computeroutput" >< span class = "identifier" > i</ span > < span class = "special" > >> </ span >
< span class = "identifier" > p</ span ></ tt >
</ p >
</ td >
< td >
< p >
Input < tt class = "computeroutput" >< span class = "identifier" > p</ span ></ tt > from input
stream, < tt class = "computeroutput" >< span class = "identifier" > i</ span ></ tt > .
</ p >
</ td >
</ tr >
< tr >
< td >
< p >
< tt class = "computeroutput" >< span class = "identifier" > p</ span > < span class = "special" > ==</ span >
< span class = "identifier" > p2</ span ></ tt >
</ p >
</ td >
< td >
< p >
Tests two pairs for equality.
</ p >
</ td >
</ tr >
< tr >
< td >
< p >
< tt class = "computeroutput" >< span class = "identifier" > p</ span > < span class = "special" > !=</ span >
< span class = "identifier" > p2</ span ></ tt >
2007-11-06 12:13:52 +00:00
</ p >
</ td >
< td >
< p >
Tests two pairs for inequality.
</ p >
</ td >
</ tr >
</ tbody >
</ table ></ div >
< a name = "fusion.support.pair.header" ></ a >< h4 >
2008-07-21 07:25:52 +00:00
< a name = "id467770" ></ a >
2007-11-06 12:13:52 +00:00
< a href = "pair.html#fusion.support.pair.header" > Header</ a >
</ h4 >
< pre class = "programlisting" >
< span class = "preprocessor" > #include</ span > < span class = "special" > < </ span >< span class = "identifier" > boost</ span >< span class = "special" > /</ span >< span class = "identifier" > fusion</ span >< span class = "special" > /</ span >< span class = "identifier" > support</ span >< span class = "special" > /</ span >< span class = "identifier" > pair</ span >< span class = "special" > .</ span >< span class = "identifier" > hpp</ span >< span class = "special" > > </ span >
< span class = "preprocessor" > #include</ span > < span class = "special" > < </ span >< span class = "identifier" > boost</ span >< span class = "special" > /</ span >< span class = "identifier" > fusion</ span >< span class = "special" > /</ span >< span class = "identifier" > include</ span >< span class = "special" > /</ span >< span class = "identifier" > pair</ span >< span class = "special" > .</ span >< span class = "identifier" > hpp</ span >< span class = "special" > > </ span >
</ pre >
< a name = "fusion.support.pair.example" ></ a >< h4 >
2008-07-21 07:25:52 +00:00
< a name = "id467926" ></ a >
2007-11-06 12:13:52 +00:00
< a href = "pair.html#fusion.support.pair.example" > Example</ a >
</ h4 >
< pre class = "programlisting" >
< span class = "identifier" > pair</ span >< span class = "special" > < </ span >< span class = "keyword" > int</ span >< span class = "special" > ,</ span > < span class = "keyword" > char</ span >< span class = "special" > > </ span > < span class = "identifier" > p</ span >< span class = "special" > (</ span >< span class = "char" > 'X'</ span >< span class = "special" > );</ span >
< span class = "identifier" > std</ span >< span class = "special" > ::</ span >< span class = "identifier" > cout</ span > < span class = "special" > << </ span > < span class = "identifier" > p</ span > < span class = "special" > << </ span > < span class = "identifier" > std</ span >< span class = "special" > ::</ span >< span class = "identifier" > endl</ span >< span class = "special" > ;</ span >
< span class = "identifier" > std</ span >< span class = "special" > ::</ span >< span class = "identifier" > cout</ span > < span class = "special" > << </ span > < span class = "identifier" > make_pair</ span >< span class = "special" > < </ span >< span class = "keyword" > int</ span >< span class = "special" > > (</ span >< span class = "char" > 'X'</ span >< span class = "special" > )</ span > < span class = "special" > << </ span > < span class = "identifier" > std</ span >< span class = "special" > ::</ span >< span class = "identifier" > endl</ span >< span class = "special" > ;</ span >
< span class = "identifier" > assert</ span >< span class = "special" > ((</ span >< span class = "identifier" > p</ span > < span class = "special" > ==</ span > < span class = "identifier" > make_pair</ span >< span class = "special" > < </ span >< span class = "keyword" > int</ span >< span class = "special" > > (</ span >< span class = "char" > 'X'</ span >< span class = "special" > )));</ span >
</ pre >
</ div >
< table xmlns:rev = "http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width = "100%" >< tr >
< td align = "left" ></ td >
2007-11-14 10:17:09 +00:00
< td align = "right" >< div class = "copyright-footer" > Copyright © 2001-2007 Joel de Guzman, Dan Marsden, Tobias
2007-11-07 02:12:28 +00:00
Schwinger< p >
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at < a href = "http://www.boost.org/LICENSE_1_0.txt" target = "_top" > http://www.boost.org/LICENSE_1_0.txt</ a > )
2007-11-14 10:17:09 +00:00
</ p >
</ div ></ td >
2007-11-06 12:13:52 +00:00
</ tr ></ table >
< hr >
< div class = "spirit-nav" >
< a accesskey = "p" href = "deduce_sequence.html" >< img src = "../../../../../../doc/html/images/prev.png" alt = "Prev" ></ a >< a accesskey = "u" href = "../support.html" >< img src = "../../../../../../doc/html/images/up.png" alt = "Up" ></ a >< a accesskey = "h" href = "../../index.html" >< img src = "../../../../../../doc/html/images/home.png" alt = "Home" ></ a >< a accesskey = "n" href = "../iterator.html" >< img src = "../../../../../../doc/html/images/next.png" alt = "Next" ></ a >
</ div >
</ body >
</ html >