Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/libs/mpl/doc/refmanual/identity.html @ 45

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

updated boost from 1_33_1 to 1_34_1

File size: 6.8 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: identity</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="./miscellaneous.html" class="navigation-link">Prev</a>&nbsp;<a href="./always.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group">Back&nbsp;<a href="./always.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./miscellaneous.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="./miscellaneous.html" class="navigation-link">Miscellaneous</a> / <a href="./identity.html" class="navigation-link">identity</a></td>
16</tr></table><div class="header-separator"></div>
17<div class="section" id="identity">
18<h1><a class="toc-backref" href="./miscellaneous.html#id488" name="identity">identity</a></h1>
19<div class="section" id="identity-synopsis">
20<h3><a class="subsection-title" href="#synopsis" name="synopsis">Synopsis</a></h3>
21<pre class="literal-block">
22template&lt; 
23      typename X
24    &gt;
25struct <a href="./identity.html" class="identifier">identity</a>
26{
27    typedef X type;
28};
29</pre>
30</div>
31<div class="section" id="identity-description">
32<h3><a class="subsection-title" href="#description" name="description">Description</a></h3>
33<p>The <a class="reference" href="http://mathworld.wolfram.com/IdentityFunction.html" target="_top">identity</a> metafunction. Returns <tt class="literal"><span class="pre">X</span></tt> unchanged.</p>
34</div>
35<div class="section" id="identity-header">
36<h3><a class="subsection-title" href="#header" name="header">Header</a></h3>
37<pre class="literal-block">
38#include &lt;<a href="../../../../boost/mpl/identity.hpp" class="header">boost/mpl/identity.hpp</a>&gt;
39</pre>
40</div>
41<div class="section" id="identity-model-of">
42<h3><a class="subsection-title" href="#model-of" name="model-of">Model of</a></h3>
43<p><a class="reference" href="./metafunction.html">Metafunction</a></p>
44</div>
45<div class="section" id="identity-parameters">
46<h3><a class="subsection-title" href="#parameters" name="parameters">Parameters</a></h3>
47<table border="1" class="table">
48<colgroup>
49<col width="22%" />
50<col width="28%" />
51<col width="51%" />
52</colgroup>
53<thead valign="bottom">
54<tr><th>Parameter</th>
55<th>Requirement</th>
56<th>Description</th>
57</tr>
58</thead>
59<tbody valign="top">
60<tr><td><tt class="literal"><span class="pre">X</span></tt></td>
61<td>Any type</td>
62<td>An argument to be returned.</td>
63</tr>
64</tbody>
65</table>
66</div>
67<div class="section" id="identity-expression-semantics">
68<h3><a class="subsection-title" href="#expression-semantics" name="expression-semantics">Expression semantics</a></h3>
69<p>For an arbitrary type <tt class="literal"><span class="pre">x</span></tt>:</p>
70<pre class="literal-block">
71typedef <a href="./identity.html" class="identifier">identity</a>&lt;x&gt;::type r;
72</pre>
73<table class="field-list" frame="void" rules="none">
74<col class="field-name" />
75<col class="field-body" />
76<tbody valign="top">
77<tr class="field"><th class="field-name">Return type:</th><td class="field-body">A type.</td>
78</tr>
79<tr class="field"><th class="field-name">Semantics:</th><td class="field-body"><p class="first">Equivalent to</p>
80<pre class="last literal-block">
81typedef x r;
82</pre>
83</td>
84</tr>
85<tr class="field"><th class="field-name">Postcondition:</th><td class="field-body"><tt class="literal"><span class="pre">is_same&lt;r,x&gt;::value</span> <span class="pre">==</span> <span class="pre">true</span></tt>.</td>
86</tr>
87</tbody>
88</table>
89</div>
90<div class="section" id="identity-example">
91<h3><a class="subsection-title" href="#example" name="example">Example</a></h3>
92<pre class="literal-block">
93typedef <a href="./apply.html" class="identifier">apply</a>&lt; <a href="./identity.html" class="identifier">identity</a>&lt;_1&gt;, char &gt;::type t1;
94typedef <a href="./apply.html" class="identifier">apply</a>&lt; <a href="./identity.html" class="identifier">identity</a>&lt;_2&gt;, char,int &gt;::type t2;
95
96<a href="./assert.html" class="identifier">BOOST_MPL_ASSERT</a>(( is_same&lt; t1, char &gt; ));
97<a href="./assert.html" class="identifier">BOOST_MPL_ASSERT</a>(( is_same&lt; t2, int > ));
98</pre>
99</div>
100<div class="section" id="identity-see-also">
101<h3><a class="subsection-title" href="#see-also" name="see-also">See also</a></h3>
102<p><a class="reference" href="./metafunctions.html">Metafunctions</a>, <a class="reference" href="./placeholders.html">Placeholders</a>, <a class="reference" href="./trivial.html">Trivial Metafunctions</a>, <a class="refentry reference" href="./always.html"><tt class="refentry literal"><span class="pre">always</span></tt></a>, <a class="refentry reference" href="./apply.html"><tt class="refentry literal"><span class="pre">apply</span></tt></a></p>
103<!-- modtime: November 10, 2004 04:40:31 +0000 -->
104<!-- Metafunctions/Miscellaneous//always |20 -->
105</div>
106</div>
107
108<div class="footer-separator"></div>
109<table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./miscellaneous.html" class="navigation-link">Prev</a>&nbsp;<a href="./always.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group">Back&nbsp;<a href="./always.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./miscellaneous.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>
110</tr></table></body>
111</html>
Note: See TracBrowser for help on using the repository browser.