Added libs/mpl
[SVN r15384]
This commit is contained in:
1 parent
6ec072c403
commit
01d61922bc
238 files changed
+15885
No files matched your search
@@ -0,0 +1,60 @@
|
||||
<!doctype html public "-//ietf//dtd html//en">
|
||||
<html><head><title>boost::mpl::Metafunction</title>
|
||||
<link rel="stylesheet" href="./mpl_wiki.css">
|
||||
</head><body bgcolor="white">
|
||||
<h1><a href="./Table_of_Content.html"><img src="./mpl_logo.jpg" alt="[Home]" border=0 align="right"></a>Metafunction</h1><h3>Description</h3>
|
||||
<p>
|
||||
A Metafunction is a class template that represents a function invocable at compile-time. A metafunction is invoked by instantiating the class template with particular template parameters (metafunction arguments); the result of metafunction application is accessible through the instantiation's nested <code>type</code> typedef. A metafunction can have a variable number of parameters.
|
||||
<p>
|
||||
<h3>Example</h3>
|
||||
<p>
|
||||
<pre>
|
||||
<span class="cxx-comment">// binary metafunction</span>
|
||||
template< typename T1, typename T2 >
|
||||
struct is_same
|
||||
{
|
||||
typedef false_c type;
|
||||
};
|
||||
<p>
|
||||
template< typename T >
|
||||
struct is_same
|
||||
{
|
||||
typedef true_c type;
|
||||
};
|
||||
<p>
|
||||
<span class="cxx-comment">// metafunction invocation</span>
|
||||
typedef is_same<int,char>::type res;
|
||||
BOOST_STATIC_ASSERT(!res::value);
|
||||
</pre>
|
||||
<p>
|
||||
<p>
|
||||
<h3>Valid expressions</h3>
|
||||
<p>
|
||||
<table border="1">
|
||||
<tr><th> Expression </th><th> Expression type </th></tr>
|
||||
<tr><td><code>typename f::type</code></td><td>A type </td></tr>
|
||||
<tr><td><code>typename f<t1,..,tn>::type</code></td><td>A type </td></tr>
|
||||
</table>
|
||||
<p>
|
||||
<h3>Expression semantics</h3>
|
||||
<p>
|
||||
<table border="1">
|
||||
<tr><th> Expression </th><th> Complexity </th><th> Precondition </th><th> Semantics </th><th> Postcondition </th></tr>
|
||||
<tr><td><code>typename f::type</code></td><td>Metafunction dependent</td><td><code>f</code> is a nullary metafunction; <code>f::type</code> is a <em>type-name</em></td><td><code>f::type</code> is the result of the metafunction invocation</td><td></td></tr>
|
||||
<tr><td><code>typename f<t1,..,tn>::type</code></td><td>Metafunction dependent</td><td><code>f</code> is an <code>n</code>-ary metafunction; <code>t1,..,tn</code> are types; <code>f<t1,..,tn>::type</code> is a <em>type-name</em></td><td><code>f<t1,..,tn>::type</code> is the result of the metafunction invocation with the input arguments <code>t1,..,tn</code></td><td></td></tr>
|
||||
</table>
|
||||
<p>
|
||||
<h3>Models</h3>
|
||||
<p>
|
||||
<ul>
|
||||
<li><code><a href="./Reference/plus.html">plus</a></code>
|
||||
<li><code><a href="./Reference/logical_not.html">logical_not</a></code>
|
||||
<li><code><a href="./Reference/size.html">size</a></code>
|
||||
<li><code>max_element</code>
|
||||
</ul>
|
||||
<p>
|
||||
<h3>See also</h3>
|
||||
<p>
|
||||
<a href="./Metafunctions.html">Metafunctions</a>, [Metafunction Class]
|
||||
<p><hr>
|
||||
<a href="./Table_of_Content.html">Table of Content</a><br>Last edited July 16, 2002 11:27 pm</body></html>
|
||||
Reference in new issue
Block a user