Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/libs/mpl/doc/refmanual/if.html @ 29

Last change on this file since 29 was 29, checked in by landauf, 17 years ago

updated boost from 1_33_1 to 1_34_1

File size: 6.9 KB
Line 
1<?xml version="1.0" encoding="utf-8" ?>
2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4<!-- Copyright Aleksey Gurtovoy 2006. Distributed under the Boost -->
5<!-- Software License, Version 1.0. (See accompanying -->
6<!-- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -->
7<head>
8<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
9<meta name="generator" content="Docutils 0.3.6: http://docutils.sourceforge.net/" />
10<title>The MPL Reference Manual: if_</title>
11<link rel="stylesheet" href="../style.css" type="text/css" />
12</head>
13<body class="docframe refmanual">
14<table class="header"><tr class="header"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./type-selection.html" class="navigation-link">Prev</a>&nbsp;<a href="./if-c.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group">Back&nbsp;<a href="./if-c.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./type-selection.html" class="navigation-link">Up</a>&nbsp;<a href="../refmanual.html" class="navigation-link">Home</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./refmanual_toc.html" class="navigation-link">Full TOC</a></span></td>
15<td class="header-group page-location"><a href="../refmanual.html" class="navigation-link">Front Page</a> / <a href="./metafunctions.html" class="navigation-link">Metafunctions</a> / <a href="./type-selection.html" class="navigation-link">Type Selection</a> / <a href="./if.html" class="navigation-link">if_</a></td>
16</tr></table><div class="header-separator"></div>
17<div class="section" id="if">
18<h1><a class="toc-backref" href="./type-selection.html#id446" name="if">if_</a></h1>
19<div class="section" id="if-synopsis">
20<h3><a class="subsection-title" href="#synopsis" name="synopsis">Synopsis</a></h3>
21<pre class="literal-block">
22template&lt; 
23      typename C
24    , typename T1
25    , typename T2
26    &gt;
27struct <a href="./if.html" class="identifier">if_</a>
28{
29    typedef <em>unspecified</em> type;
30};
31</pre>
32</div>
33<div class="section" id="if-description">
34<h3><a class="subsection-title" href="#description" name="description">Description</a></h3>
35<p>Returns one of its two arguments, <tt class="literal"><span class="pre">T1</span></tt> or <tt class="literal"><span class="pre">T2</span></tt>, depending on the value <tt class="literal"><span class="pre">C</span></tt>.</p>
36</div>
37<div class="section" id="if-header">
38<h3><a class="subsection-title" href="#header" name="header">Header</a></h3>
39<pre class="literal-block">
40#include &lt;<a href="../../../../boost/mpl/if.hpp" class="header">boost/mpl/if.hpp</a>&gt;
41</pre>
42</div>
43<div class="section" id="if-parameters">
44<h3><a class="subsection-title" href="#parameters" name="parameters">Parameters</a></h3>
45<table border="1" class="table">
46<colgroup>
47<col width="15%" />
48<col width="36%" />
49<col width="48%" />
50</colgroup>
51<thead valign="bottom">
52<tr><th>Parameter</th>
53<th>Requirement</th>
54<th>Description</th>
55</tr>
56</thead>
57<tbody valign="top">
58<tr><td><tt class="literal"><span class="pre">C</span></tt></td>
59<td><a class="reference" href="./integral-constant.html">Integral Constant</a></td>
60<td>A selection condition.</td>
61</tr>
62<tr><td><tt class="literal"><span class="pre">T1</span></tt>, <tt class="literal"><span class="pre">T2</span></tt></td>
63<td>Any type</td>
64<td>Types to select from.</td>
65</tr>
66</tbody>
67</table>
68</div>
69<div class="section" id="if-expression-semantics">
70<h3><a class="subsection-title" href="#expression-semantics" name="expression-semantics">Expression semantics</a></h3>
71<p>For any <a class="reference" href="./integral-constant.html">Integral Constant</a> <tt class="literal"><span class="pre">c</span></tt> and arbitrary types <tt class="literal"><span class="pre">t1</span></tt>, <tt class="literal"><span class="pre">t2</span></tt>:</p>
72<pre class="literal-block">
73typedef <a href="./if.html" class="identifier">if_</a>&lt;c,t1,t2&gt;::type t;
74</pre>
75<table class="field-list" frame="void" rules="none">
76<col class="field-name" />
77<col class="field-body" />
78<tbody valign="top">
79<tr class="field"><th class="field-name">Return type:</th><td class="field-body">Any type.</td>
80</tr>
81<tr class="field"><th class="field-name">Semantics:</th><td class="field-body">If <tt class="literal"><span class="pre">c::value</span> <span class="pre">==</span> <span class="pre">true</span></tt>, <tt class="literal"><span class="pre">t</span></tt> is identical to <tt class="literal"><span class="pre">t1</span></tt>; otherwise <tt class="literal"><span class="pre">t</span></tt> is
82identical to <tt class="literal"><span class="pre">t2</span></tt>.</td>
83</tr>
84</tbody>
85</table>
86</div>
87<div class="section" id="if-example">
88<h3><a class="subsection-title" href="#example" name="example">Example</a></h3>
89<pre class="literal-block">
90typedef <a href="./if.html" class="identifier">if_</a>&lt;true_,char,long&gt;::type t1;
91typedef <a href="./if.html" class="identifier">if_</a>&lt;false_,char,long&gt;::type t2;
92
93<a href="./assert.html" class="identifier">BOOST_MPL_ASSERT</a>(( is_same&lt;t1, char&gt; ));
94<a href="./assert.html" class="identifier">BOOST_MPL_ASSERT</a>(( is_same&lt;t2, long&gt; ));
95</pre>
96</div>
97<div class="section" id="if-see-also">
98<h3><a class="subsection-title" href="#see-also" name="see-also">See also</a></h3>
99<p><a class="reference" href="./metafunctions.html">Metafunctions</a>, <a class="reference" href="./integral-constant.html">Integral Constant</a>, <a class="refentry reference" href="./if-c.html"><tt class="refentry literal"><span class="pre">if_c</span></tt></a>, <a class="refentry reference" href="./eval-if.html"><tt class="refentry literal"><span class="pre">eval_if</span></tt></a></p>
100<!-- modtime: November 10, 2004 04:40:27 +0000 -->
101<!-- Metafunctions/Type Selection//if_c |20 -->
102</div>
103</div>
104
105<div class="footer-separator"></div>
106<table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./type-selection.html" class="navigation-link">Prev</a>&nbsp;<a href="./if-c.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group">Back&nbsp;<a href="./if-c.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./type-selection.html" class="navigation-link">Up</a>&nbsp;<a href="../refmanual.html" class="navigation-link">Home</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./refmanual_toc.html" class="navigation-link">Full TOC</a></span></td>
107</tr></table></body>
108</html>
Note: See TracBrowser for help on using the repository browser.