new MPL docs

[SVN r26212]
This commit is contained in:
Aleksey Gurtovoy committed 2004-11-15 12:24:13 +00:00
1 parent d5e241cd2a
commit 54a5f8f55f
306 files changed
+27492 -7633

No files matched your search

-67
View File
@@ -1,67 +0,0 @@
div.articletitle
{
text-align: center;
text-transform: uppercase;
}
div.authorgroup
{
text-align: center;
}
h3.title span.emphasis em
{
font-style: normal;
text-decoration: underline;
}
body
{
background-color: white;
color: black;
}
sup
{
font-size: x-small;
font-weight: lighter;
}
a:link,
a:visited
{
color: #505050;
}
sup a:link
,sup a:visited
,a.interlink:link
,a.interlink:visited
{
color: #505050;
text-decoration: none;
}
div.biblioentry p
{
border-style: none none none solid;
border-width: 1px;
border-color: silver;
margin-top: -1em;
padding-left: 0.5em;
padding-top: 0.25em;
}
div.footnote p
{
margin-bottom: -0.5em;
}
pre.programlisting
{
border-style: none none none solid;
border-width: 1px;
border-color: silver;
padding-left: 1em;
}
+69 -23
View File
@@ -1,29 +1,75 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>THE BOOST MPL LIBRARY</title>
<link rel="stylesheet" href="article.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.50.0">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.3.6: http://docutils.sourceforge.net/" />
<title>THE BOOST MPL LIBRARY</title>
<meta name="copyright" content="Copyright © Aleksey Gurtovoy and David Abrahams, 2002-2004." />
<link rel="stylesheet" href="style.css" type="text/css" />
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<div class="article">
<div class="titlepage">
<div>
<img src="../../../boost.png" align="middle" width="277" height="86">
<div class="articletitle">
<h1 class="title"><a name="idafawr"></a>THE BOOST MPL LIBRARY</h1>
<body class="docframe">
<a class="reference" href="http://www.boost.org" target="_top">
<img align="left" alt="www.boost.org" src="../../../boost.png"/>
</a>
<h1 class="title">THE BOOST MPL LIBRARY</h1>
<table class="docinfo" frame="void" rules="none">
<col class="docinfo-name" />
<col class="docinfo-content" />
<tbody valign="top">
<tr><th class="docinfo-name">Copyright:</th>
<td>Copyright © Aleksey Gurtovoy and David Abrahams, 2002-2004.</td></tr>
<tr class="field"><th class="docinfo-name">License:</th><td class="field-body">Distributed under the Boost Software License, Version 1.0. (See
accompanying file <tt class="literal"><span class="pre">LICENSE_1_0.txt</span></tt> or copy at
<a class="reference" href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)</td>
</tr>
</tbody>
</table>
<div class="document" id="the-boost-mpl-library">
<p>The Boost.MPL library is a general-purpose, high-level C++
template metaprogramming framework of compile-time algorithms, sequences and
metafunctions. It provides a conceptual foundation and an extensive
set of powerful and coherent tools that make doing explict metaprogramming
in C++ as easy and enjoyable as possible within the current language.</p>
<p>There are several places to start when getting familiar with the library,
depending on what your know about metaprogramming in general and
C++ template metaprogramming in particular. Starting with
Boost version 1.32, the MPL comes with both an <a class="reference" href="./tutorial/tutorial-metafunctions.html">in-depth tutorial</a> on its
fundamental concepts and an annotated <a class="reference" href="./tutorial/reference-manual.html">reference manual</a> covering all concepts
and components in the library. While the tutorial
only uncovers a bit of what there is to C++ metaprogramming and the MPL,
it's a perfect place to start if you are only somewhat familiar with the
subject. At the very least, after you're done with it, you will be able to put
the rest of the stuff that appears here into context. The reference manual
is <em>the</em> resource for you if you plan — or are already doing — some actual
development with the library, but a casual reading is still allowed and likely
to bring many insights on the framework's organization and underlying
ideas. Finally, the top-level sections in this document that you
see highlighted below might also offer something of interest.</p>
<p>So, welcome, and happy metaprogramming!</p>
<dl>
<dt><strong>Important</strong>:</dt>
<dd>There have been some major interface changes in the library since the last
public release, many of which are <em>not</em> backward compatible. If you are
a seasoned MPL user, be prepared to have to modify your code after
upgrading. Please refer to the <a class="reference" href="./tutorial/changes-in-boost-1-32-0.html">1.32 release changelog</a>
for the detailed information about the changes.</dd>
</dl>
<!-- .. section-numbering:: -->
<ul class="toc simple" id="outline">
<li><a class="reference" href="./tutorial/tutorial-metafunctions.html" id="id40" name="id40">Tutorial: Metafunctions and Higher-Order Metaprogramming</a></li>
<li><a class="reference" href="./tutorial/reference-manual.html" id="id61" name="id61">Reference Manual</a></li>
<li><a class="reference" href="./tutorial/changelog-history.html" id="id62" name="id62">Changelog &amp; History</a></li>
<li><a class="reference" href="./tutorial/technical-details.html" id="id70" name="id70">Technical Details</a></li>
<li><a class="reference" href="./tutorial/resources.html" id="id77" name="id77">Resources</a></li>
<li><a class="reference" href="./tutorial/acknowledgements.html" id="id78" name="id78">Acknowledgements</a></li>
<li><a class="reference" href="./tutorial/tutorial_toc.html">Full TOC</a></li>
</ul>
</div>
<hr class="footer" />
<div class="footer">
Generated on: 2004-11-15 12:20 UTC.
Generated by <a class="reference" href="http://docutils.sourceforge.net/" target="_top">Docutils</a> from <a class="reference" href="http://docutils.sourceforge.net/rst.html" target="_top">reStructuredText</a> source.
</div>
</div>
<p>The Boost MPL library documentation is currently undergoing a major overhaul
for the 1.32 release. Please come back in a few days.</p>
</div>
</body>
</html>
-15
View File
@@ -1,15 +0,0 @@
@echo off
if "%3" == "" goto usage
sx -x lower -x empty %2 >%3.xml
msxsl.exe %3.xml ..\..\..\..\..\docbook-xsl-1.50.0\html\my\%1 -o %3
del %3.xml
tidy.exe -config tidy_config -m %3
python tidy_attr.py %3
exit
:usage
echo Usage examples:
echo msxsl_build.bat docbook_msxsl.xsl src\body.sgml index.html
echo msxsl_build.bat docbook_msxsl.xsl paper\src\body.sgml paper\mpl_paper.html
-87
View File
@@ -1,87 +0,0 @@
div.articletitle
{
text-align: center;
text-transform: uppercase;
}
div.authorgroup
{
text-align: center;
}
h3.title span.emphasis em
{
font-style: normal;
text-decoration: underline;
}
body
{
background-color: white;
color: black;
}
sup
{
font-size: x-small;
font-weight: lighter;
}
a:link
,a:visited
{
color: #505050;
}
sup a:link
,sup a:visited
,a.interlink:link
,a.interlink:visited
{
color: #505050;
text-decoration: none;
}
div.biblioentry p
{
border-style: none none none solid;
border-width: 1px;
border-color: silver;
margin-top: -1em;
padding-left: 0.5em;
padding-top: 0.25em;
}
div.footnote p
{
margin-bottom: -0.5em;
}
div.table table
{
border: solid;
border-width: 1px;
border-color: silver;
}
div.table table tr th
{
background-color: #f0f0f0;
padding-left: 1em;
padding-right: 1em;
}
div.table table tr td
{
padding-left: 1em;
padding-right: 1em;
}
pre.programlisting
{
border-style: none none none solid;
border-width: 1px;
border-color: silver;
padding-left: 1em;
}
-59
View File
@@ -1,59 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type">
<title>6. Acknowledgements</title>
<link rel="stylesheet" href="article.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.50.0">
<meta name="keywords" content="template metaprogramming, generic programming, programming languages, C++, STL, type systems, polymorphism, compile-time">
<link rel="home" href="index.html" title="the boost c++ metaprogramming library">
<link rel="up" href="index.html" title="the boost c++ metaprogramming library">
<link rel="previous" href="example.html" title="5. example: a compile-time fsm generator">
<link rel="next" href="refs.html" title="references">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<div class="navheader">
<table width="100%" summary="Navigation header">
<tr>
<th colspan="3" align="center">6. Acknowledgements</th>
</tr>
<tr>
<td width="20%" align="left"><a accesskey="p" href="example.html">Prev</a>&nbsp;</td>
<th width="60%" align="center">&nbsp;</th>
<td width="20%" align="right">&nbsp;<a accesskey="n" href="refs.html">Next</a></td>
</tr>
</table>
<hr>
</div>
<div class="section">
<div class="titlepage">
<div>
<h2 class="title" style="clear: both"><a name="acknowl"></a>6. Acknowledgements</h2>
</div>
</div>
<p>Peter Dimov contributed the <tt>bind</tt> functionality without which compile-time lambda expressions wouldn't have been possible. The MPL implementation would have been much more difficult without Vesa Karvonen's wonderful Boost Preprocessor Metaprogramming Library. Authors are also greatly indebted to David B. Held who kindly volunteered to thoroughly edit this document. Of course, any remaining errors are exclusively ours.</p>
</div>
<div class="navfooter">
<hr>
<table width="100%" summary="Navigation footer">
<tr>
<td width="40%" align="left"><a accesskey="p" href="example.html">Prev</a>&nbsp;</td>
<td width="20%" align="center"><a accesskey="u" href="index.html">Up</a></td>
<td width="40%" align="right">&nbsp;<a accesskey="n" href="refs.html">Next</a></td>
</tr>
<tr>
<td width="40%" align="left" valign="top">5. Example: a compile-time FSM generator&nbsp;</td>
<td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td>
<td width="40%" align="right" valign="top">&nbsp;References</td>
</tr>
</table>
</div>
</body>
</html>
-82
View File
@@ -1,82 +0,0 @@
div.articletitle
{
text-align: center;
text-transform: uppercase;
}
div.authorgroup
{
text-align: center;
}
h3.title span.emphasis em
{
font-style: normal;
text-decoration: underline;
}
body
{
background-color: white;
color: black;
}
sup
{
font-size: x-small;
font-weight: lighter;
}
a:link
,a:visited
{
color: #505050;
}
sup a:link
,sup a:visited
,a.interlink:link
,a.interlink:visited
{
color: #505050;
text-decoration: none;
}
div.biblioentry p
{
border-style: none none none solid;
border-width: 1px;
border-color: silver;
margin-top: -1em;
padding-left: 0.5em;
padding-top: 0.25em;
}
div.table table
{
border: solid;
border-width: 1px;
border-color: silver;
}
div.table table tr th
{
background-color: #f0f0f0;
padding-left: 1em;
padding-right: 1em;
}
div.table table tr td
{
padding-left: 1em;
padding-right: 1em;
}
pre.programlisting
{
border-style: none none none solid;
border-width: 1px;
border-color: silver;
padding-left: 1em;
}
-124
View File
@@ -1,124 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type">
<title>4. Code generation facilities</title>
<link rel="stylesheet" href="article.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.50.0">
<meta name="keywords" content="template metaprogramming, generic programming, programming languages, C++, STL, type systems, polymorphism, compile-time">
<link rel="home" href="index.html" title="the boost c++ metaprogramming library">
<link rel="up" href="index.html" title="the boost c++ metaprogramming library">
<link rel="previous" href="lambda.html" title="3. lambda facility">
<link rel="next" href="example.html" title="5. example: a compile-time fsm generator">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<div class="navheader">
<table width="100%" summary="Navigation header">
<tr>
<th colspan="3" align="center">4. Code generation facilities</th>
</tr>
<tr>
<td width="20%" align="left"><a accesskey="p" href="lambda.html">Prev</a>&nbsp;</td>
<th width="60%" align="center">&nbsp;</th>
<td width="20%" align="right">&nbsp;<a accesskey="n" href="example.html">Next</a></td>
</tr>
</table>
<hr>
</div>
<div class="section">
<div class="titlepage">
<div>
<h2 class="title" style="clear: both"><a name="codegeneration"></a>4. Code generation facilities</h2>
</div>
</div>
<p>There are cases, especially in the domain of numeric computation, when one wants to perform some part of the calculations at compile-time, and then pass the results to a run-time part of the program for further processing. For example, suppose one has implemented a complex compile-time algorithm that works with fixed-point arithmetic:</p>
<pre class="programlisting">
// fixed-point algorithm input
typedef mpl::vector&lt;
mpl::fixed_c&lt;-1,2345678&gt;
, mpl::fixed_c&lt;9,0001&gt;
// ..
, mpl::fixed_c&lt;3,14159&gt;
&gt; input_data;
/*
complex compile-time algorithm
*/
typedef /*...*/ result_data;
</pre>
<p>Suppose the <tt>result_data</tt> here is a sequence of <tt>mpl::fixed_c</tt> types that keeps the results of the algorithm, and now one wishes to feed that result to the run-time part of the algorithm. With MPL she can do this:</p>
<pre class="programlisting">
double my_algorithm()
{
// passing the results to the run-time part of the program
std::vector&lt;double&gt; results;
results.reserve(mpl::size&lt;result_data&gt;::value);
mpl::for_each&lt;numbers,_&gt;(
boost::bind(&amp;std::vector&lt;double&gt;::push_back, &amp;results, _1)
);
// ...
}
</pre>
<p>The <tt>for_each&lt;numbers,_&gt;(...)</tt> call is what actually transfers the compile-time <tt>result_data</tt> into run-time <tt>results</tt>. <tt>for_each</tt> is a function template declared as:</p>
<pre class="programlisting">
template&lt;
typename Seq
, typename TransformOp
, typename F
&gt;
void for_each(F f)
{
// ...
}
</pre>
<p>To call the function, one is required to explicitly provide two actual template parameters, a compile-time sequence <tt>Seq</tt> and a unary transformation metafunction <tt>TransformOp</tt>, plus a run-time function argument <tt>f</tt> (in our example, <tt>numbers</tt>, <tt>_</tt>, and <tt>boost::bind(...)</tt> correspondingly). <tt>f</tt> is a function object which <tt>operator()</tt> is called for every element in the <tt>Seq</tt> tranfromed by <tt>TransformOp</tt>.</p>
<p>Applying this to our example, the</p>
<pre class="programlisting">
mpl::for_each&lt;numbers,_&gt;(
boost::bind(&amp;std::vector&lt;double&gt;::push_back, &amp;results, _1)
);
</pre>
<p>call is roughly equivalent to this:</p>
<pre class="programlisting">
f(mpl::apply&lt; _,mpl::at_c&lt;result_data,0&gt;::type &gt;::type());
f(mpl::apply&lt; _,mpl::at_c&lt;result_data,1&gt;::type &gt;::type());
// ...
f(mpl::apply&lt; _,mpl::at_c&lt;result_data,n&gt;::type &gt;::type());
</pre>
<p>where <tt>n == mpl::size&lt;result_data&gt;::type::value</tt>.</p>
</div>
<div class="navfooter">
<hr>
<table width="100%" summary="Navigation footer">
<tr>
<td width="40%" align="left"><a accesskey="p" href="lambda.html">Prev</a>&nbsp;</td>
<td width="20%" align="center"><a accesskey="u" href="index.html">Up</a></td>
<td width="40%" align="right">&nbsp;<a accesskey="n" href="example.html">Next</a></td>
</tr>
<tr>
<td width="40%" align="left" valign="top">3. Lambda facility&nbsp;</td>
<td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td>
<td width="40%" align="right" valign="top">&nbsp;5. Example: a compile-time FSM generator</td>
</tr>
</table>
</div>
</body>
</html>
-325
View File
@@ -1,325 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type">
<title>5. Example: a compile-time FSM generator</title>
<link rel="stylesheet" href="article.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.50.0">
<meta name="keywords" content="template metaprogramming, generic programming, programming languages, C++, STL, type systems, polymorphism, compile-time">
<link rel="home" href="index.html" title="the boost c++ metaprogramming library">
<link rel="up" href="index.html" title="the boost c++ metaprogramming library">
<link rel="previous" href="codegeneration.html" title="4. code generation facilities">
<link rel="next" href="acknowl.html" title="6. acknowledgements">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<div class="navheader">
<table width="100%" summary="Navigation header">
<tr>
<th colspan="3" align="center">5. Example: a compile-time FSM generator</th>
</tr>
<tr>
<td width="20%" align="left"><a accesskey="p" href="codegeneration.html">Prev</a>&nbsp;</td>
<th width="60%" align="center">&nbsp;</th>
<td width="20%" align="right">&nbsp;<a accesskey="n" href="acknowl.html">Next</a></td>
</tr>
</table>
<hr>
</div>
<div class="section">
<div class="titlepage">
<div>
<h2 class="title" style="clear: both"><a name="example"></a>5. Example: a compile-time FSM generator</h2>
</div>
</div>
<p>Finite state machines (FSMs) are an important tool for describing and implementing program behavior <span class="citation">[<a class="interlink" href="refs.html#ref.hu79" title="[hu79]">HU79</a>]</span>, <span class="citation">[<a class="interlink" href="refs.html#ref.mar98" title="[mar98]">Mar98</a>]</span>. They also are a good example of a domain in which metaprogramming can be applied to reduce the amount of repetitive and boilerplate operations one must perform in order to implement these simple mathematical models in code. Below we present a simple state machine generator that has been implemented using Boost Metaprogramming Library facilities. The generator takes a compile-time automata description, and converts it into C++ code that implements the FSM at run-time.</p>
<p>The FSM description is basically a combination of states and events plus a state transition table (STT), which ties them all together. The generator walks through the table and generates the state machine's <tt>process_event</tt> method that is the essence of an FSM.</p>
<p>Suppose we want to implement a simple music player using a finite state machine model. The state transition table for the FSM is shown in <a class="interlink" href="example.html#example.fsm.stt" title="table 1. player's state transition table with actions">Table 1</a>. The STT format reflects the way one usually describes the behavior of an FSM in plain English. For example, the first line of the table can be read as follows: &lsquo;If the model is in the <tt>stopped</tt> state and the <tt>play_event</tt> is received, then the <tt>do_play</tt> transition function is called, and the model transitions to the <tt>playing</tt> state&rsquo;.</p>
<div class="table"><a name="example.fsm.stt"></a>
<table summary="Player's state transition table with actions" border="0">
<colgroup>
<col>
<col>
<col>
<col></colgroup>
<thead>
<tr>
<th align="left">State</th>
<th align="left">Event</th>
<th align="left">Next state</th>
<th align="left">Transition function</th>
</tr>
</thead>
<tbody>
<tr>
<td align="left"><tt>stopped</tt></td>
<td align="left"><tt>play_event</tt></td>
<td align="left"><tt>playing</tt></td>
<td align="left"><tt>do_play</tt></td>
</tr>
<tr>
<td align="left"><tt>playing</tt></td>
<td align="left"><tt>stop_event</tt></td>
<td align="left"><tt>stopped</tt></td>
<td align="left"><tt>do_stop</tt></td>
</tr>
<tr>
<td align="left"><tt>playing</tt></td>
<td align="left"><tt>pause_event</tt></td>
<td align="left"><tt>paused</tt></td>
<td align="left"><tt>do_pause</tt></td>
</tr>
<tr>
<td align="left"><tt>paused</tt></td>
<td align="left"><tt>play_event</tt></td>
<td align="left"><tt>playing</tt></td>
<td align="left"><tt>do_resume</tt></td>
</tr>
<tr>
<td align="left"><tt>paused</tt></td>
<td align="left"><tt>stop_event</tt></td>
<td align="left"><tt>stopped</tt></td>
<td align="left"><tt>do_stop</tt></td>
</tr>
</tbody>
</table>
<p class="title"><b>Table 1. Player's state transition table with actions</b></p>
</div>
<p>The transition table provides us with a complete formal definition of the target FSM, and there are several ways to transform that definition into code. For instance, if we define states as members of an enumeration type, and events as classes derived from some base <tt>event</tt> class <sup><a name="note.fsm" href="#ftn.note.fsm">10</a></sup> , like so:</p>
<pre class="programlisting">
class player
{
public:
// event declarations
struct event;
struct play_event;
struct stop_event;
struct pause_event;
// "input" function
void process_event(event const&amp;); // throws
private:
// states
enum state_t { stopped, playing, paused };
// transition functions
void do_play(play_event const&amp;);
void do_stop(stop_event const&amp;);
void do_pause(pause_event const&amp;);
void do_resume(play_event const&amp;);
private:
state_t m_state;
};
</pre>
<p>then the most straightforward way to derive the FSM implementation from the above table would be something like this:</p>
<pre class="programlisting">
void player::process_event(event const&amp; e)
{
if (m_state == stopped)
{
if (typeid(e) == typeid(play_event))
{
do_play(static_cast&lt;play_event const&amp;&gt;(e));
m_state = playing;
return;
}
}
else if (m_state == playing)
{
if (typeid(e) == typeid(stop_event))
{
do_stop(static_cast&lt;stop_event const&amp;&gt;(e));
m_state = stopped;
return;
}
if (typeid(e) == typeid(pause_event))
{
do_pause(static_cast&lt;pause_event const&amp;&gt;(e));
m_state = paused;
return;
}
}
else if (m_state == paused)
{
if (typeid(e) == typeid(stop_event))
{
do_stop(static_cast&lt;stop_event const&amp;&gt;(e));
m_state = stopped;
return;
}
if (typeid(e) == typeid(play_event))
{
do_play(static_cast&lt;play_event const&amp;&gt;(e));
m_state = playing;
return;
}
}
else
{
throw logic_error(
boost::format("unknown state: %d")
% static_cast&lt;int&gt;(m_state)
);
}
throw std::logic_error(
"unexpected event: " + typeid(e).name()
);
}
</pre>
<p>Although there is nothing particularly wrong with implementing an FSM's structure using nested <tt>if</tt> (or <tt>switch-case</tt>) statements, the obvious weakness of this approach is that most of the above code is boilerplate. What one tends to do with boilerplate code is to copy and paste it, then change names etc. to adjust it to its new location; and that's where the errors are most likely to creep in. Since all the lines of event processing look alike (structurally), it's very easy to overlook or forget something that needs to be changed, and many such errors won't appear until the runtime.</p>
<p>The transition table of our FSM is just five lines long; ideally, we would like the skeleton implementation of the automata's controlling logic to be equally short (or, at least, to look equally short, i.e. to be encapsulated in some form so we never worry about it).</p>
<div class="section">
<div class="titlepage">
<div>
<h3 class="title"><a name="example.impl"></a>5.1. Implementation</h3>
</div>
</div>
<p>To represent the STT in a C++ program, we define a <tt>transition</tt> class template that represents a single line of the table. Then the table itself can be represented as a sequence of such lines:</p>
<pre class="programlisting">
typedef mpl::list&lt;
transition&lt;stopped, play_event, playing, &amp;player::do_play&gt;
, transition&lt;playing, stop_event, stopped, &amp;player::do_stop&gt;
, transition&lt;playing, pause_event, paused, &amp;player::do_pause&gt;
, transition&lt;paused, play_event, playing, &amp;player::do_resume&gt;
, transition&lt;paused, stop_event, stopped, &amp;player::do_stop&gt;
&gt;::type transition_table;
</pre>
<p>Now, the complete FSM will look like this:</p>
<pre class="programlisting">
class player
: state_machine&lt;player&gt;
{
private:
typedef player self_t;
// state invariants
void stopped_state_invariant();
void playing_state_invariant();
void paused_state_invariant();
// states (invariants are passed as non-type template arguments,
// and are called then the FSM enters the corresponding state)
typedef state&lt;0, &amp;self_t::stopped_state_invariant&gt; stopped;
typedef state&lt;1, &amp;self_t::playing_state_invariant&gt; playing;
typedef state&lt;2, &amp;self_t::paused_state_invariant&gt; paused;
private:
// event declarations; events are represented as types,
// and can carry a specific data for each event;
// but it's not needed for generator, so we define them later
struct play_event;
struct stop_event;
struct pause_event;
// transition functions
void do_play(play_event const&amp;);
void do_stop(stop_event const&amp;);
void do_pause(pause_event const&amp;);
void do_resume(play_event const&amp;);
// STT
friend class state_machine&lt;player&gt;;
typedef mpl::list&lt;
transition&lt;stopped, play_event, playing, &amp;player::do_play&gt;
, transition&lt;playing, stop_event, stopped, &amp;player::do_stop&gt;
, transition&lt;playing, pause_event, paused, &amp;player::do_pause&gt;
, transition&lt;paused, play_event, playing, &amp;player::do_resume&gt;
, transition&lt;paused, stop_event, stopped, &amp;player::do_stop&gt;
&gt;::type transition_table;
};
</pre>
<p>That's all - the above will generate a complete FSM implementation according to our specification. The only thing we need before using it is the definition of the event types (that were just forward declared before):</p>
<pre class="programlisting">
// event definitions
struct player::play_event
: player::event
{
};
// ...
</pre>
<p>The usage is simple as well:</p>
<pre class="programlisting">
int main()
{
// usage example
player p;
p.process_event(player::play_event());
p.process_event(player::pause_event());
p.process_event(player::play_event());
p.process_event(player::stop_event());
return 0;
}
</pre>
</div>
<div class="section">
<div class="titlepage">
<div>
<h3 class="title"><a name="example.relatedwork"></a>5.2. Related work</h3>
</div>
</div>
<p>A notable prior work in the field of automation of general-purpose state machine implementation in C++ is the Robert Martin's <span class="emphasis"><em>State Machine Compiler</em></span> <span class="citation">[<a class="interlink" href="refs.html#ref.smc" title="[smc]">SMC</a>]</span>. The SMC takes an ASCII description of the machine's state transition table and produces C++ code that implements the FSM using a variation of State design pattern <span class="citation">[<a class="interlink" href="refs.html#ref.hun91" title="[hun91]">Hun91</a>]</span>, <span class="citation">[<a class="interlink" href="refs.html#ref.ghj95" title="[ghj+95]">GHJ+95</a>]</span>. Lafreniere <span class="citation">[<a class="interlink" href="refs.html#ref.laf00" title="[laf00]">Laf00</a>]</span> presents another approach, where no external tools are used, and the FSMs are table driven.</p>
</div>
<div class="footnotes"><br>
<hr width="100" align="left">
<div class="footnote">
<p><sup><a name="ftn.note.fsm" href="#note.fsm">10</a></sup>The events need to be passed to action functions, as they may contain some event-specific information for an action.</p>
</div>
</div>
</div>
<div class="navfooter">
<hr>
<table width="100%" summary="Navigation footer">
<tr>
<td width="40%" align="left"><a accesskey="p" href="codegeneration.html">Prev</a>&nbsp;</td>
<td width="20%" align="center"><a accesskey="u" href="index.html">Up</a></td>
<td width="40%" align="right">&nbsp;<a accesskey="n" href="acknowl.html">Next</a></td>
</tr>
<tr>
<td width="40%" align="left" valign="top">4. Code generation facilities&nbsp;</td>
<td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td>
<td width="40%" align="right" valign="top">&nbsp;6. Acknowledgements</td>
</tr>
</table>
</div>
</body>
</html>
-181
View File
@@ -1,181 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type">
<title>The Boost C++ Metaprogramming Library</title>
<link rel="stylesheet" href="article.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.50.0">
<meta name="keywords" content="template metaprogramming, generic programming, programming languages, C++, STL, type systems, polymorphism, compile-time">
<link rel="home" href="index.html" title="the boost c++ metaprogramming library">
<link rel="next" href="intro.html" title="1. introduction">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<div class="navheader">
<table width="100%" summary="Navigation header">
<tr>
<th colspan="3" align="center">The Boost C++ Metaprogramming Library</th>
</tr>
<tr>
<td width="20%" align="left">&nbsp;</td>
<th width="60%" align="center">&nbsp;</th>
<td width="20%" align="right">&nbsp;<a accesskey="n" href="intro.html">Next</a></td>
</tr>
</table>
<hr>
</div>
<div class="article">
<div class="titlepage">
<div>
<div class="articletitle">
<h1 class="title"><a name="id1124916"></a>The Boost C++ Metaprogramming Library</h1>
</div>
</div>
<div>
<div class="authorgroup">
<h4>Aleksey Gurtovoy<sup>i</sup> and David Abrahams<sup>ii</sup></h4>
<div class="affiliation"><sup>i</sup><span class="orgname">MetaCommunications,</span> <a href="mailto:agurtovoy@meta-comm.com">agurtovoy@meta-comm.com</a></div>
<div class="affiliation"><sup>ii</sup><span class="orgname">Boost Consulting,</span> <a href="mailto:david.abrahams@rcn.com">david.abrahams@rcn.com</a></div>
</div>
</div>
<div>
<div class="abstract">
<p class="title"><b>Abstract</b></p>
<p>This paper describes the <tt>Boost</tt> C++ template metaprogramming library (MPL), an extensible compile-time framework of algorithms, sequences and metafunction classes. The library brings together important abstractions from the generic and functional programming worlds to build a powerful and easy-to-use toolset which makes template metaprogramming practical enough for the real-world environments. The MPL is heavily influenced by its run-time equivalent - the Standard Template Library (STL), a part of the C++ standard library <span class="citation">[<a class="interlink" href="refs.html#ref.stl94" title="[stl94]">STL94</a>]</span>, <span class="citation">[<a class="interlink" href="refs.html#ref.iso98" title="[iso98]">ISO98</a>]</span>. Like the STL, it defines an open conceptual and implementation framework which can serve as a foundation for future contributions in the domain. The library's fundamental concepts and idioms enable the user to focus on solutions without navigating the universe of possible ad-hoc approaches to a given metaprogramming problem, even if no actual MPL code is used. The library also provides a compile-time lambda expression facility enabling arbitrary currying and composition of class templates, a feature whose runtime counterpart is often cited as missing from the STL. This paper explains the motivation, usage, design, and implementation of the MPL with examples of its real-life applications, and offers some lessons learned about C++ template metaprogramming.</p>
</div>
</div>
<div>
<div class="keywords">
<p><b>Keywords:</b> template metaprogramming, generic programming, programming languages, C++, STL, type systems, polymorphism, compile-time</p>
</div>
</div>
</div>
<div class="toc">
<p><b>Table of Contents</b></p>
<dl>
<dt>1. <a href="intro.html">Introduction</a></dt>
<dd>
<dl>
<dt>1.1. <a href="intro.html#intro.native">Native language metaprogramming</a></dt>
<dt>1.2. <a href="intro.html#intro.cxx">Metaprogramming in C++</a></dt>
<dd>
<dl>
<dt>1.2.1. <a href="intro.html#intro.cxx.numeric">Numeric computations</a></dt>
<dt>1.2.2. <a href="intro.html#intro.cxx.type">Type computations</a></dt>
<dt>1.2.3. <a href="intro.html#intro.cxx.seq">Type sequences</a></dt>
</dl>
</dd>
<dt>1.3. <a href="intro.html#intro.whymetaprog">Why metaprogramming?</a></dt>
<dt>1.4. <a href="intro.html#intro.whylibrary">Why a metaprogramming library?</a></dt>
</dl>
</dd>
<dt>2. <a href="usage.html">Basic usage</a></dt>
<dd>
<dl>
<dt>2.1. <a href="usage.html#typeselection">Conditional type selection</a></dt>
<dd>
<dl>
<dt>2.1.1. <a href="usage.html#delayedeval">Delayed evaluation</a></dt>
</dl>
</dd>
<dt>2.2. <a href="usage.html#metafunctions">Metafunctions</a></dt>
<dd>
<dl>
<dt>2.2.1. <a href="usage.html#metafunctions.simple">The simple form</a></dt>
<dt>2.2.2. <a href="usage.html#metafunctions.higherorder">Higher-order metafunctions</a></dt>
<dt>2.2.3. <a href="usage.html#metafunctions.classes">Metafunction classes</a></dt>
<dt>2.2.4. <a href="usage.html#metafunctions.onesize">One size fits all?</a></dt>
<dt>2.2.5. <a href="usage.html#metafunctions.lambda">From metafunction to metafunction class</a></dt>
</dl>
</dd>
<dt>2.3. <a href="usage.html#sequences">Sequences, algorithms, and iterators</a></dt>
<dd>
<dl>
<dt>2.3.1. <a href="usage.html#sequences.intro">Introduction</a></dt>
<dt>2.3.2. <a href="usage.html#sequences.algo">Algorithms and sequences</a></dt>
<dt>2.3.3. <a href="usage.html#sequences.concepts">Sequence concepts</a></dt>
<dt>2.3.4. <a href="usage.html#sequences.revisited">Ad hoc example revisited</a></dt>
<dt>2.3.5. <a href="usage.html#sequences.iterfold">iter_fold as the main iteration algorithm</a></dt>
<dt>2.3.6. <a href="usage.html#sequences.numbers">Sequences of numbers</a></dt>
<dt>2.3.7. <a href="usage.html#sequences.variety">A variety of sequences</a></dt>
<dt>2.3.8. <a href="usage.html#sequences.unrolling">Loop/recursion unrolling</a></dt>
</dl>
</dd>
</dl>
</dd>
<dt>3. <a href="lambda.html">Lambda facility</a></dt>
<dt>4. <a href="codegeneration.html">Code generation facilities</a></dt>
<dt>5. <a href="example.html">Example: a compile-time FSM generator</a></dt>
<dd>
<dl>
<dt>5.1. <a href="example.html#example.impl">Implementation</a></dt>
<dt>5.2. <a href="example.html#example.relatedwork">Related work</a></dt>
</dl>
</dd>
<dt>6. <a href="acknowl.html">Acknowledgements</a></dt>
<dt><a href="refs.html">References</a></dt>
</dl>
</div>
</div>
<div class="navfooter">
<hr>
<table width="100%" summary="Navigation footer">
<tr>
<td width="40%" align="left">&nbsp;</td>
<td width="20%" align="center">&nbsp;</td>
<td width="40%" align="right">&nbsp;<a accesskey="n" href="intro.html">Next</a></td>
</tr>
<tr>
<td width="40%" align="left" valign="top">&nbsp;</td>
<td width="20%" align="center">&nbsp;</td>
<td width="40%" align="right" valign="top">&nbsp;1. Introduction</td>
</tr>
</table>
</div>
</body>
</html>
-359
View File
@@ -1,359 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type">
<title>1. Introduction</title>
<link rel="stylesheet" href="article.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.50.0">
<meta name="keywords" content="template metaprogramming, generic programming, programming languages, C++, STL, type systems, polymorphism, compile-time">
<link rel="home" href="index.html" title="the boost c++ metaprogramming library">
<link rel="up" href="index.html" title="the boost c++ metaprogramming library">
<link rel="previous" href="index.html" title="the boost c++ metaprogramming library">
<link rel="next" href="usage.html" title="2. basic usage">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<div class="navheader">
<table width="100%" summary="Navigation header">
<tr>
<th colspan="3" align="center">1. Introduction</th>
</tr>
<tr>
<td width="20%" align="left"><a accesskey="p" href="index.html">Prev</a>&nbsp;</td>
<th width="60%" align="center">&nbsp;</th>
<td width="20%" align="right">&nbsp;<a accesskey="n" href="usage.html">Next</a></td>
</tr>
</table>
<hr>
</div>
<div class="section">
<div class="titlepage">
<div>
<h2 class="title" style="clear: both"><a name="intro"></a>1. Introduction</h2>
</div>
</div>
<p>Metaprogramming is usually defined as the creation of programs which generate other programs. Parser generators such as YACC <span class="citation">[<a class="interlink" href="refs.html#ref.joh79" title="[joh79]">Joh79</a>]</span> are examples of one kind of program-generating program. The input language to YACC is a context-free grammar in Extended Backus-Naur Form <span class="citation">[<a class="interlink" href="refs.html#ref.ebnf" title="[ebnf]">EBNF</a>]</span>, and its output is a program which parses that grammar. Note that in this case the metaprogram (YACC) is written in a language (C) which does not directly support the description of generated programs. These specifications, which we'll call <span class="emphasis"><em>metadata</em></span>, are not written in C, but in a <span class="emphasis"><em>meta-language</em></span>. Because the the rest of the user's program typically requires a general-purpose programming system and must interact with the generated parser, the metadata is translated into C, which is then compiled and linked together with the rest of the system. The metadata thus undergoes two translation steps, and the user is always very conscious of the boundary between her metadata and the rest of her program.</p>
<div class="section">
<div class="titlepage">
<div>
<h3 class="title"><a name="intro.native"></a>1.1. Native language metaprogramming</h3>
</div>
</div>
<p>A more interesting form of metaprogramming is available in languages such as Scheme <span class="citation">[<a class="interlink" href="refs.html#ref.ss75" title="[ss75]">SS75</a>]</span>, where the generated program specification is given in the same language as the metaprogram itself. The metaprogrammer defines her meta-language as a subset of the expressible forms of the underlying language, and program generation can take place in the same translation step used to process the rest of the user's program. This allows users to switch transparently between ordinary programming, generated program specification, and metaprogramming, often without being aware of the transition.</p>
</div>
<div class="section">
<div class="titlepage">
<div>
<h3 class="title"><a name="intro.cxx"></a>1.2. Metaprogramming in C++</h3>
</div>
</div>
<p>In C++, it was discovered almost by accident <span class="citation">[<a class="interlink" href="refs.html#ref.unr" title="[unr]">Unr</a>]</span>, <span class="citation">[<a class="interlink" href="refs.html#ref.vel95a" title="[vel95a]">Vel95a</a>]</span> that the template mechanism provides a rich facility for computation at compile-time. In this section, we'll explore the basic mechanisms and some common idioms used for metaprogramming in C++.</p>
<div class="section">
<div class="titlepage">
<div>
<h4 class="title"><a name="intro.cxx.numeric"></a>1.2.1. Numeric computations</h4>
</div>
</div>
<p>The availability of <span class="emphasis"><em>non-type template parameters</em></span> makes it possible to perform integer computations at compile-time. For example, the following template computes the factorial of its argument:</p>
<pre class="programlisting">
template&lt; unsigned n &gt;
struct factorial
{
static const unsigned value = n * factorial&lt;n-1&gt;::value;
};
template&lt;&gt;
struct factorial&lt;0&gt;
{
static const unsigned value = 1;
};
</pre>
<p>The program fragment above is called a <span class="emphasis"><em>metafunction</em></span>, and it is easy to see its relationship to a function designed to be evaluated at runtime: the &lsquo;metafunction argument&rsquo; is passed as a template parameter, and its &lsquo;return value&rsquo; is defined as a nested static constant. Because of the hard line between the expression of compile-time and runtime computation in C++, metaprograms look different from their runtime counterparts. Thus, although as in Scheme the C++ metaprogrammer writes her code in the same language as the ordinary program, only a subset of the full C++ language is available to her: those expressions which can be evaluated at compile-time. Compare the above with a straightforward runtime definition of the factorial function:</p>
<pre class="programlisting">
unsigned factorial(unsigned N)
{
return N == 0 ? 1 : N * factorial(N - 1);
}
</pre>
<p>While it is easy to see the analogy between the two recursive definitions, recursion is in general more important to C++ metaprograms than it is to runtime C++. In contrast to languages such as Lisp where recursion is idiomatic, C++ programmers will typically avoid recursion when possible. This is done not only for efficiency reasons, but also because of &lsquo;cultural momentum&rsquo;: recursive programs are simply harder (for C++ programmers) to think about. Like pure Lisp, though, the C++ template mechanism is a <span class="emphasis"><em>functional</em></span> programming language: as such it rules out the use of data mutation required to maintain loop variables.</p>
<p>A key difference between the runtime and compile-time factorial functions is the expression of the termination condition: our meta-factorial uses template specialization as a kind of <span class="emphasis"><em>pattern-matching</em></span> mechanism to describe the behavior when <tt>N</tt> is zero. The syntactic analogue in the runtime world would require two separate definitions of the same function. In this case the impact of the second definition is minimal, but in large metaprograms the cost of maintaining and understanding the terminating definitions can become significant.</p>
<p>Note also that a C++ metafunction's return value must be <span class="emphasis"><em>named</em></span>. The name chosen here, <tt>value</tt>, is the same one used for all numeric returns in the MPL. As we'll see, establishing a consistent naming convention for metafunction returns is crucial to the power of the library.</p>
</div>
<div class="section">
<div class="titlepage">
<div>
<h4 class="title"><a name="intro.cxx.type"></a>1.2.2. Type computations</h4>
</div>
</div>
<p>How could we apply our <tt>factorial</tt> metafunction? We might, for example, produce an array type of an appropriate size to hold all permutations of instances of another type:</p>
<pre class="programlisting">
// permutation_holder&lt;T&gt;::type is an array type which can contain
// all permutations of a given T.
// unspecialized template for scalars
template&lt; typename T &gt;
struct permutation_holder
{
typedef T type[1][1];
};
// specialization for array types
template&lt; typename T, unsigned N &gt;
struct permutation_holder&lt;T[N]&gt;
{
typedef T type[factorial&lt;N&gt;::value][N];
};
</pre>
<p>Here we have introduced the notion of a <span class="emphasis"><em>type computation</em></span>. Like <tt>factorial</tt> above, <tt>permutation_holder</tt> template is a metafunction. However, where <tt>factorial</tt> manipulates unsigned integer values, <tt>permutation_holder</tt> accepts and &lsquo;returns&rsquo; a type (as the nested typedef <tt>type</tt>). Because the C++ type system provides a much richer set of expressions than anything we can use as a nontype template argument (e.g. the integers), C++ metaprograms tend to be composed mostly of type computations.</p>
</div>
<div class="section">
<div class="titlepage">
<div>
<h4 class="title"><a name="intro.cxx.seq"></a>1.2.3. Type sequences</h4>
</div>
</div>
<p>The ability to programmatically manipulate collections of types is a central tool of most interesting C++ metaprograms. Because this capability is so well-supported by the MPL, we'll provide just a brief introduction to the basics here. Later on, we'll revisit the example below to show how it can be implemented using MPL.</p>
<p>First, we'd need a way to represent the collection. One idea might be to store the types in a structure:</p>
<pre class="programlisting">
struct types
{
int t1;
long t2;
std::vector&lt;double&gt; t3;
};
</pre>
<p>Unfortunately, this arrangement is not susceptible to the compile-time type introspection power that C++ gives us: there's no way to find out what the names of the members are, and even if we assume that they're named according to some convention as above, there's no way to know how many members there are. The key to solving this problem is to increase the uniformity of the representation. If we have a consistent way to get the first type of any sequence and the rest of the sequence, we can easily access all members:</p>
<pre class="programlisting">
template&lt; typename First, typename Rest &gt;
struct cons
{
typedef First first;
typedef Rest rest;
};
struct nil {};
typedef
cons&lt;int
, cons&lt;long
, cons&lt;std::vector&lt;double&gt;
, nil
&gt; &gt; &gt; my_types;
</pre>
<p>The structure described by <tt>types</tt> above is the compile-time analogue of a singly-linked list; it has been first introduced by Czarnecki and Eisenecker in <span class="citation">[<a class="interlink" href="refs.html#ref.ce98" title="[ce98]">CE98</a>]</span>. Now that we've adjusted the structure so that the C++ template machinery can &lsquo;peel it apart&rsquo;, let's examine a simple metafunction which does so. Suppose a user wished to find the largest of an arbitrary collection of types. We can apply the recursive metafunction formula which should by now be familiar:</p>
<div class="example"><a name="example.largest"></a>
<p class="title"><b>Example 1. 'largest' metafunction</b></p>
<pre class="programlisting">
// choose the larger of two types
template&lt;
typename T1
, typename T2
, bool choose1 = (sizeof(T1) &gt; sizeof(T2)) // hands off!
&gt;
struct choose_larger
{
typedef T1 type;
};
// specialization for the case where sizeof(T2) &gt;= sizeof(T1)
template&lt; typename T1, typename T2 &gt;
struct choose_larger&lt; T1,T2,false &gt;
{
typedef T2 type;
};
// get the largest of a cons-list
template&lt; typename T &gt; struct largest;
// specialization to peel apart the cons list
template&lt; typename First, typename Rest &gt;
struct largest&lt; cons&lt;First,Rest&gt; &gt;
: choose_larger&lt; First, typename largest&lt;Rest&gt;::type &gt;
{
// type inherited from base
};
// specialization for loop termination
template&lt; typename First &gt;
struct largest&lt; cons&lt;First,nil&gt; &gt;
{
typedef First type;
};
int main()
{
// print the name of the largest of my_types
std::cout
&lt;&lt; typeid(largest&lt;my_types&gt;::type).name()
&lt;&lt; std::endl
;
}
</pre>
</div>
<p>There are several things worth noticing about this code:</p>
<div class="itemizedlist">
<ul type="box">
<li style="list-style-type: square">
<p>It uses a few ad-hoc, esoteric techniques, or &lsquo;hacks&rsquo;. The default template argument <tt>choose1</tt> (labeled &lsquo;hands off!&rsquo;) is one example. Without it, we would have needed yet another template to provide the implementation of <tt>choose_larger</tt>, or we would have had to provide the computation explicitly as a parameter to the template - perhaps not bad for this example, but it would make <tt>choose_larger</tt> much less useful and more error-prone. The other hack is the derivation of a specialization of <tt>largest</tt> from <tt>choose_larger</tt>. This is a code-saving device which allows the programmer to avoid writing &lsquo;<tt>typedef typename</tt> ...<tt>::type type</tt>&rsquo; in the template body.</p>
</li>
<li style="list-style-type: square">
<p>Even this simple metaprogram uses three separate partial specializations. The <tt>largest</tt> metafunction uses <span class="emphasis"><em>two</em></span> specializations. One might expect that this indicates there are two termination conditions, but there are not: one specialization is needed simply to deal with access to the sequence elements. These specializations make the code difficult to read by spreading the definition of a single metafunction over several C++ template definitions. Also, because they are <span class="emphasis"><em>partial</em></span> specializations, they make the code unusable for a large community of C++ programmers whose compilers don't support that feature.</p>
</li>
</ul>
</div>
<p>While these techniques are, of course, a valuable part of the arsenal of any good C++ metaprogrammer, their use tends to make programs written in what is already an unusual style harder-to-read and harder-to-write. By encapsulating commonly-used structures and dealing with loop terminations internally, the MPL reduces the need for both tricky hacks and for template specializations.</p>
</div>
</div>
<div class="section">
<div class="titlepage">
<div>
<h3 class="title"><a name="intro.whymetaprog"></a>1.3. Why metaprogramming?</h3>
</div>
</div>
<p>It's worth asking why anyone would want to do this. After all, even a simple toy example like the factorial metafunction is somewhat esoteric. To show how the type computation can be put to work, let's examine a simple example. The following code produces an array containing all possible permutations of another array:</p>
<pre class="programlisting">
// can't return an array in C++, so we need this wrapper
template&lt; typename T &gt;
struct wrapper
{
T x;
};
// return an array of the N! permutations of 'in'
template&lt; typename T &gt;
wrapper&lt; typename permutation_holder&lt;T&gt;::type &gt;
all_permutations(T const&amp; in)
{
wrapper&lt;typename permutation_holder&lt;T&gt;::type&gt; result;
// copy the unpermutated array to the first result element
unsigned const N = sizeof(T) / sizeof(**result.x);
std::copy(&amp;*in, &amp;*in + N, result.x[0]);
// enumerate the permutations
unsigned const result_size = sizeof(result.x) / sizeof(T);
for (T* dst = result.x + 1; dst != result.x + result_size; ++dst)
{
T* src = dst - 1;
std::copy(*src, *src + N, *dst);
std::next_permutation(*dst, *dst + N);
}
return result;
}
</pre>
<p>The runtime definition of <tt>factorial</tt> would be useless in <tt>all_permutations</tt> above, since in C++ the sizes of array members must be computed at compile-time. However, there are alternative approaches; how could we avoid metaprogramming, and what would the consequences be?</p>
<div class="orderedlist">
<ol type="1">
<li>
<p>We could write programs to interpret the metadata directly. In our factorial example, the array size could have been a runtime quantity; then we'd have been able to use the straightforward factorial function. However, that would imply the use of dynamic allocation, which is often expensive.</p>
<p>To carry this further, YACC might be rewritten to accept a pointer-to-function returning tokens from the stream to be parsed, and a string containing the grammar description. This approach, however, would impose unacceptable runtime costs for most applications: either the parser would have to treat the grammar nondeterministically, exploring the grammar for each parse, or it would have to begin by replicating at runtime the substantial table-generation and optimization work of the existing YACC for each input grammar.</p>
</li>
<li>
<p>We could replace the compile-time computation with our own analysis. After all, the size of arrays passed to <tt>all_permutations</tt> are always known at compile-time, and thus can be known to its user. We could ask the user to supply the result type explicitly:</p>
<pre class="programlisting">
template&lt; typename Result, typename T &gt;
Result all_permutations(T const&amp; input);
</pre>
<p>The costs to this approach are obvious: we give up expressivity (by requiring the user to explicitly specify implementation details), and correctness (by allowing the user to specify them incorrectly). Anyone who has had to write parser tables by hand will tell you that the impracticality of this approach is the very reason of YACC's existence.</p>
<p>In a language such as C++, where the metadata can be expressed in the same language as the rest of the user's program, expressivity is further enhanced: the user can invoke metaprograms directly, without learning a foreign syntax or interrupting the flow of her code.</p>
</li>
</ol>
</div>
<p>So, the motivation for metaprogramming comes down to the combination of three factors: efficiency, expressivity, and correctness. While in classical programming there is always a tension between expressivity and correctness on one hand and efficiency on the other, in the metaprogramming world we wield new power: we can move the computation required for expressivity from runtime to compile-time.</p>
</div>
<div class="section">
<div class="titlepage">
<div>
<h3 class="title"><a name="intro.whylibrary"></a>1.4. Why a metaprogramming <span class="emphasis"><em>library</em></span>?</h3>
</div>
</div>
<p>One might just as well ask why we need any generic library:</p>
<div class="itemizedlist">
<ul type="box">
<li style="list-style-type: square">
<p>Quality. Code that is appropriate for a general-purpose library is usually incidental to the purpose of its users. To a library developer, it is the central mission. On average, the containers and algorithms provided by any given C++ standard library implementation are more-flexible and better-implemented than the project-specific implementations which abound, because library development was treated as an end in itself rather than a task incidental to the development of some other application. With a centralized implementation for any given function, optimizations and improvements are more likely to have been applied.</p>
</li>
<li style="list-style-type: square">
<p>Re-use. More important even than the re-use of code which all libraries provide, a well-designed generic library establishes a <span class="emphasis"><em>framework of concepts and idioms</em></span> which establishes a reusable mental model for approaching problems. Just as the C++ Standard Template Library gave us iterator concepts and a function object protocol, the Boost Metaprogramming Library provides type-iterators and metafunction class protocol. A well-considered framework of idioms saves the metaprogrammer from considering irrelevant implementation details and allows her to concentrate on the problem at hand.</p>
</li>
<li style="list-style-type: square">
<p>Portability. A good library can smooth over the ugly realities of platform differences. While in theory a metaprogramming library is fully generic and shouldn't be concerned with these issues, in practice support for templates remains inconsistent even four years after standardization. This should perhaps not be surprising: C++ templates are the language's furthest-reaching and most complicated feature, which largely accounts for the power of metaprogramming in C++.</p>
</li>
<li style="list-style-type: square">
<p>Fun. Repeating the same idioms over and over is <span class="emphasis"><em>tedious</em></span>. It makes programmers tired and reduces productivity. Furthermore, when programmers get bored they get sloppy, and buggy code is even more costly than slowly-written code. Often the most useful libraries are simply patterns that have been &ldquo;plucked&rdquo; by an astute programmer from a sea of repetition. The MPL helps to reduce boredom by eliminating the need for the most commonly-repeated boilerplate coding patterns.</p>
</li>
</ul>
</div>
<p>As one can see, the MPL's development is motivated primarily by the same practical, real-world considerations that justify the development of any other library. Perhaps this is an indication that template metaprogramming is finally ready to leave the realm of the esoteric and enter the lingua franca of every day programmers.</p>
</div>
</div>
<div class="navfooter">
<hr>
<table width="100%" summary="Navigation footer">
<tr>
<td width="40%" align="left"><a accesskey="p" href="index.html">Prev</a>&nbsp;</td>
<td width="20%" align="center"><a accesskey="u" href="index.html">Up</a></td>
<td width="40%" align="right">&nbsp;<a accesskey="n" href="usage.html">Next</a></td>
</tr>
<tr>
<td width="40%" align="left" valign="top">The Boost C++ Metaprogramming Library&nbsp;</td>
<td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td>
<td width="40%" align="right" valign="top">&nbsp;2. Basic usage</td>
</tr>
</table>
</div>
</body>
</html>
-165
View File
@@ -1,165 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type">
<title>3. Lambda facility</title>
<link rel="stylesheet" href="article.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.50.0">
<meta name="keywords" content="template metaprogramming, generic programming, programming languages, C++, STL, type systems, polymorphism, compile-time">
<link rel="home" href="index.html" title="the boost c++ metaprogramming library">
<link rel="up" href="index.html" title="the boost c++ metaprogramming library">
<link rel="previous" href="usage.html" title="2. basic usage">
<link rel="next" href="codegeneration.html" title="4. code generation facilities">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<div class="navheader">
<table width="100%" summary="Navigation header">
<tr>
<th colspan="3" align="center">3. Lambda facility</th>
</tr>
<tr>
<td width="20%" align="left"><a accesskey="p" href="usage.html">Prev</a>&nbsp;</td>
<th width="60%" align="center">&nbsp;</th>
<td width="20%" align="right">&nbsp;<a accesskey="n" href="codegeneration.html">Next</a></td>
</tr>
</table>
<hr>
</div>
<div class="section">
<div class="titlepage">
<div>
<h2 class="title" style="clear: both"><a name="lambda"></a>3. Lambda facility</h2>
</div>
</div>
<p>The MPL's lambda facility allows the <i>inline composition</i> of class templates into &lsquo;lambda expressions&rsquo;, which are classes and can therefore be passed around as ordinary metafunction classes, or transformed into metafunction classes before application using the expression:</p>
<pre class="programlisting">
typedef mpl::lambda&lt;expr&gt;::type func;
</pre>
<p>For example, <tt>boost::remove_const</tt> traits template from Boost <tt>type_traits</tt> library <span class="citation">[<a class="interlink" href="refs.html#ref.ttl" title="[ttl]">TTL</a>]</span> is a class template (obviously), or a <a class="interlink" href="usage.html#metafunctions" title="2.2. metafunctions">metafunction</a> in MPL terminology. The simplest example of an &lsquo;inline composition&rsquo; of it would be something like:</p>
<pre class="programlisting">
typedef boost::remove_const&lt;_1&gt; expr;
</pre>
<p>This forms a so called &lsquo;lambda expression&rsquo;, which is neither a metafunction class, nor a metafunction, yet can be passed around everywhere because it's an ordinary C++ class, because all MPL facilities are polymorphic with respect to their arguments. Now, that lambda expression can be <span class="emphasis"><em>transformed</em></span> into a metafunction class using the MPL's <tt>lambda</tt> facility:</p>
<pre class="programlisting">
typedef boost::remove_const&lt;_1&gt; expr;
typedef mpl::lambda&lt;expr&gt;::type func;
</pre>
<p>The <tt>func</tt> is a unary metafunction class and can be used as such. In particular, it can be pass around or invoked (applied):</p>
<pre class="programlisting">
typedef mpl::apply&lt;func,int const&gt;::type res;
BOOST_MPL_ASSERT_IS_SAME(res, int);
</pre>
<p>or even</p>
<pre class="programlisting">
typedef func::apply&lt;int const&gt;::type res;
BOOST_MPL_ASSERT_IS_SAME(res, int);
</pre>
<p>Inline composition is very appealing syntactically when one deals with metafunctions, because it makes the expression obvious:</p>
<pre class="programlisting">
typedef mpl::logical_or&lt;
mpl::less&lt; mpl::size_of&lt;_1&gt;, mpl::int_c&lt;16&gt; &gt;
, boost::is_same&lt;_1,_2&gt;
&gt; expr;
typedef mpl::lambda&lt;expr&gt;::type func;
</pre>
<p>And one does not have to specify the last part (<tt>typedef lambda&lt;expr&gt;::type func</tt>), because all the algorithms do this to any of their metafunction class operands internally (a <tt>lambda&lt;T&gt;::type</tt> expression applied to a metafunction class gives back the same metafunction class, so it's safe to apply the expression unconditionally).</p>
<p>The alternative way to write an equivalent of the above metafunction class would be:</p>
<pre class="programlisting">
typedef bind&lt;
mpl::meta_fun2&lt;mpl::logical_or&gt;
, mpl::bind&lt; mpl::meta_fun2&lt;mpl::less&gt;
, mpl::bind&lt; mpl::meta_fun1&lt;mpl::size_of&gt;,_1 &gt;
, mpl::int_c&lt;16&gt;
&gt;
, mpl::bind&lt; mpl::meta_fun2&lt;boost::is_same&gt;,_1,_2 &gt;
&gt; func;
</pre>
<p>Or to use <tt>mpl::compose_</tt> family of templates in a similar way. Here, we use <tt>mpl::meta_fun</tt> templates to convert metafunctions into metafunction classes and then combine them using <tt>mpl::bind</tt>. The transformation from this form to the above inline lambda expression and vice-versa is mechanical, and that is essentially what the <tt>typedef mpl::lambda&lt;expr&gt;::type</tt> expression does.</p>
<p>For its own metafunctions (algorithms, primitives, etc.), MPL enables one to write the above in a less cumbersome way:</p>
<pre class="programlisting">
typedef mpl::bind&lt;
mpl::logical_or&lt;&gt;
, mpl::bind&lt; mpl::less&lt;&gt;, mpl::bind&lt;mpl::size_of&lt;&gt;,_1&gt;, mpl::int_c&lt;16&gt; &gt;
, mpl::bind&lt; mpl::make_f2&lt;boost::is_same&gt;, _1,_2 &gt;
&gt; func;
</pre>
<p>Note that we still have to wrap <tt>is_same</tt> into <tt>make_f2</tt>, because it's a foreign template.</p>
<p>Now, about combining class template metafunctions and metafunction classes in the single lambda expression - it can be done like this:</p>
<pre class="programlisting">
struct my_predicate
{
template&lt; typename T1, typename T2 &gt; struct apply
{
//...
};
};
typedef mpl::logical_or&lt;
mpl::less&lt; mpl::size_of&lt;_&gt;,mpl::int_c&lt;16&gt; &gt;
, mpl::bind&lt; my_predicate,_,_ &gt; // here
&gt; expr;
</pre>
<p>To bind something to one of its arguments (or change the order of parameters), then use either:</p>
<pre class="programlisting">
typedef mpl::logical_or&lt;
mpl::less&lt; mpl::size_of&lt;_&gt;,mpl::int_c&lt;16&gt; &gt;
, mpl::bind&lt;my_predicate,int,_&gt;::type // here
&gt; expr;
</pre>
<p>or</p>
<pre class="programlisting">
typedef mpl::logical_or&lt;
mpl::less&lt; mpl::size_of&lt;_&gt;,mpl::int_c&lt;16&gt; &gt;
, my_predicate::apply&lt;int,_&gt; // here
&gt; expr;
</pre>
</div>
<div class="navfooter">
<hr>
<table width="100%" summary="Navigation footer">
<tr>
<td width="40%" align="left"><a accesskey="p" href="usage.html">Prev</a>&nbsp;</td>
<td width="20%" align="center"><a accesskey="u" href="index.html">Up</a></td>
<td width="40%" align="right">&nbsp;<a accesskey="n" href="codegeneration.html">Next</a></td>
</tr>
<tr>
<td width="40%" align="left" valign="top">2. Basic usage&nbsp;</td>
<td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td>
<td width="40%" align="right" valign="top">&nbsp;4. Code generation facilities</td>
</tr>
</table>
</div>
</body>
</html>
-152
View File
@@ -1,152 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type">
<title>References</title>
<link rel="stylesheet" href="article.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.50.0">
<meta name="keywords" content="template metaprogramming, generic programming, programming languages, C++, STL, type systems, polymorphism, compile-time">
<link rel="home" href="index.html" title="the boost c++ metaprogramming library">
<link rel="up" href="index.html" title="the boost c++ metaprogramming library">
<link rel="previous" href="acknowl.html" title="6. acknowledgements">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<div class="navheader">
<table width="100%" summary="Navigation header">
<tr>
<th colspan="3" align="center">References</th>
</tr>
<tr>
<td width="20%" align="left"><a accesskey="p" href="acknowl.html">Prev</a>&nbsp;</td>
<th width="60%" align="center">&nbsp;</th>
<td width="20%" align="right">&nbsp;</td>
</tr>
</table>
<hr>
</div>
<div class="bibliography">
<div class="titlepage">
<div>
<h1 class="title"><a name="refs"></a>References</h1>
</div>
</div>
<div class="biblioentry"><a name="ref.abr01"></a>
<p>[Abr01] <span class="authorgroup">David Abrahams and Carlos Pinto Coelho,</span> <span class="title"><i><a href="http://users.rcn.com/abrahams/instantiation_speed/index.html" target="_top">Effects of Metaprogramming Style on Compilation Time</a></i>,</span> <span class="date">2001</span></p>
</div>
<div class="biblioentry"><a name="ref.ale01"></a>
<p>[Ale01] <span class="author">Andrei Alexandrescu,</span> <span class="title"><i>Modern C++ Design: Generic Programming and Design Patterns Applied</i>,</span> <span class="publishername">Addison-Wesley,</span> <span class="isbn">ISBN 0-201-70431-5,</span> <span class="date">2001</span></p>
</div>
<div class="biblioentry"><a name="ref.ce98"></a>
<p>[CE98] <span class="authorgroup">Krzysztof Czarnecki and Ulrich Eisenecker,</span> <span class="title"><i>Metalisp</i>,</span> <span class="bibliomisc"><a href="http://home.t-online.de/home/Ulrich.Eisenecker/meta.htm" target="_top">http://home.t-online.de/home/Ulrich.Eisenecker/meta.htm</a></span></p>
</div>
<div class="biblioentry"><a name="ref.ce00"></a>
<p>[CE00] <span class="authorgroup">Krzysztof Czarnecki and Ulrich Eisenecker,</span> <span class="title"><i>Generative Programming: Methods, Tools, and Applications</i>,</span> <span class="publishername">Addison-Wesley,</span> <span class="isbn">ISBN 0-201-30977-7,</span> <span class="date">2000</span></p>
</div>
<div class="biblioentry"><a name="ref.ebnf"></a>
<p>[EBNF] <span class="title"><i>ISO/IEC 14977:1996(E), Information technology &mdash; Syntactic metalanguage &mdash; Extended BNF</i>,</span> <span class="orgname">ISO/IEC,</span> <span class="date">1996</span></p>
</div>
<div class="biblioentry"><a name="ref.ghj95"></a>
<p>[GHJ+95] <span class="authorgroup">Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides,</span> <span class="title"><i>Design Patterns, Elements of Reusable Object-Oriented Software</i>,</span> <span class="publishername">Addison-Wesley,</span> <span class="isbn">ISBN 0-201-63361-2,</span> <span class="date">1995</span></p>
</div>
<div class="biblioentry"><a name="ref.hu79"></a>
<p>[HU79] <span class="authorgroup">Hopcroft and Ullman,</span> <span class="title"><i>Introduction to automata theory, languages and computations</i>,</span> <span class="publishername">Addison-Wesley,</span> <span class="date">1979</span></p>
</div>
<div class="biblioentry"><a name="ref.hud89"></a>
<p>[Hud89] <span class="author">Paul Hudak,</span> <span class="title"><i>Conception, Evolution, and Application of Functional Programming Languages</i>,</span> <span class="biblioset"><i>ACM Computing Surveys</i>, <span class="publishername">Association for Computing Machinery (ACM),</span> <span class="issn">ISSN 0360-0300,</span></span> <span class="volumenum">Vol. 21,</span> <span class="issuenum">No. 3,</span> <span class="pagenums">pp. 359-411,</span> <span class="date">September, 1989</span></p>
</div>
<div class="biblioentry"><a name="ref.hun91"></a>
<p>[Hun91] <span class="author">Immo Huneke,</span> <span class="title"><i>Finite State Machines: A Model of Behavior for C++</i>,</span> <span class="biblioset"><i>C++ Report</i>, <span class="publishername">SIGS Publications Inc.,</span> <span class="issn">ISSN 1040-6042,</span></span> <span class="date">1991</span></p>
</div>
<div class="biblioentry"><a name="ref.iso98"></a>
<p>[ISO98] <span class="title"><i>ISO/IEC 14882:1998(E), Programming languages &mdash; C++</i>,</span> <span class="orgname">ISO/IEC,</span> <span class="date">1998</span></p>
</div>
<div class="biblioentry"><a name="ref.joh79"></a>
<p>[Joh79] <span class="author">Stephen C. Johnson,</span> <span class="title"><i><a href="http://dinosaur.compilertools.net/yacc/index.html" target="_top">Yacc: Yet Another Compiler Compiler</a></i>,</span> <span class="publishername">UNIX Programmer's Manual,</span> <span class="volumenum">Vol. 2b,</span> <span class="pagenums">pp. 353-387,</span> <span class="date">1979</span></p>
</div>
<div class="biblioentry"><a name="ref.laf00"></a>
<p>[Laf00] <span class="author">David Lafreniere,</span> <span class="title"><i><a href="http://www.cuj.com/articles/2000/0005/0005f/0005f.htm?topic=articles" target="_top">State Machine Design in C++</a></i>,</span> <span class="biblioset"><i>C/C++ User Journal</i>, <span class="publishername">CMP Media LCC,</span> <span class="issn">ISSN 1075-2838,</span></span> <span class="volumenum">Vol. 18,</span> <span class="issuenum">No. 5,</span> <span class="date">May 1998</span></p>
</div>
<div class="biblioentry"><a name="ref.loki"></a>
<p>[Loki] <span class="title"><i>The Loki library</i>,</span> <span class="bibliomisc"><a href="http://sourceforge.net/projects/loki-lib/" target="_top">http://sourceforge.net/projects/loki-lib/</a></span></p>
</div>
<div class="biblioentry"><a name="ref.mar98"></a>
<p>[Mar98] <span class="author">Robert C. Martin,</span> <span class="title"><i><a href="http://www.objectmentor.com/resources/articles/umlfsm.pdf" target="_top">UML Tutorial: Finite State Machines</a></i>,</span> <span class="biblioset"><i>C++ Report</i>, <span class="publishername">SIGS Publications Inc.,</span> <span class="issn">ISSN 1040-6042,</span></span> <span class="date">June 1998</span></p>
</div>
<div class="biblioentry"><a name="ref.mplr"></a>
<p>[MPLR] <span class="title"><i>Boost MPL Library Reference Documentation</i>,</span> <span class="bibliomisc"><a href="http://www.mywikinet.com/mpl/ref/Table_of_Content.html" target="_top">http://www.mywikinet.com/mpl/ref/Table_of_Content.html</a></span></p>
</div>
<div class="biblioentry"><a name="ref.pre"></a>
<p>[PRE] <span class="author">Vesa Karvonen,</span> <span class="title"><i>Boost Preprocessor Metaprogramming library</i>,</span> <span class="bibliomisc"><a href="http://www.boost.org/libs/preprocessor/doc/" target="_top">http://www.boost.org/libs/preprocessor/doc/</a></span></p>
</div>
<div class="biblioentry"><a name="ref.smc"></a>
<p>[SMC] <span class="author">Robert C. Martin,</span> <span class="title"><i>SMC - Finite State Machine Compiler (C++)</i>,</span> <span class="bibliomisc"><a href="http://www.objectmentor.com/resources/downloads/index" target="_top">http://www.objectmentor.com/resources/downloads/index</a></span></p>
</div>
<div class="biblioentry"><a name="ref.stl94"></a>
<p>[STL94] <span class="authorgroup">A. A. Stepanov and M. Lee,</span> <span class="title"><i>The Standard Template Library</i>,</span> <span class="orgname">Hewlett-Packard Laboratories,</span> <span class="date">1994</span></p>
</div>
<div class="biblioentry"><a name="ref.spl"></a>
<p>[SPL] <span class="title"><i>Boost Smart Pointer library</i>,</span> <span class="bibliomisc"><a href="http://www.boost.org/libs/smart_ptr/" target="_top">http://www.boost.org/libs/smart_ptr/</a></span></p>
</div>
<div class="biblioentry"><a name="ref.ss75"></a>
<p>[SS75] <span class="authorgroup">Gerald&nbsp;J. Sussman and Guy&nbsp;L. Steele Jr.,</span> <span class="title"><i>Scheme: An interpreter for extended lambda calculus</i>,</span> <span class="biblioset"><i>MIT AI Memo 349</i>, <span class="publishername">Massachusetts Institute of Technology,</span></span> <span class="date">May 1975</span></p>
</div>
<div class="biblioentry"><a name="ref.ttl"></a>
<p>[TTL] <span class="title"><i>Boost Type Traits library</i>,</span> <span class="bibliomisc"><a href="http://www.boost.org/libs/type_traits/" target="_top">http://www.boost.org/libs/type_traits/</a></span></p>
</div>
<div class="biblioentry"><a name="ref.vel95a"></a>
<p>[Vel95a] <span class="author">Todd Veldhuizen,</span> <span class="title"><i><a href="http://osl.iu.edu/~tveldhui/papers/Template-Metaprograms/meta-art.html" target="_top">Using C++ template metaprograms</a></i>,</span> <span class="biblioset"><i>C++ Report</i>, <span class="publishername">SIGS Publications Inc.,</span> <span class="issn">ISSN 1040-6042,</span></span> <span class="volumenum">Vol. 7,</span> <span class="issuenum">No. 4,</span> <span class="pagenums">pp. 36-43,</span> <span class="date">May 1995</span></p>
</div>
<div class="biblioentry"><a name="ref.vel95b"></a>
<p>[Vel95b] <span class="author">Todd Veldhuizen,</span> <span class="title"><i><a href="http://osl.iu.edu/~tveldhui/papers/Expression-Templates/exprtmpl.html" target="_top">Expression templates</a></i>,</span> <span class="biblioset"><i>C++ Report</i>, <span class="publishername">SIGS Publications Inc.,</span> <span class="issn">ISSN 1040-6042,</span></span> <span class="volumenum">Vol. 7,</span> <span class="issuenum">No. 5,</span> <span class="pagenums">pp. 26-31,</span> <span class="date">Jun 1995</span></p>
</div>
<div class="biblioentry"><a name="ref.unr"></a>
<p>[Unr] <span class="author">Erwin Unruh,</span> <span class="title"><i>Prime number computation</i>,</span> <span class="publishername">ANSI X3J16-94-0075/ISO WG21-462</span></p>
</div>
</div>
<div class="navfooter">
<hr>
<table width="100%" summary="Navigation footer">
<tr>
<td width="40%" align="left"><a accesskey="p" href="acknowl.html">Prev</a>&nbsp;</td>
<td width="20%" align="center"><a accesskey="u" href="index.html">Up</a></td>
<td width="40%" align="right">&nbsp;</td>
</tr>
<tr>
<td width="40%" align="left" valign="top">6. Acknowledgements&nbsp;</td>
<td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td>
<td width="40%" align="right" valign="top">&nbsp;</td>
</tr>
</table>
</div>
</body>
</html>
-920
View File
@@ -1,920 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type">
<title>2. Basic usage</title>
<link rel="stylesheet" href="article.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.50.0">
<meta name="keywords" content="template metaprogramming, generic programming, programming languages, C++, STL, type systems, polymorphism, compile-time">
<link rel="home" href="index.html" title="the boost c++ metaprogramming library">
<link rel="up" href="index.html" title="the boost c++ metaprogramming library">
<link rel="previous" href="intro.html" title="1. introduction">
<link rel="next" href="lambda.html" title="3. lambda facility">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<div class="navheader">
<table width="100%" summary="Navigation header">
<tr>
<th colspan="3" align="center">2. Basic usage</th>
</tr>
<tr>
<td width="20%" align="left"><a accesskey="p" href="intro.html">Prev</a>&nbsp;</td>
<th width="60%" align="center">&nbsp;</th>
<td width="20%" align="right">&nbsp;<a accesskey="n" href="lambda.html">Next</a></td>
</tr>
</table>
<hr>
</div>
<div class="section">
<div class="titlepage">
<div>
<h2 class="title" style="clear: both"><a name="usage"></a>2. Basic usage</h2>
</div>
</div>
<div class="section">
<div class="titlepage">
<div>
<h3 class="title"><a name="typeselection"></a>2.1. Conditional type selection</h3>
</div>
</div>
<p>Conditional type selection is the simplest basic construct of C++ template metaprogramming. Veldhuizen <span class="citation">[<a class="interlink" href="refs.html#ref.vel95a" title="[vel95a]">Vel95a</a>]</span> was the first to show how to implement it, and Czarnecki and Eisenecker <span class="citation">[<a class="interlink" href="refs.html#ref.ce00" title="[ce00]">CE00</a>]</span> first presented it as a standalone library primitive. The MPL defines the corresponding facility as follows:</p>
<pre class="programlisting">
template&lt;
typename Condition
, typename T1
, typename T2
&gt;
struct if_
{
typedef /*unspecified*/ type;
};
</pre>
<p>Note that the first template parameter of the template is a type.</p>
<pre class="programlisting">
// usage/semantics
typedef mpl::if_&lt;mpl::true_c,char,long&gt;::type t1;
typedef mpl::if_&lt;mpl::false_c,char,long&gt;::type t2;
BOOST_MPL_ASSERT_IS_SAME(t1, char);
BOOST_MPL_ASSERT_IS_SAME(t2, long);
</pre>
<p>The construct is important because template metaprograms often contain a lot of decision-making code, and, as we will show, spelling it manually every time via (partial) class template specialization quickly becomes impractical. The template is also important from the point of encapsulating the compiler workarounds.</p>
<div class="section">
<div class="titlepage">
<div>
<h4 class="title"><a name="delayedeval"></a>2.1.1. Delayed evaluation</h4>
</div>
</div>
<p>The way the C++ template instantiation mechanism works imposes some subtle limitations on applicability of the type selection primitive (<tt>if_</tt>), compared to a manually implemented equivalent of the selection code. For example, suppose we are implementing a <tt>pointed_type</tt> traits template such that <tt>pointed_type&lt;T&gt;::type</tt> instantiated for a <tt>T</tt> that is either a plain pointer (<tt>U*</tt>), <tt>std::auto_ptr&lt;U&gt;</tt>, or any of the Boost smart pointers <span class="citation">[<a class="interlink" href="refs.html#ref.spl" title="[spl]">SPL</a>]</span>, e.g. <tt>boost::scoped_ptr&lt;U&gt;</tt>, will give us the pointed type (<tt>U</tt>):</p>
<pre class="programlisting">
BOOST_MPL_ASSERT_IS_SAME(pointed_type&lt;my*&gt;::type, my);
BOOST_MPL_ASSERT_IS_SAME(pointed_type&lt; std::auto_ptr&lt;my&gt; &gt;::type, my);
BOOST_MPL_ASSERT_IS_SAME(pointed_type&lt; boost::scoped_ptr&lt;my&gt; &gt;::type, my);
</pre>
<p>Unfortunately, the straightforward application of <tt>if_</tt> to this problem does not work: <sup><a name="note.pointedtype" href="#ftn.note.pointedtype">1</a></sup></p>
<pre class="programlisting">
template&lt; typename T &gt;
struct pointed_type
: mpl::if_&lt;
boost::is_pointer&lt;T&gt;
, typename boost::remove_pointer&lt;T&gt;::type
, typename T::element_type // #1
&gt;
{
};
// the following code causes compilation error in line #1:
// name followed by "::" must be a class or namespace name
typedef pointed_type&lt;char*&gt;::type result;
</pre>
<p>Clearly, the expression <tt>typename T::element_type</tt> is not valid in the case of <tt>T == char*</tt>, and that's what the compiler is complaining about. Implementing the selection code manually solves the problem:</p>
<pre class="programlisting">
namespace aux {
// general case
template&lt; typename T, bool is_pointer = false &gt;
struct select_pointed_type
{
typedef typename T::element_type type;
};
// specialization for plain pointers
template&lt; typename T &gt;
struct select_pointed_type&lt;T,true&gt;
{
typedef typename boost::remove_pointer&lt;T&gt;::type type;
};
}
template&lt; typename T &gt;
struct pointed_type
: aux::select_pointed_type&lt;
T, boost::is_pointer&lt;T&gt;::value
&gt;
{
};
</pre>
<p>But this quickly becomes awkward if needs to be done repeatedly, and this awkwardness is compounded when partial specialization is not available. We can try to work around the problem as follows:</p>
<pre class="programlisting">
namespace aux {
template&lt; typename T &gt;
struct element_type
{
typedef typename T::element_type type;
};
}
template&lt; typename T &gt;
struct pointed_type
{
typedef typename mpl::if_&lt;
boost::is_pointer&lt;T&gt;
, typename boost::remove_pointer&lt;T&gt;::type
, typename aux::element_type&lt;T&gt;::type
&gt;::type type;
};
</pre>
<p>but this doesn't work either - the access to the <tt>aux::element_type&lt;T&gt;</tt>'s nested <tt>type</tt> member still forces the compiler to instantiate <tt>element_type&lt;T&gt;</tt> with <tt>T == char*</tt>, and that instantiation is, of course, invalid. Also, although in our case this does not lead to a compile error, the <tt>boost::remove_pointer&lt;T&gt;</tt> template always gets instantiated as well, and for the same reason (because we are accessing its nested <tt>type</tt> member). Unnecessary instantiation that is not fatal may or may be not a problem, depending on the &lsquo;weight&rsquo; of the template (how much the instantiation taxes the compiler), but a general rule of thumb would be to avoid such code.</p>
<p>Returning to our error, to make the above code compile, we need to factor the act of &lsquo;asking&rsquo; <tt>aux::element_type&lt;T&gt;</tt> for its nested <tt>type</tt> out of the <tt>if_</tt> invocation. The fact that both the <tt>boost::remove_pointer&lt;T&gt;</tt> trait template and <tt>aux::element_type&lt;T&gt;</tt> use the same naming convention for their result types makes the refactoring easier:</p>
<pre class="programlisting">
template&lt; typename T &gt;
struct pointed_type
{
private:
typedef typename mpl::if_&lt;
boost::is_pointer&lt;T&gt;
, boost::remove_pointer&lt;T&gt;
, aux::element_type&lt;T&gt;
&gt;::type func_;
public:
typedef typename func_::type type;
};
</pre>
<p>Now the compiler is guaranteed not to instantiate both <tt>boost::remove_pointer&lt;T&gt;</tt> and <tt>aux::element_type&lt;T&gt;</tt>, even although they are used as actual parameters to the <tt>if_</tt> template, so we are allowed to get away with <tt>aux::element_type&lt;char*&gt;</tt> so long as it won't end up being selected as <tt>func_</tt>.</p>
<p>The above technique is so common in template metaprograms, that it even makes sense to facilitate the selection of a nested <tt>type</tt> member by introducing a high-level equivalent to <tt>if_</tt> - the one that will do the <tt>func_::type</tt> operation (that is called [nullary] metafunction class application) as a part of its invocation. The MPL provides such template - it's called <tt>apply_if</tt>. Using it, we can re-write the above code as simple as:</p>
<pre class="programlisting">
template&lt; typename T &gt;
struct pointed_type
{
typedef typename mpl::apply_if&lt;
boost::is_pointer&lt;T&gt;
, boost::remove_pointer&lt;T&gt;
, aux::element_type&lt;T&gt;
&gt;::type type;
};
</pre>
<p>To make our techniques review complete, let's consider a slightly different example - suppose we want to define a high-level wrapper around <tt>boost::remove_pointer</tt> traits template <span class="citation">[<a class="interlink" href="refs.html#ref.ttl" title="[ttl]">TTL</a>]</span>, which will strip the pointer qualification conditionally. We will call it <tt>remove_pointer_if</tt>:</p>
<pre class="programlisting">
template&lt;
typename Condition
, typename T
&gt;
struct remove_pointer_if
{
typedef typename mpl::if_&lt;
Condition
, typename boost::remove_pointer&lt;T&gt;::type
, T
&gt;::type type;
};
</pre>
<p>Now the above works the first time, but it suffers from the problem we mentioned earlier - <tt>boost::remove_pointer&lt;T&gt;</tt> gets instantiated even if its result is never used. In the metaprogramming world compilation time is an important resource <span class="citation">[<a class="interlink" href="refs.html#ref.abr01" title="[abr01]">Abr01</a>]</span>, and it is wasted by unnecessary template instantiations. We've just seen how to deal with the problem when both arguments to <tt>if_</tt> are the results of nullary metafunction class applications, but in this example one of the arguments (<tt>T</tt>) is just a simple type, so the refactoring just doesn't seem possible.</p>
<p>The easiest way out of this situation would be to pass to <tt>if_</tt> a real nullary metafunction instead of <tt>T</tt> - the one that returns <tt>T</tt> on its invocation. The MPL provides a simple way to do it - we just substitute <tt>identity&lt;T&gt;</tt> and <tt>apply_if</tt> for <tt>T</tt> and <tt>if_</tt>:</p>
<pre class="programlisting">
template&lt;
typename Condition
, typename T
&gt;
struct remove_pointer_if
{
typedef typename mpl::apply_if&lt;
Condition
, boost::remove_pointer&lt;T&gt;
, mpl::identity&lt;T&gt;
&gt;::type type;
};
</pre>
<p>which gives us exactly what we wanted.</p>
</div>
</div>
<div class="section">
<div class="titlepage">
<div>
<h3 class="title"><a name="metafunctions"></a>2.2. Metafunctions</h3>
</div>
</div>
<div class="section">
<div class="titlepage">
<div>
<h4 class="title"><a name="metafunctions.simple"></a>2.2.1. The simple form</h4>
</div>
</div>
<p>In C++, the basic underlying language construct which allows parameterized compile-time computation is the <i>class template</i> (<span class="citation">[<a class="interlink" href="refs.html#ref.iso98" title="[iso98]">ISO98</a>]</span>, section 14.5.1 [temp.class]). A bare class template is the simplest possible model we could choose for metafunctions: it can take types and/or non-type arguments as actual template parameters, and instantiation &lsquo;returns&rsquo; a new type. For example, the following produces a type derived from its arguments:</p>
<pre class="programlisting">
template&lt; typename T1, typename T2 &gt;
struct derive : T1, T2
{
};
</pre>
<p>However, this model is far too limiting: it restricts the metafunction result not only to class types, but to instantiations of a given class template, to say nothing of the fact that every metafunction invocation introduces an additional level of template nesting. While that might be acceptable for this particular metafunction, any model which prevented us from &lsquo;returning&rsquo;, say, <tt>int</tt> is obviously not general enough. To meet this basic requirement, we must rely on a nested type to provide our return value:</p>
<pre class="programlisting">
template&lt; typename T1, typename T2 &gt;
struct derive
{
struct type : N1, N2 {};
};
// silly specialization, but demonstrates "returning" int
template&lt;&gt;
struct derive&lt;void,void&gt;
{
typedef int type;
};
</pre>
<p>Veldhuizen <span class="citation">[<a class="interlink" href="refs.html#ref.vel95a" title="[vel95a]">Vel95a</a>]</span> was first to talk about class templates of this form as &lsquo;compile-time functions&rsquo;, and Czarnecki and Eisenecker <span class="citation">[<a class="interlink" href="refs.html#ref.ce00" title="[ce00]">CE00</a>]</span> have introduced &lsquo;template metafunction&rsquo; as an equivalent term (they also use the simpler term &lsquo;metafunction&rsquo;, as do we). Czarnecki and Eisenecker have also recognized the limitations of the simple metafunction representation and suggested the form that we discuss in <a class="interlink" href="usage.html#metafunctions.classes" title="2.2.3. metafunction classes">Section 2.2.3</a>.</p>
</div>
<div class="section">
<div class="titlepage">
<div>
<h4 class="title"><a name="metafunctions.higherorder"></a>2.2.2. Higher-order metafunctions</h4>
</div>
</div>
<p>While syntactically simple, the simple template metafunction form does not always interact optimally with the rest of C++. In particular, the simple metafunction form makes it unnecessarily awkward and tedious to define and work with higher-order metafunctions (metafunctions that operate on other metafunctions). In order to pass a simple metafunction to another template, we need to use <i>template template parameters</i>:</p>
<pre class="programlisting">
// returns F(T1,F(T2,T3))
template&lt;
template&lt;typename&gt; class F
, typename T1
, typename T2
, typename T3
&gt;
struct apply_twice
{
typedef typename F&lt;
T1
, typename F&lt;T2,T3&gt;::type
&gt;::type type;
};
// a new metafunction returning a type derived from T1, T2, and T3
template&lt;
typename T1
, typename T2
, typename T3
&gt;
struct derive3
: apply_twice&lt;derive,T1,T2,T3&gt;
{
};
</pre>
<p>This looks different, but it seems to work. <sup><a name="note.higherorder" href="#ftn.note.higherorder">2</a></sup> However, things begin to break down noticeably when we want to &lsquo;return&rsquo; a metafunction from our metafunction:</p>
<pre class="programlisting">
// returns G s.t. G(T1,T2,T3) == F(T1,F(T2,T3))
template&lt; template&lt;typename&gt; class F &gt;
struct compose_self
{
template&lt;
typename T1
, typename T2
, typename T3
&gt;
struct type
: apply_twice&lt;F,T1,T2,T3&gt;
{
};
};
</pre>
<p>The first and most obvious problem is that the result of applying <tt>compose_self</tt> is not itself a type, but a template, so it can't be passed in the usual ways to other metafunctions. A more subtle issue, however, is that the metafunction &lsquo;returned&rsquo; is not exactly what we intended. Although it acts just like <tt>apply_twice</tt>, it differs in one important respect: its identity. In the C++ type system, <tt>compose_self&lt;F&gt;::template type&lt;T,U,V&gt;</tt> is not a synonym for <tt>apply_twice&lt;F,T,U,V&gt;</tt>, and any metaprogram which compared metafunctions would discover that fact.</p>
<p>Because C++ makes a strict distinction between type and class template template parameters, reliance on simple metafunctions creates a &lsquo;wall&rsquo; between metafunctions and metadata, relegating metafunctions to the status of second-class citizens. For example, recalling our introduction to type sequences, there's no way to make a <tt>cons</tt> list of metafunctions:</p>
<pre class="programlisting">
typedef cons&lt;derive, cons&lt;derive3, nil&gt; &gt; derive_functions; // error!
</pre>
<p>We might consider redefining our <tt>cons</tt> cell so we can pass <tt>derive</tt> as the head element:</p>
<pre class="programlisting">
template &lt;
template&lt; template&lt;typename T, typename U&gt; class F
, typename Tail
&gt;
struct cons;
</pre>
<p>However, now we have another problem: C++ templates are polymorphic with respect to their type arguments, but not with respect to template template parameters. The arity (number of parameters) of any template template parameter is strictly enforced, so we <span class="emphasis"><em>still</em></span> can't embed <tt>derive3</tt> in a <tt>cons</tt> list. Moreover, polymorphism <span class="emphasis"><em>between</em></span> types and metafunctions is not supported (the compiler expects one or the other), and as we've seen, the syntax and semantics of &lsquo;returned&rsquo; metafunctions is different from that of returned types. Trying to accomplish everything with the simple template metafunction form would seriously limit the applicability of higher-order metafunctions and would have an overall negative effect on the both conceptual and implementation clarity, simplicity and size of the library.</p>
</div>
<div class="section">
<div class="titlepage">
<div>
<h4 class="title"><a name="metafunctions.classes"></a>2.2.3. Metafunction classes</h4>
</div>
</div>
<p>Fortunately, the truism that &lsquo;there is no problem in software which can't be solved by adding yet another level of indirection&rsquo; applies here. To elevate metafunctions to the status of first-class objects, the MPL introduces the concept of a &lsquo;metafunction class&rsquo;:</p>
<pre class="programlisting">
// metafunction class form of derive
struct derive
{
template&lt; typename N1, typename N2 &gt;
struct apply
{
struct type : N1, N2 {};
};
};
</pre>
<p>This form should look familiar to anyone acquainted with function objects in STL, with the nested <tt>apply</tt> template taking the same role as the runtime function-call operator. In fact, compile-time metafunction classes have the same relationship to metafunctions that runtime function objects have to functions:</p>
<pre class="programlisting">
// function form of add
template&lt; typename T &gt; T add(T x, T y) { return x + y; }
// function object form of add
struct add
{
template&lt; typename T &gt;
T operator()(T x, T y) { return x + y; }
};
</pre>
</div>
<div class="section">
<div class="titlepage">
<div>
<h4 class="title"><a name="metafunctions.onesize"></a>2.2.4. One size fits all?</h4>
</div>
</div>
<p>The metafunction class form solves all the problems with ordinary template metafunction mentioned earlier: since it is a regular class, it can be placed in compile-time metadata sequences and manipulated by other metafunctions using the same protocols as for any other metadata. We thereby avoid the code-duplication needed to provide versions of each library component to operate on ordinary metadata and on metafunctions with each distinct supported arity.</p>
<p>On the other hand, it seems that accepting metafunction classes as <span class="emphasis"><em>the</em></span> representation for compile-time function entities imposes code duplication danger as well: if the library's own primitives, algorithms, etc. are represented as class templates, that means that one either cannot reuse these algorithms in the context of higher-order functions, or she have to duplicate all algorithms in the second form, so, for instance, there would be two versions of <tt>find</tt>:</p>
<pre class="programlisting">
// user-friendly form
template&lt;
typename Sequence
, typename T
&gt;
struct find
{
typedef /* ... */ type;
};
// "metafunction class" form
struct find_func
{
template&lt; typename Sequence, typename T &gt;
struct apply
{
typedef /* ... */ type;
};
};
</pre>
<p>Of course, the third option is to eliminate &lsquo;user-friendly form&rsquo; completely so one would always have to write:</p>
<pre class="programlisting">
typedef mpl::find::apply&lt;list,long&gt;::type iter;
// or, if one prefers,
// typedef mpl::apply&lt; mpl::find,list,long &gt;::type iter;
</pre>
<p>instead of</p>
<pre class="programlisting">
typedef mpl::find&lt;list,long&gt;::type iter;
</pre>
<p>That too would hurt usability, considering that the direct invocations of library's algorithms are far more often-used than passing algorithms as arguments to other algorithms/metafunctions.</p>
</div>
<div class="section">
<div class="titlepage">
<div>
<h4 class="title"><a name="metafunctions.lambda"></a>2.2.5. From metafunction to metafunction class</h4>
</div>
</div>
<p>The MPL's answer to this dilemma is <i>lambda expressions</i>. Lambda is the mechanism that enables the library to curry metafunctions and convert them into metafunction classes, so when one wants to pass the <tt>find</tt> algorithm as an argument to a higher-order metafunction, she just write:</p>
<pre class="programlisting">
using namespace mpl::placeholder;
typedef mpl::apply&lt; my_f, mpl::find&lt;_1,_2&gt; &gt;::type result;
</pre>
<p>where <tt>_1</tt> and <tt>_2</tt> are placeholders for the first and second arguments to the resulting metafunction class. This preserves the intuitive syntax below for when the user wants to use <tt>find</tt> directly in her code:</p>
<pre class="programlisting">
typedef mpl::find&lt;list,long&gt;::type iter;
</pre>
<p>Lambda facility is described in more details in <a class="interlink" href="lambda.html#lambda" title="3. lambda facility">Section 3</a>.</p>
</div>
</div>
<div class="section">
<div class="titlepage">
<div>
<h3 class="title"><a name="sequences"></a>2.3. Sequences, algorithms, and iterators</h3>
</div>
</div>
<div class="section">
<div class="titlepage">
<div>
<h4 class="title"><a name="sequences.intro"></a>2.3.1. Introduction</h4>
</div>
</div>
<p>Compile-time iteration over a sequence (of types) is one of the basic concepts of template metaprogramming. Differences in types of objects being manipulated is the most common point of variability of similar but not identical code/design, and such designs are the direct target for some metaprogramming. Templates were originally designed to solve this exact problem (e.g. <tt>std::vector</tt>). However, without predefined abstractions/constructs for manipulating/iterating over <span class="emphasis"><em>sequences</em></span> of types (as opposed to standalone types), and without known techniques for emulating these constructs using the current language facilities, their effect on helping high-level metaprogramming happen has been limited.</p>
<p>Czarnecki and Eisenecker <span class="citation">[<a class="interlink" href="refs.html#ref.ce98" title="[ce98]">CE98</a>]</span>, <span class="citation">[<a class="interlink" href="refs.html#ref.ce00" title="[ce00]">CE00</a>]</span> were the first to introduce compile-time sequences of types and some simple algorithms on them, although the idea of representing common data structures like trees, lists, etc. at compile time, using class template composition has been around for a while (e.g. most of the expression template libraries build such trees as a part of their expression "parsing" process <span class="citation">[<a class="interlink" href="refs.html#ref.vel95b" title="[vel95b]">Vel95b</a>]</span>). Alexandrescu <span class="citation">[<a class="interlink" href="refs.html#ref.ale01" title="[ale01]">Ale01</a>]</span> used lists of types and some algorithms on them to implement several design patterns; the accompanying code is known as the Loki library <span class="citation">[<a class="interlink" href="refs.html#ref.loki" title="[loki]">Loki</a>]</span>.</p>
</div>
<div class="section">
<div class="titlepage">
<div>
<h4 class="title"><a name="sequences.algo"></a>2.3.2. Algorithms and sequences</h4>
</div>
</div>
<p>Most of the algorithms in the Boost Metaprogramming Library operate on sequences. For example, searching for a type in a list looks like this:</p>
<pre class="programlisting">
typedef mpl::list&lt;char,short,int,long,float,double&gt; types;
typedef mpl::find&lt;types,long&gt;::type iter;
</pre>
<p>Here, <tt>find</tt> accepts two parameters - a sequence to search (<tt>types</tt>) and the type to search for (<tt>long</tt>) - and returns an iterator <tt>iter</tt> pointing to the first element of the sequence such that <tt>iter::type</tt> is identical to <tt>long</tt>. If no such element exists, <tt>iter</tt> is identical to <tt>end&lt;types&gt;::type</tt>. Basically, this is how one would search for a value in a <tt>std::list</tt> or <tt>std::vector</tt>, except that <tt>mpl::find</tt> accepts the sequence as a single parameter, while <tt>std::find</tt> takes two iterators. Everything else is pretty much the same - the names are the same, the semantics are very close, there are iterators, and one can search not only by type, but also by using a predicate:</p>
<pre class="programlisting">
typedef mpl::find_if&lt; types,boost::is_float&lt;_&gt; &gt;::type iter;
</pre>
<p>This conceptual/syntactical similarity with the STL is not coincidental. Reusing the conceptual framework of the STL in the compile-time world allows us to apply familiar and sound approaches for dealing with sequential data structures. The algorithms and idioms which programmers already know from the STL can be applied again at compile-time. We consider this to be one of MPL's greatest strengths, distinguishing it from earlier attempts to build a template metaprogramming library.</p>
</div>
<div class="section">
<div class="titlepage">
<div>
<h4 class="title"><a name="sequences.concepts"></a>2.3.3. Sequence concepts</h4>
</div>
</div>
<p>In the <tt>find</tt> example above, we searched for the type in a sequence built using the <tt>mpl::list</tt> template; but <tt>list</tt> is not the only sequence that the library provides. Neither is <tt>mpl::find</tt> or any other algorithm hard-coded to work only with <tt>list</tt> sequences. <tt>list</tt> is just one model of MPL's <span class="concept">Forward Sequence</span> concept, and <tt>find</tt> works with anything that satisfies this concept's requirements. The hierarchy of sequence concepts in MPL is quite simple - a <span class="concept">Sequence</span> is any compile-time entity for which <tt>begin&lt;&gt;</tt> and <tt>end&lt;&gt;</tt> produce iterators to the range of its elements; a <span class="concept">Forward Sequence</span> is a Sequence whose iterators satisfy <span class="concept">Forward Iterator</span> requirements; a <span class="concept">Bidirectional Sequence</span> is a Forward Sequence whose iterators satisfy <span class="concept">Bidirectional Iterator</span> requirements; finally, a <span class="concept">Random Access Sequence</span> is a Bidirectional Sequence whose iterators satisfy <span class="concept">Random Access Iterator</span> requirements. <sup><a name="note.seqconcepts" href="#ftn.note.seqconcepts">3</a></sup></p>
<p>Decoupling algorithms from particular sequence implementations (through iterators) allows a metaprogrammer to create her own sequence types and to retain the rest of the library at her disposal. For example, one can define a <tt>tiny_list</tt> for dealing with sequences of three types as follows:</p>
<pre class="programlisting">
template&lt; typename TinyList, long Pos &gt;
struct tiny_list_item;
template&lt; typename TinyList, long Pos &gt;
struct tiny_list_iterator
{
typedef typename tiny_list_item&lt;TinyList,Pos&gt;::type type;
typedef tiny_list_iterator&lt;TinyList, Pos-1&gt; prior;
typedef tiny_list_iterator&lt;TinyList, Pos+1&gt; next;
};
template&lt; typename T0, typename T1, typename T2 &gt;
struct tiny_list
{
typedef tiny_list_iterator&lt;tiny_list, 0&gt; begin;
typedef tiny_list_iterator&lt;tiny_list, 3&gt; end;
typedef T0 type0;
typedef T1 type1;
typedef T2 type2;
};
template&lt; typename TinyList &gt;
struct tiny_list_item&lt;TinyList,0&gt;
{
typedef typename TinyList::type0 type;
};
template&lt; typename TinyList &gt;
struct tiny_list_item&lt;TinyList,1&gt;
{
typedef typename TinyList::type1 type;
};
template&lt; typename TinyList &gt;
struct tiny_list_item&lt;TinyList,2&gt;
{
typedef typename TinyList::type2 type;
};
</pre>
<p>and then use it with any of the library algorithms as if it were <tt>mpl::list</tt>:</p>
<pre class="programlisting">
typedef tiny_list&lt; char,short,int &gt; types;
typedef mpl::transform&lt;
types
, boost::add_pointer&lt;_1&gt;
&gt;::type pointers;
</pre>
<p>Note that <tt>tiny_list</tt> is a model of Bidirectional Sequence; it would be a Random Access Sequence if we added <tt>advance</tt> and <tt>distance</tt> members to <tt>tiny_list_iterator</tt>:</p>
<pre class="programlisting">
template&lt; typename TinyList, long Pos &gt;
struct tiny_list_iterator
{
static long const position = Pos;
typedef typename tiny_list_item&lt;TinyList,Pos&gt;::type type;
typedef tiny_list_iterator&lt;TinyList, Pos-1&gt; prior;
typedef tiny_list_iterator&lt;TinyList, Pos+1&gt; next;
template&lt; typename N &gt; struct advance
{
typedef tiny_list_iterator&lt;
TinyList
, Pos + N::value
&gt; type;
};
template&lt; typename Other &gt; struct distance
{
typedef mpl::integral_c&lt;
long
, Other::position - position
&gt; type;
};
};
</pre>
<p>While the <tt>tiny_list</tt> itself might be not that interesting (after all, it can hold only three elements), if the technique above could be automated so we would be able to define not-so-tiny sequences (with five, ten, twenty, etc. elements), it would be very valuable. <sup><a name="note.tinylist" href="#ftn.note.tinylist">4</a></sup></p>
<p>External code generation is an option, but there exists a solution within the language. However, it is not a template metaprogramming, but rather <span class="emphasis"><em>preprocessor metaprogramming</em></span>. In fact, MPL's <tt>vector</tt> - a fixed-size type sequence that provides random-access iterators - is implemented very much like the above <tt>tiny_list</tt> - using the Boost Preprocessor library <span class="citation">[<a class="interlink" href="refs.html#ref.pre" title="[pre]">PRE</a>]</span>.</p>
</div>
<div class="section">
<div class="titlepage">
<div>
<h4 class="title"><a name="sequences.revisited"></a>2.3.4. Ad hoc example revisited</h4>
</div>
</div>
<p>So, the library provides its users with almost complete compile-time equivalent of the STL framework. Does it help them to solve their metaprogramming tasks? Let's return to our earlier <a class="interlink" href="intro.html#example.largest" title="example 1. 'largest' metafunction"><tt>largest</tt></a> example to see if we can rewrite it in a better way with what MPL has to offer. Well, actually, there is not much to look at, because the MPL implementation is a one-liner (we'll spread it out here for readability) <sup><a name="note.maxelement" href="#ftn.note.maxelement">5</a></sup> :</p>
<pre class="programlisting">
template&lt; typename Sequence &gt;
struct largest
{
typedef typename mpl::max_element&lt;
Sequence
mpl::less&lt;
mpl::size_of&lt;_1&gt;
, mpl::size_of&lt;_2&gt;
&gt;
&gt;::type iter;
typedef typename iter::type type;
};
</pre>
<p>There are no more termination conditions with tricky pattern matching, no more partial specializations; and even more importantly, it's <span class="emphasis"><em>obvious</em></span> what the above code does - even although it's all templates - something that one could not say about the original version.</p>
</div>
<div class="section">
<div class="titlepage">
<div>
<h4 class="title"><a name="sequences.iterfold"></a>2.3.5. iter_fold as the main iteration algorithm</h4>
</div>
</div>
<p>For the purpose of examining a little bit more of the library's internal structure, let's look at how <tt>max_element</tt> from the above example is implemented. One might expect that <span class="emphasis"><em>now</em></span> we will again see all these awkward partial specializations, esoteric pattern matching, etc. Well, let's see:</p>
<pre class="programlisting">
template&lt;
typename Sequence
, typename Predicate
&gt;
struct max_element
{
typedef typename mpl::iter_fold&lt;
Sequence
, typename mpl::begin&lt;Sequence&gt;::type
, if_&lt; less&lt; deref&lt;_1&gt;,deref&lt;_2&gt; &gt;, _2, _1 &gt;
&gt;::type type;
};
</pre>
<p>The first thing to notice here is that this algorithm is implemented in terms of another one: <tt>iter_fold</tt>. In fact, this is probably the most important point of the example, because nearly all other generic sequence algorithms in the library are implemented in terms of <tt>iter_fold</tt>. If a user should ever need to implement her own sequence algorithm, she'll almost certainly be able to do so using this primitive, which means she won't have to resort to implementing hand-crafted iteration, pattern matching of special cases for loop termination, or workarounds for lack of partial specialization. It also means that her algorithm will automatically benefit from any optimizations the library has implemented, (e.g. recursion unrolling), and that it will work with any sequence that is a model of ForwardSequence, because <tt>iter_fold</tt> does not require anything more of its sequence argument.</p>
<p><tt>iter_fold</tt> algorithm is basically a compile-time equivalent of the <tt>fold</tt> or <tt>reduce</tt> functions that comprise the basic and well-known primitives of many functional programming languages. An analogy more familiar to a C++ programmer would be the <tt>std::accumulate</tt> algorithm from the C++ standard library (<span class="citation">[<a class="interlink" href="refs.html#ref.iso98" title="[iso98]">ISO98</a>]</span>, section 26.4.1 [lib.accumulate]). However, <tt>iter_fold</tt> is designed to take advantage of the natural characteristics of recursive traversal: it accepts <span class="emphasis"><em>two</em></span> metafunction class arguments, the first of which is applied to the state "on the way in" and the second of which is applied "on the way out".</p>
<p>The interface to <tt>iter_fold</tt> is defined in MPL as follows:</p>
<pre class="programlisting">
template&lt;
typename Sequence
, typename InitialState
, typename ForwardOp
, typename BackwardOp = _1
&gt;
struct iter_fold
{
typedef /*unspecified*/ type;
};
</pre>
<p>The algorithm &lsquo;returns&rsquo; the result of two-way successive applications of binary <tt>ForwardOp</tt> and <tt>BackwardOp</tt> operations to iterators in range [<tt>begin&lt;Sequence&gt;::type</tt>, <tt>end&lt;Sequence&gt;::type</tt>) and previous result of an operation; the <tt>InitialState</tt> is logically placed before the sequence and included in the forward traversal. The result <tt>type</tt> is identical to <tt>InitialState</tt> if the sequence is empty.</p>
<p>The library also provides <tt>iter_fold_backward</tt>, <tt>fold</tt>, and <tt>fold_backward</tt> algorithms which wrap <tt>iter_fold</tt> to accommodate its most common usage patterns.</p>
</div>
<div class="section">
<div class="titlepage">
<div>
<h4 class="title"><a name="sequences.numbers"></a>2.3.6. Sequences of numbers</h4>
</div>
</div>
<p>What we've seen so far were sequences (and algorithms on sequences) of types. It is both possible and easy to manipulate compile-time <span class="emphasis"><em>values</em></span> using the library as well. The only thing to remember is that in C++, class template non-type template parameters give us one more example of non-polymorphic behavior. In other words, if one declared a metafunction to take a non-type template parameter (e.g. <tt>long</tt>) it's not possible to pass anything besides compile-time integral constants to it:</p>
<pre class="programlisting">
template&lt; long N1, long N2 &gt;
struct equal_to
{
static bool const value = (N1 == N2);
};
equal_to&lt;5,5&gt;::value; // ok
equal_to&lt;int,int&gt;::value; // error!
</pre>
<p>And of course this doesn't work the other way around either:</p>
<pre class="programlisting">
typedef mpl::list&lt;1,2,3,4,5&gt; numbers; // error!
</pre>
<p>While this may be an obvious limitation, it imposes yet another dilemma on the library design: on the one hand, we don't want to restrict users to type manipulations only, and on the other hand, full support for integral manipulations would require at least duplication of most of the library facilities <sup><a name="note.nontype" href="#ftn.note.nontype">6</a></sup> - the same situation as we would have if we had chosen to represent metafunctions as ordinary class templates. The solution for this issue is the same as well: we represent integral values by wrapping them in types <sup><a name="note.valuewrapping" href="#ftn.note.valuewrapping">7</a></sup> . For example, to create a list of numbers one can write:</p>
<pre class="programlisting">
typedef mpl::list&lt;
mpl::int_c&lt;1&gt;
, mpl::int_c&lt;2&gt;
, mpl::int_c&lt;3&gt;
, mpl::int_c&lt;4&gt;
, mpl::int_c&lt;5&gt;
&gt; numbers;
</pre>
<p>Wrapping integral constants into types to make them first-class citizens is important well inside metaprograms, where one often doesn't know (and doesn't care) if the metafunctions she is using operate on types, integral values, other metafunctions, or something else, like fixed-point or rational numbers (<tt>mpl::fixed_c</tt> and <tt>mpl::rational_c</tt>).</p>
<p>But, from the user's perspective, the above example is much more verbose than the shorter, incorrect one. Thus, for the purpose of convenience, the library does provide users with a template that takes non-type template parameters, but offers a more compact notation:</p>
<pre class="programlisting">
typedef mpl::list_c&lt;long,1,2,3,4,5&gt; numbers;
</pre>
<p>There is a similar <tt>vector</tt> counterpart as well:</p>
<pre class="programlisting">
typedef mpl::vector_c&lt;long,1,2,3,4,5&gt; numbers;
</pre>
</div>
<div class="section">
<div class="titlepage">
<div>
<h4 class="title"><a name="sequences.variety"></a>2.3.7. A variety of sequences</h4>
</div>
</div>
<p>Previous efforts to provide generalized metaprogramming facilities for C++ have always concentrated on <tt>cons</tt>-style type lists and a few core algorithms like <tt>size</tt> and <tt>at</tt>, which are tied to the specific sequence implementation. Such systems have an elegant simplicity reminiscent of the analogous functionality in pure functional Lisp. It is much more time-consuming to implement even a basic set of the sequence algorithms provided by equivalent run-time libraries (the STL in particular), but if we have learned anything from the STL, it is that tying those algorithms' implementations to a specific sequence implementation is a misguided effort!</p>
<p>The truth is that there is no single &lsquo;best&rsquo; type sequence implementation for the same reasons that there will never be a single &lsquo;best&rsquo; runtime sequence implementation. Furthermore, there are <span class="emphasis"><em>already</em></span> quite a number of type list implementations in use today; and just as the STL algorithms can operate on sequences which don't come from STL containers, so the MPL algorithms are designed to work with foreign type sequences.</p>
<p>It may be an eye-opening fact for some that type lists are not the only useful compile-time sequence. Again, the need for a variety of compile-time containers arises for the same reasons that we have lists, vectors, deques, and sets in the C++ standard library - different containers have different functional and performance characteristics which determine not only applicability and efficiency of particular algorithms, but also the expressiveness or verbosity of the code that uses them. While runtime performance is not an issue for C++ metaprograms, compilation speed is often a significant bottleneck to advanced C++ software development <span class="citation">[<a class="interlink" href="refs.html#ref.abr01" title="[abr01]">Abr01</a>]</span>.</p>
<p>The MPL provides five built-in sequences: <tt>list</tt>, <tt>list_c</tt> (really just a <tt>list</tt> of value wrappers), <tt>vector</tt>, a randomly-accessible sequence of fixed maximum size, <tt>vector_c</tt>, and <tt>range_c</tt>, a randomly-accessible sequence of consecutive integral values. More important, however, is its ability to adapt to arbitrary sequence types. The only core operations that a sequence is required to provide in order to be used with the library algorithms are <tt>begin&lt;&gt;</tt> and <tt>end&lt;&gt;</tt> metafunctions which "return" iterators into the sequence. As with the STL, it is the iterators which are used to implement most of the general-purpose sequence algorithms the library provides. Also, as with the STL, algorithm specialization is used to take advantage of implementation knowledge about particular sequences: many of the "basic" sequence operations such as <tt>back&lt;&gt;</tt>, <tt>front&lt;&gt;</tt>, <tt>size&lt;&gt;</tt>, and <tt>at&lt;&gt;</tt> are specialized on sequence type to provide a more efficient implementation than the fully generic version.</p>
</div>
<div class="section">
<div class="titlepage">
<div>
<h4 class="title"><a name="sequences.unrolling"></a>2.3.8. Loop/recursion unrolling</h4>
</div>
</div>
<p>Almost coincidentally, loop unrolling can be as important to compile-time iterative algorithms as it is to runtime algorithms. To see why, one must first remember that all "loops" in C++ metaprograms, are in fact, implemented with recursion, and that the template instantiation depth can be a valuable resource in a compiler implementation. In fact, Annex B of the C++ standard (<span class="citation">[<a class="interlink" href="refs.html#ref.iso98" title="[iso98]">ISO98</a>]</span>, annex B [limits]) <span class="emphasis"><em>recommends</em></span> a minimum depth of 17 recursively nested template instantiations; but this is far too low for many serious metaprograms, some of which easily exceed the hard-coded instantiation limits of some otherwise excellent compilers. To see how this works in action, let's examine a straightforward implementation of the <tt>fold</tt> metafunction, which combines some algorithm state with each element of a sequence:</p>
<pre class="programlisting">
namespace aux {
// unspecialized version combines the initial state and first element
// and recurses to process the rest
template&lt;
typename Start
, typename Finish
, typename State
, typename BinaryFunction
&gt;
struct fold_impl
: fold_impl&lt;
typename Start::next
, Finish
, typename apply&lt;
BinaryFunction
, State
, typename Start::type
&gt;::type
, BinaryFunction
&gt;
{
};
// specialization for loop termination
template&lt;
typename Finish
, typename State
, typename BinaryFunction
&gt;
struct fold_impl&lt;Finish,Finish,State,BinaryFunction&gt;
{
typedef State type;
};
} // namespace aux
// public interface
template&lt;
typename Sequence
, typename State
, typename ForwardOp
&gt;
struct fold
: aux::fold_impl&lt;
, typename begin&lt;Sequence&gt;::type
, typename end&lt;Sequence&gt;::type
, State
, typename lambda&lt;ForwardOp&gt;::type
&gt;
{
};
</pre>
<p>Although simple and elegant, this implementation will always incur at least as many levels of recursive template instantiation as there are elements in the input sequence. <sup><a name="note.unrolling1" href="#ftn.note.unrolling1">8</a></sup> The library addresses this problem by explicitly "unrolling" the recursion. To apply the technique to our <tt>fold</tt> example, we begin by factoring out a single step of the algorithm. Our <tt>fold_impl_step</tt> metafunction has two results: <tt>type</tt> (the next state), and <tt>iterator</tt> (the next sequence position).</p>
<pre class="programlisting">
template&lt;
typename BinaryFunction
, typename State
, typename Start
, typename Finish
&gt;
struct fold_impl_step
{
typedef typename apply&lt;
BinaryFunction
, State
, typename Start::type
&gt;::type type;
typedef typename Start::next iterator;
};
</pre>
<p>As with our main algorithm implementation, we specialize for the loop termination condition so that the step becomes a no-op:</p>
<pre class="programlisting">
template&lt;
typename BinaryFunction
, typename State
, typename Finish
&gt;
struct fold_impl_step&lt;BinaryFunction,State,Finish,Finish&gt;
{
typedef State type;
typedef Finish iterator;
};
</pre>
<p>Now we can now reduce <tt>fold</tt>'s instantiation depth by any constant factor N simply by inserting N invocations of <tt>fold_impl_step</tt>. Here we've chosen a factor of 4:</p>
<pre class="programlisting">
template&lt;
typename Start
, typename Finish
, typename State
, typename BinaryFunction
&gt;
struct fold_impl
{
private:
typedef fold_impl_step&lt;
BinaryFunction
, State
, Start
, Finish
&gt; next1;
typedef fold_impl_step&lt;
BinaryFunction
, typename next1::type
, typename next1::iterator
, Finish
&gt; next2;
typedef fold_impl_step&lt;
BinaryFunction
, typename next2::type
, typename next2::iterator
, Finish
&gt; next3;
typedef fold_impl_step&lt;
BinaryFunction
, typename next3::type
, typename next3::iterator
, Finish
&gt; next4;
typedef fold_impl_step&lt;
typename next4::iterator
, Finish
, typename next4::type
, BinaryFunction
&gt; recursion;
public:
typedef typename recursion::type type;
};
</pre>
<p>The MPL applies this unrolling technique across all algorithms with an unrolling factor tuned according to the demands of the C++ implementation in use, and with an option for the user to override the value. <sup><a name="note.unrolling2" href="#ftn.note.unrolling2">9</a></sup> This fact enables users to push beyond the metaprogramming limits they would usually encounter with more naive algorithm implementations. Experiments also show a small (up to 10%) increase in metaprogram instantiation speed on some compilers when loop unrolling is used.</p>
</div>
</div>
</div>
<div class="navfooter">
<hr>
<table width="100%" summary="Navigation footer">
<tr>
<td width="40%" align="left"><a accesskey="p" href="intro.html">Prev</a>&nbsp;</td>
<td width="20%" align="center"><a accesskey="u" href="index.html">Up</a></td>
<td width="40%" align="right">&nbsp;<a accesskey="n" href="lambda.html">Next</a></td>
</tr>
<tr>
<td width="40%" align="left" valign="top">1. Introduction&nbsp;</td>
<td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td>
<td width="40%" align="right" valign="top">&nbsp;3. Lambda facility</td>
</tr>
</table>
</div>
</body>
</html>
-11
View File
@@ -1,11 +0,0 @@
@echo off
if "%4" == "" goto build
f:\msxsl\msxsl.exe f:\home\depot\xml\stylesheets\docbook-xsl-1.50.0\html\titlepage.templates.xml f:\home\depot\xml\stylesheets\docbook-1.50.0\template\titlepage.xsl | f:\msxsl\msxsl.exe - f:\msxsl\to_utf8.xsl -o f:\home\depot\xml\stylesheets\docbook-xsl-1.50.0\html\titlepage.templates.xsl
:build
sx -x lower -x empty %2 >%3.xml
xsltproc -o %3 f:\home\depot\xml\stylesheets\docbook-xsl-1.50.0\html\my\%1 %3.xml
del %3.xml
f:\tidy\tidy.exe -config f:\tidy\config.txt -m %3
f:\tidy\tidy_attr.py %3
File diff suppressed because it is too large. Load diff
-38
View File
@@ -1,38 +0,0 @@
<articleinfo>
<authorgroup>
<author>
<firstname>Aleksey</><surname>Gurtovoy</>
<affiliation>
<orgname>MetaCommunications</>
<address><email>agurtovoy@meta-comm.com</></>
</affiliation>
</author>
<author>
<firstname>David</><surname>Abrahams</>
<affiliation>
<orgname>Boost Consulting</>
<address><email>david.abrahams@rcn.com</></>
</affiliation>
</author>
</authorgroup>
<abstract>
<para>
This paper describes the &Boost; &Cxx; template metaprogramming library (&MPL;), an extensible compile-time framework of algorithms, sequences and metafunction classes. The library brings together important abstractions from the generic and functional programming worlds to build a powerful and easy-to-use toolset which makes template metaprogramming practical enough for the real-world environments. The &MPL; is heavily influenced by its run-time equivalent - the Standard Template Library (STL), a part of the C++ standard library <citation><xref linkend="ref.STL94"></>, <citation><xref linkend="ref.ISO98"></>. Like the STL, it defines an open conceptual and implementation framework which can serve as a foundation for future contributions in the domain. The library's fundamental concepts and idioms enable the user to focus on solutions without navigating the universe of possible ad-hoc approaches to a given metaprogramming problem, even if no actual &MPL; code is used. The library also provides a compile-time lambda expression facility enabling arbitrary currying and composition of class templates, a feature whose runtime counterpart is often cited as missing from the STL. This paper explains the motivation, usage, design, and implementation of the &MPL; with examples of its real-life applications, and offers some lessons learned about &Cxx; template metaprogramming.
</>
</abstract>
<keywordset>
<keyword>template metaprogramming</>
<keyword>generic programming</>
<keyword>programming languages</>
<keyword>C++</>
<keyword>STL</>
<keyword>type systems</>
<keyword>polymorphism</>
<keyword>compile-time</>
</keywordset>
</articleinfo>
-10
View File
@@ -1,10 +0,0 @@
<!-- ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| section -->
<section id="acknowl">
<title>Acknowledgements</>
<para>
Peter Dimov contributed the <literal>bind</> functionality without which compile-time lambda expressions wouldn't have been possible. The &MPL; implementation would have been much more difficult without Vesa Karvonen's wonderful Boost Preprocessor Metaprogramming Library. Authors are also greatly indebted to David B. Held who kindly volunteered to thoroughly edit this document. Of course, any remaining errors are exclusively ours.
</>
</section>
-41
View File
@@ -1,41 +0,0 @@
<!doctype article public "-//OASIS//DTD DocBook V4.1//EN"
[
<!-- abbreviations -->
<!entity mdash "-">
<!entity Boost "<literal>Boost</>">
<!entity Cxx "C++">
<!entity C "C">
<!entity MPL "MPL">
<!entity BMPL "Boost Metaprogramming Library">
<!entity mdat "metadata">
<!entity mping "metaprogramming">
<!entity mfn "metafunction">
<!entity unspec "/*unspecified*/">
<!-- physical entities -->
<!entity abstract SYSTEM "abstract.sgml">
<!entity introduction SYSTEM "introduction.sgml">
<!entity usage SYSTEM "usage.sgml">
<!entity typeselection SYSTEM "typeselection.sgml">
<!entity metafunctions SYSTEM "metafunctions.sgml">
<!entity sequences SYSTEM "sequences.sgml">
<!entity lambda SYSTEM "lambda.sgml">
<!entity codegeneration SYSTEM "codegeneration.sgml">
<!entity example SYSTEM "example.sgml">
<!entity acknowl SYSTEM "acknowl.sgml">
<!entity references SYSTEM "references.sgml">
]>
<article>
<title>The Boost &Cxx; Metaprogramming Library</>
&abstract;
&introduction;
&usage;
&lambda;
&codegeneration;
&example;
&acknowl;
&references;
</article>
-96
View File
@@ -1,96 +0,0 @@
<!-- ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| section -->
<section id="codegeneration">
<title>Code generation facilities</>
<para>
There are cases, especially in the domain of numeric computation, when one wants to perform some part of the calculations at compile-time, and then pass the results to a run-time part of the program for further processing. For example, suppose one has implemented a complex compile-time algorithm that works with fixed-point arithmetic:
</>
<programlisting>
<![CDATA[
// fixed-point algorithm input
typedef mpl::vector<
mpl::fixed_c<-1,2345678>
, mpl::fixed_c<9,0001>
// ..
, mpl::fixed_c<3,14159>
> input_data;
/*
complex compile-time algorithm
*/
typedef /*...*/ result_data;
]]>
</>
<para>
Suppose the <literal>result_data</> here is a sequence of <literal>mpl::fixed_c</> types that keeps the results of the algorithm, and now one wishes to feed that result to the run-time part of the algorithm. With &MPL; she can do this:
</>
<programlisting>
<![CDATA[
double my_algorithm()
{
// passing the results to the run-time part of the program
std::vector<double> results;
results.reserve(mpl::size<result_data>::value);
mpl::for_each<numbers,_>(
boost::bind(&std::vector<double>::push_back, &results, _1)
);
// ...
}
]]>
</>
<para>
The <literal>for_each&lt;numbers,_&gt;(...)</> call is what actually transfers the compile-time <literal>result_data</> into run-time <literal>results</>. <literal>for_each</> is a function template declared as:
</>
<programlisting>
<![CDATA[
template<
typename Seq
, typename TransformOp
, typename F
>
void for_each(F f)
{
// ...
}
]]>
</>
<para>To call the function, one is required to explicitly provide two actual template parameters, a compile-time sequence <literal>Seq</> and a unary transformation metafunction <literal>TransformOp</>, plus a run-time function argument <literal>f</> (in our example, <literal>numbers</>, <literal>_</>, and <literal>boost::bind(...)</> correspondingly). <literal>f</> is a function object which <literal>operator()</> is called for every element in the <literal>Seq</> tranfromed by <literal>TransformOp</>.
</>
<para>
Applying this to our example, the
</>
<programlisting>
<![CDATA[
mpl::for_each<numbers,_>(
boost::bind(&std::vector<double>::push_back, &results, _1)
);
]]>
</>
<para>
call is roughly equivalent to this:
</>
<programlisting>
<![CDATA[
f(mpl::apply< _,mpl::at_c<result_data,0>::type >::type());
f(mpl::apply< _,mpl::at_c<result_data,1>::type >::type());
// ...
f(mpl::apply< _,mpl::at_c<result_data,n>::type >::type());
]]>
</>
<para>
where <literal>n == mpl::size&lt;result_data&gt;::type::value</>.
</>
</section>
-294
View File
@@ -1,294 +0,0 @@
<!-- ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| section -->
<section id="example">
<title>Example: a compile-time FSM generator</>
<para>
Finite state machines (<acronym>FSMs</>) are an important tool for describing and implementing program behavior <citation><xref linkend="ref.hu79"></>, <citation><xref linkend="ref.mar98"></>. They also are a good example of a domain in which &mping; can be applied to reduce the amount of repetitive and boilerplate operations one must perform in order to implement these simple mathematical models in code. Below we present a simple state machine generator that has been implemented using &BMPL; facilities. The generator takes a compile-time automata description, and converts it into &Cxx; code that implements the FSM at run-time.
</>
<para>
The FSM description is basically a combination of states and events plus a state transition table (<acronym>STT</>), which ties them all together. The generator walks through the table and generates the state machine's <literal>process_event</> method that is the essence of an FSM.
</>
<para>
Suppose we want to implement a simple music player using a finite state machine model. The state transition table
for the FSM is shown in <xref linkend="example.fsm.stt">. The STT format reflects the way one usually describes the behavior of an FSM in plain English. For example, the first line of the table can be read as follows: <quote>If the model is in the <literal>stopped</> state and the <literal>play_event</> is received, then the <literal>do_play</> transition function is called, and the model transitions to the <literal>playing</> state</>.
</>
<table id="example.fsm.stt" frame="none">
<title>Player's state transition table with actions</>
<tgroup cols="4" align="left">
<thead>
<row>
<entry>State</>
<entry>Event</>
<entry>Next state</>
<entry>Transition function</>
</>
</>
<tbody>
<row>
<entry><literal>stopped</></>
<entry><literal>play_event</></>
<entry><literal>playing</></>
<entry><literal>do_play</></>
</>
<row>
<entry><literal>playing</></>
<entry><literal>stop_event</></>
<entry><literal>stopped</></>
<entry><literal>do_stop</></>
</>
<row>
<entry><literal>playing</></>
<entry><literal>pause_event</></>
<entry><literal>paused</></>
<entry><literal>do_pause</></>
</>
<row>
<entry><literal>paused</></>
<entry><literal>play_event</></>
<entry><literal>playing</></>
<entry><literal>do_resume</></>
</>
<row>
<entry><literal>paused</></>
<entry><literal>stop_event</></>
<entry><literal>stopped</></>
<entry><literal>do_stop</></>
</>
</>
</tgroup>
</table>
<para>
The transition table provides us with a complete formal definition of the target FSM, and there are several ways to
transform that definition into code. For instance, if we define states as members of an enumeration type, and events as classes derived from some base <literal>event</> class
<footnote id="note.fsm"><para>The events need to be passed to action functions, as they may contain some event-specific information for an action.</></>
, like so:
</>
<programlisting>
<![CDATA[
class player
{
public:
// event declarations
struct event;
struct play_event;
struct stop_event;
struct pause_event;
// "input" function
void process_event(event const&); // throws
private:
// states
enum state_t { stopped, playing, paused };
// transition functions
void do_play(play_event const&);
void do_stop(stop_event const&);
void do_pause(pause_event const&);
void do_resume(play_event const&);
private:
state_t m_state;
};
]]>
</>
<para>
then the most straightforward way to derive the FSM implementation from the above table would be something
like this:
</>
<programlisting>
<![CDATA[
void player::process_event(event const& e)
{
if (m_state == stopped)
{
if (typeid(e) == typeid(play_event))
{
do_play(static_cast<play_event const&>(e));
m_state = playing;
return;
}
}
else if (m_state == playing)
{
if (typeid(e) == typeid(stop_event))
{
do_stop(static_cast<stop_event const&>(e));
m_state = stopped;
return;
}
if (typeid(e) == typeid(pause_event))
{
do_pause(static_cast<pause_event const&>(e));
m_state = paused;
return;
}
}
else if (m_state == paused)
{
if (typeid(e) == typeid(stop_event))
{
do_stop(static_cast<stop_event const&>(e));
m_state = stopped;
return;
}
if (typeid(e) == typeid(play_event))
{
do_play(static_cast<play_event const&>(e));
m_state = playing;
return;
}
}
else
{
throw logic_error(
boost::format("unknown state: %d")
% static_cast<int>(m_state)
);
}
throw std::logic_error(
"unexpected event: " + typeid(e).name()
);
}
]]>
</>
<para>
Although there is nothing particularly wrong with implementing an FSM's structure using nested <literal>if</> (or <literal>switch-case</>) statements, the obvious weakness of this approach is that most of the above code is boilerplate. What one tends to do with boilerplate code is to copy and paste it, then change names etc. to adjust it to its new location; and that's where the errors are most likely to creep in. Since all the lines of event processing look alike (structurally), it's very easy to overlook or forget something that needs to be changed, and many such errors won't appear until the runtime.
</>
<para>
The transition table of our FSM is just five lines long; ideally, we would like the skeleton implementation of the automata's controlling logic to be equally short (or, at least, to look equally short, i.e. to be encapsulated in some form so we never worry about it).
</>
<!-- ||||||||||||||||||||||||||||| subsection -->
<section id="example.impl">
<title>Implementation</>
<para>
To represent the STT in a &Cxx; program, we define a <literal>transition</> class template that represents a single line of the table. Then the table itself can be represented as a sequence of such lines:
</>
<programlisting>
<![CDATA[
typedef mpl::list<
transition<stopped, play_event, playing, &player::do_play>
, transition<playing, stop_event, stopped, &player::do_stop>
, transition<playing, pause_event, paused, &player::do_pause>
, transition<paused, play_event, playing, &player::do_resume>
, transition<paused, stop_event, stopped, &player::do_stop>
>::type transition_table;
]]></>
<para>
Now, the complete FSM will look like this:
</>
<programlisting>
<![CDATA[
class player
: state_machine<player>
{
private:
typedef player self_t;
// state invariants
void stopped_state_invariant();
void playing_state_invariant();
void paused_state_invariant();
// states (invariants are passed as non-type template arguments,
// and are called then the FSM enters the corresponding state)
typedef state<0, &self_t::stopped_state_invariant> stopped;
typedef state<1, &self_t::playing_state_invariant> playing;
typedef state<2, &self_t::paused_state_invariant> paused;
private:
// event declarations; events are represented as types,
// and can carry a specific data for each event;
// but it's not needed for generator, so we define them later
struct play_event;
struct stop_event;
struct pause_event;
// transition functions
void do_play(play_event const&);
void do_stop(stop_event const&);
void do_pause(pause_event const&);
void do_resume(play_event const&);
// STT
friend class state_machine<player>;
typedef mpl::list<
transition<stopped, play_event, playing, &player::do_play>
, transition<playing, stop_event, stopped, &player::do_stop>
, transition<playing, pause_event, paused, &player::do_pause>
, transition<paused, play_event, playing, &player::do_resume>
, transition<paused, stop_event, stopped, &player::do_stop>
>::type transition_table;
};
]]>
</>
<para>
That's all &mdash; the above will generate a complete FSM implementation according to our specification. The only thing we need before using it is the definition of the event types (that were just forward declared before):
</>
<programlisting>
<![CDATA[
// event definitions
struct player::play_event
: player::event
{
};
// ...
]]>
</>
<para>
The usage is simple as well:
</>
<programlisting>
<![CDATA[
int main()
{
// usage example
player p;
p.process_event(player::play_event());
p.process_event(player::pause_event());
p.process_event(player::play_event());
p.process_event(player::stop_event());
return 0;
}
]]>
</>
</section>
<!-- ||||||||||||||||||||||||||||| subsection -->
<section id="example.relatedwork">
<title>Related work</>
<para>
A notable prior work in the field of automation of general-purpose state machine implementation in &Cxx; is the Robert Martin's <emphasis>State Machine Compiler</> <citation><xref linkend="ref.smc"></>. The SMC takes an ASCII description of the machine's state transition table and produces &Cxx; code that implements the FSM using a variation of State design pattern <citation><xref linkend="ref.hun91"></>, <citation><xref linkend="ref.ghj95"></>. Lafreniere <citation><xref linkend="ref.laf00"></> presents another approach, where no external tools are used, and the FSMs are table driven.
</>
</section>
</section>
-375
View File
@@ -1,375 +0,0 @@
<section id="intro">
<title>Introduction</>
<para>
Metaprogramming is usually defined as the creation of programs which generate other programs. Parser generators such as YACC <citation><xref linkend="ref.Joh79"></> are examples of one kind of program-generating program. The input language to YACC is a context-free grammar in Extended Backus-Naur Form <citation><xref linkend="ref.EBNF"></>, and its output is a program which parses that grammar. Note that in this case the metaprogram (YACC) is written in a language (&C;) which does not directly support the description of generated programs. These specifications, which we'll call <emphasis>&mdat;</>, are not written in &C;, but in a <emphasis>meta-language</>. Because the the rest of the user's program typically requires a general-purpose programming system and must interact with the generated parser, the &mdat; is translated into &C;, which is then compiled and linked together with the rest of the system. The &mdat; thus undergoes two translation steps, and the user is always very conscious of the boundary between her &mdat; and the rest of her program.
</>
<!-- ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| section -->
<section id="intro.native">
<title>Native language metaprogramming</>
<para>
A more interesting form of &mping; is available in languages such as Scheme <citation><xref linkend="ref.SS75"></>, where the generated program specification is given in the same language as the metaprogram itself. The metaprogrammer defines her meta-language as a subset of the expressible forms of the underlying language, and program generation can take place in the same translation step used to process the rest of the user's program. This
allows users to switch transparently between ordinary programming, generated program specification, and &mping;, often without being aware of the transition.
</>
</section>
<!-- ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| section -->
<section id="intro.cxx">
<title>Metaprogramming in &Cxx;</>
<para>
In &Cxx;, it was discovered almost by accident <citation><xref linkend="ref.Unr"></>, <citation><xref linkend="ref.Vel95a"></> that the template mechanism provides a rich facility for computation at compile-time. In this section, we'll explore the basic mechanisms and some common idioms used for metaprogramming in &Cxx;.
</>
<!-- ||||||||||||||||||||||||||||| subsection -->
<section id="intro.cxx.numeric">
<title>Numeric computations</>
<para>
The availability of <emphasis>non-type template parameters</> makes it possible to perform integer computations at compile-time. For example, the following template computes the factorial of its argument:
</>
<programlisting>
<![CDATA[
template< unsigned n >
struct factorial
{
static const unsigned value = n * factorial<n-1>::value;
};
template<>
struct factorial<0>
{
static const unsigned value = 1;
};
]]>
</>
<para>
The program fragment above is called a <emphasis>&mfn;</>, and it is easy to see its relationship to a function designed to be evaluated at runtime: the <quote>&mfn; argument</> is passed as a template parameter, and its <quote>return value</> is defined as a nested static constant. Because of the hard line between the expression of compile-time and runtime computation in &Cxx;, metaprograms look different from their runtime counterparts. Thus, although as in Scheme the &Cxx; metaprogrammer writes her code in the same language as the ordinary program, only a subset
of the full &Cxx; language is available to her: those expressions which can be evaluated at compile-time. Compare the above with a straightforward runtime definition of the factorial function:
</>
<programlisting>
unsigned factorial(unsigned N)
{
return N == 0 ? 1 : N * factorial(N - 1);
}
</>
<para>
While it is easy to see the analogy between the two recursive definitions, recursion is in general more important to &Cxx; metaprograms than it is to runtime &Cxx;. In contrast to languages such as Lisp where recursion is idiomatic, &Cxx; programmers will typically avoid recursion when possible. This is done not only for efficiency reasons, but also because of <quote>cultural momentum</>: recursive programs are simply harder (for &Cxx; programmers) to think about. Like pure Lisp, though, the &Cxx; template mechanism is a <emphasis>functional</> programming language: as such it rules out the use of data mutation required to maintain loop variables.
</>
<para>
A key difference between the runtime and compile-time factorial functions is the expression of the termination condition: our meta-factorial uses template specialization as a kind of <emphasis>pattern-matching</> mechanism to describe the behavior when <literal>N</> is zero. The syntactic analogue in the runtime world would require two separate definitions of the same function. In this case the impact of the second definition is minimal, but in large
metaprograms the cost of maintaining and understanding the terminating definitions can become significant.
</>
<para>
Note also that a &Cxx; &mfn;'s return value must be <emphasis>named</>. The name chosen here, <literal>value</>, is the same one used for all numeric returns in the &MPL;. As we'll see, establishing a consistent naming
convention for &mfn; returns is crucial to the power of the library.
</>
</section>
<!-- ||||||||||||||||||||||||||||| subsection -->
<section id="intro.cxx.type">
<title>Type computations</>
<para>
How could we apply our <literal>factorial</> &mfn;? We might, for example, produce an array type of an appropriate size to hold all permutations of instances of another type:
</>
<programlisting>
<![CDATA[
// permutation_holder<T>::type is an array type which can contain
// all permutations of a given T.
// unspecialized template for scalars
template< typename T >
struct permutation_holder
{
typedef T type[1][1];
};
// specialization for array types
template< typename T, unsigned N >
struct permutation_holder<T[N]>
{
typedef T type[factorial<N>::value][N];
};
]]>
</>
<para>
Here we have introduced the notion of a <emphasis>type computation</>. Like <literal>factorial</> above, <literal>permutation_holder</> template is a &mfn;. However, where <literal>factorial</> manipulates unsigned integer values, <literal>permutation_holder</> accepts and <quote>returns</> a type (as the nested typedef <literal>type</>). Because the &Cxx; type system provides a much richer set of expressions than anything we can use as a nontype template argument (e.g. the integers), &Cxx; metaprograms tend to be composed mostly of type computations.
</>
</section>
<!-- ||||||||||||||||||||||||||||| subsection -->
<section id="intro.cxx.seq">
<title>Type sequences</>
<para>
The ability to programmatically manipulate collections of types is a central tool of most interesting &Cxx; metaprograms. Because this capability is so well-supported by the &MPL;, we'll provide just a brief
introduction to the basics here. Later on, we'll revisit the example below to show how it can be implemented using &MPL;.
</>
<para>
First, we'd need a way to represent the collection. One idea might be to store the types in a structure:
</>
<programlisting>
<![CDATA[
struct types
{
int t1;
long t2;
std::vector<double> t3;
};
]]>
</>
<para>
Unfortunately, this arrangement is not susceptible to the compile-time type introspection power that &Cxx; gives us: there's no way to find out what the names of the members are, and even if we assume that they're named according to some convention as above, there's no way to know how many members there are. The key to solving this problem is to
increase the uniformity of the representation. If we have a consistent way to get the first type of any sequence and the rest of the sequence, we can easily access all members:
</>
<programlisting>
<![CDATA[
template< typename First, typename Rest >
struct cons
{
typedef First first;
typedef Rest rest;
};
struct nil {};
typedef
cons<int
, cons<long
, cons<std::vector<double>
, nil
> > > my_types;
]]>
</>
<para>
The structure described by <literal>types</> above is the compile-time analogue of a singly-linked list; it has been first introduced by Czarnecki and Eisenecker in <citation><xref linkend="ref.ce98"></>. Now that we've adjusted the structure so that the &Cxx; template machinery can <quote>peel it apart</>, let's examine a simple metafunction which does so. Suppose a user wished to find the largest of an arbitrary collection of types. We can apply the recursive &mfn; formula which should by now be familiar:
</>
<example id="example.largest">
<title>'largest' metafunction</>
<programlisting>
<![CDATA[
// choose the larger of two types
template<
typename T1
, typename T2
, bool choose1 = (sizeof(T1) > sizeof(T2)) // hands off!
>
struct choose_larger
{
typedef T1 type;
};
// specialization for the case where sizeof(T2) >= sizeof(T1)
template< typename T1, typename T2 >
struct choose_larger< T1,T2,false >
{
typedef T2 type;
};
// get the largest of a cons-list
template< typename T > struct largest;
// specialization to peel apart the cons list
template< typename First, typename Rest >
struct largest< cons<First,Rest> >
: choose_larger< First, typename largest<Rest>::type >
{
// type inherited from base
};
// specialization for loop termination
template< typename First >
struct largest< cons<First,nil> >
{
typedef First type;
};
int main()
{
// print the name of the largest of my_types
std::cout
<< typeid(largest<my_types>::type).name()
<< std::endl
;
}
]]>
</>
</>
<para>
There are several things worth noticing about this code:
</>
<itemizedlist mark="box">
<listitem><para>
It uses a few ad-hoc, esoteric techniques, or <quote>hacks</>. The default template argument <literal>choose1</> (labeled <quote>hands off!</>) is one example. Without it, we would have needed yet another template to provide the implementation of <literal>choose_larger</>, or we would have had to provide the computation explicitly as a parameter to the template - perhaps not bad for this example, but it would make <literal>choose_larger</> much less useful and more error-prone. The other hack is the derivation of a specialization of <literal>largest</> from <literal>choose_larger</>. This is a code-saving device which allows the programmer to avoid writing <quote><literal>typedef
typename </>...<literal>::type type</></> in the template body.
</></>
<listitem><para>
Even this simple metaprogram uses three separate partial specializations. The <literal>largest</> &mfn; uses <emphasis>two</> specializations. One might expect that this indicates there are two termination conditions, but there are not: one specialization is needed simply to deal with access to the sequence elements. These specializations make the code difficult to read by spreading the definition of a single &mfn; over several &Cxx; template definitions. Also, because they are <emphasis>partial</> specializations, they make the code unusable for a large community of &Cxx; programmers whose compilers don't support that feature.
</></>
</itemizedlist>
<para>
While these techniques are, of course, a valuable part of the arsenal of any good &Cxx; metaprogrammer, their use tends to make programs written in what is already an unusual style harder-to-read and harder-to-write. By encapsulating commonly-used structures and dealing with loop terminations internally, the &MPL; reduces the need for both tricky hacks and for template specializations.
</>
</section>
</section>
<!-- ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| section -->
<section id="intro.whymetaprog">
<title>Why metaprogramming?</>
<!--
maybe we don't need another example of a metaprogram given what
we've done above? We could rewrite and cut most of this section...
-->
<para>
It's worth asking why anyone would want to do this. After all, even a simple toy example like the factorial &mfn; is somewhat esoteric. To show how the type computation can be put to work, let's examine a simple example. The following code produces an array containing all possible permutations of another array:
</>
<programlisting>
<![CDATA[
// can't return an array in C++, so we need this wrapper
template< typename T >
struct wrapper
{
T x;
};
// return an array of the N! permutations of 'in'
template< typename T >
wrapper< typename permutation_holder<T>::type >
all_permutations(T const& in)
{
wrapper<typename permutation_holder<T>::type> result;
// copy the unpermutated array to the first result element
unsigned const N = sizeof(T) / sizeof(**result.x);
std::copy(&*in, &*in + N, result.x[0]);
// enumerate the permutations
unsigned const result_size = sizeof(result.x) / sizeof(T);
for (T* dst = result.x + 1; dst != result.x + result_size; ++dst)
{
T* src = dst - 1;
std::copy(*src, *src + N, *dst);
std::next_permutation(*dst, *dst + N);
}
return result;
}
]]>
</>
<!-- ...up to this point -->
<para>
The runtime definition of <literal>factorial</> would be useless in <literal>all_permutations</> above, since in &Cxx; the sizes of array members must be computed at compile-time. However, there are alternative approaches; how could we avoid &mping;, and what would the consequences be?
</>
<orderedlist>
<listitem>
<para>
We could write programs to interpret the &mdat; directly. In our factorial example, the array size could have been a runtime quantity; then we'd have been able to use the straightforward factorial function. However, that would imply the use of dynamic allocation, which is often expensive.
</>
<para>
To carry this further, YACC might be rewritten to accept a pointer-to-function returning tokens from the stream to be parsed, and a string containing the grammar description. This approach, however, would impose unacceptable runtime costs for most applications: either the parser would have to treat the grammar nondeterministically, exploring the grammar for each parse, or it would have to begin by replicating at runtime the substantial table-generation and optimization work of the existing YACC for each input grammar.
</>
</>
<listitem>
<para>
We could replace the compile-time computation with our own analysis. After all, the size of arrays passed to
<literal>all_permutations</> are always known at compile-time, and thus can be known to its user. We could ask the user to supply the result type explicitly:
</>
<programlisting>
<![CDATA[
template< typename Result, typename T >
Result all_permutations(T const& input);
]]>
</>
<para>
The costs to this approach are obvious: we give up expressivity (by requiring the user to explicitly specify implementation details), and correctness (by allowing the user to specify them incorrectly). Anyone who has had to write parser tables by hand will tell you that the impracticality of this approach is the very reason of YACC's existence.
</>
<para>
In a language such as &Cxx;, where the &mdat; can be expressed in the same language as the rest of the user's program, expressivity is further enhanced: the user can invoke metaprograms directly, without learning a foreign syntax or interrupting the flow of her code.
</>
</>
</orderedlist>
<para>
So, the motivation for &mping; comes down to the combination of three factors: efficiency, expressivity, and correctness. While in classical programming there is always a tension between expressivity and correctness on one hand and efficiency on the other, in the &mping; world we wield new power: we can move the computation required for
expressivity from runtime to compile-time.
</>
</section>
<!-- ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| section -->
<section id="intro.whylibrary">
<title>Why a metaprogramming <emphasis>library</>?</>
<para>
One might just as well ask why we need any generic library:
</>
<itemizedlist mark="box">
<listitem>
<para>
Quality. Code that is appropriate for a general-purpose library is usually incidental to the purpose of its users. To a library developer, it is the central mission. On average, the containers and algorithms provided by any given &Cxx; standard library implementation are more-flexible and better-implemented than the project-specific implementations which abound, because library development was treated as an end in itself rather than a task incidental to the development of some other application. With a centralized implementation for any given function, optimizations and improvements are more likely to have been applied.
</>
</>
<listitem>
<para>
Re-use. More important even than the re-use of code which all libraries provide, a well-designed generic library establishes a <emphasis>framework of concepts and idioms</> which establishes a reusable mental model for approaching problems. Just as the &Cxx; Standard Template Library gave us iterator concepts and a function object protocol, the &BMPL; provides type-iterators and metafunction class protocol. A well-considered framework of idioms saves the metaprogrammer from considering irrelevant implementation details and allows her to concentrate on the problem at hand.
</>
</>
<listitem>
<para>
Portability. A good library can smooth over the ugly realities of platform differences. While in theory a &mping; library is fully generic and shouldn't be concerned with these issues, in practice support for templates remains inconsistent even four years after standardization. This should perhaps not be surprising: &Cxx; templates are the language's furthest-reaching and most complicated feature, which largely accounts for the power of &mping; in &Cxx;.
</>
</>
<listitem>
<para>
Fun. Repeating the same idioms over and over is <emphasis>tedious</>. It makes programmers tired and reduces productivity. Furthermore, when programmers get bored they get sloppy, and buggy code is even more costly than slowly-written code. Often the most useful libraries are simply patterns that have been <quote>plucked</> by an astute programmer from a sea of repetition. The &MPL; helps to reduce boredom by eliminating the need for the most commonly-repeated boilerplate coding patterns.
</>
</>
</itemizedlist>
<para>
As one can see, the &MPL;'s development is motivated primarily by the same practical, real-world considerations that justify the development of any other library. Perhaps this is an indication that template &mping; is finally ready to leave the realm of the esoteric and enter the lingua franca of every day programmers.
</>
<!-- probably this paragraph would be better in the conclusions -->
</section>
</section>
-142
View File
@@ -1,142 +0,0 @@
<!-- ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| section -->
<section id="lambda">
<title>Lambda facility</>
<para>
The &MPL;'s lambda facility allows the <firstterm>inline composition</> of class templates into <quote>lambda expressions</>, which are classes and can therefore be passed around as ordinary metafunction classes, or transformed into metafunction classes before application using the expression:
</>
<programlisting><![CDATA[
typedef mpl::lambda<expr>::type func;
]]></>
<para>
For example, <literal>boost::remove_const</> traits template from Boost <literal>type_traits</> library <citation><xref linkend="ref.TTL"></> is a class template (obviously), or a <link linkend="metafunctions">metafunction</> in &MPL; terminology. The simplest example of an <quote>inline composition</> of it would be something like:
</>
<programlisting><![CDATA[
typedef boost::remove_const<_1> expr;
]]></>
<para>
This forms a so called <quote>lambda expression</>, which is neither a metafunction class, nor a metafunction, yet can be passed around everywhere because it's an ordinary &Cxx; class, because all &MPL; facilities are polymorphic with respect to their arguments. Now, that lambda expression can be <emphasis>transformed</> into a metafunction class using the &MPL;'s <literal>lambda</> facility:
</>
<programlisting><![CDATA[
typedef boost::remove_const<_1> expr;
typedef mpl::lambda<expr>::type func;
]]></>
<para>
The <literal>func</> is a unary metafunction class and can be used as such. In particular, it can be pass around or invoked (applied):
</>
<programlisting><![CDATA[
typedef mpl::apply<func,int const>::type res;
BOOST_MPL_ASSERT_IS_SAME(res, int);
]]></>
<para>
or even
</>
<programlisting><![CDATA[
typedef func::apply<int const>::type res;
BOOST_MPL_ASSERT_IS_SAME(res, int);
]]></>
<para>
Inline composition is very appealing syntactically when one deals with metafunctions, because it makes the expression obvious:
</>
<programlisting><![CDATA[
typedef mpl::logical_or<
mpl::less< mpl::sizeof_<_1>, mpl::int_c<16> >
, boost::is_same<_1,_2>
> expr;
typedef mpl::lambda<expr>::type func;
]]></>
<para>
And one does not have to specify the last part (<literal>typedef lambda&lt;expr&gt;::type func</>), because all the algorithms do this to any of their metafunction class operands internally (a <literal>lambda&lt;T&gt;::type</> expression applied to a metafunction class gives back the same metafunction class, so it's safe to apply the expression unconditionally).
</>
<para>
The alternative way to write an equivalent of the above metafunction class would be:
</>
<programlisting><![CDATA[
typedef bind<
mpl::meta_fun2<mpl::logical_or>
, mpl::bind< mpl::meta_fun2<mpl::less>
, mpl::bind< mpl::meta_fun1<mpl::sizeof_>,_1 >
, mpl::int_c<16>
>
, mpl::bind< mpl::meta_fun2<boost::is_same>,_1,_2 >
> func;
]]></>
<para>
Or to use <literal>mpl::compose_</> family of templates in a similar way. Here, we use <literal>mpl::meta_fun</> templates to convert metafunctions into metafunction classes and then combine them using <literal>mpl::bind</>. The transformation from this form to the above inline lambda expression and vice-versa is mechanical, and that is essentially what the <literal>typedef mpl::lambda&lt;expr&gt;::type</> expression does.
</>
<para>
For its own metafunctions (algorithms, primitives, etc.), &MPL; enables one to write the above in a less cumbersome way:
</>
<programlisting><![CDATA[
typedef mpl::bind<
mpl::logical_or<>
, mpl::bind< mpl::less<>, mpl::bind<mpl::sizeof_<>,_1>, mpl::int_c<16> >
, mpl::bind< mpl::make_f2<boost::is_same>, _1,_2 >
> func;
]]></>
<para>
Note that we still have to wrap <literal>is_same</> into <literal>make_f2</>, because it's a foreign template.
</>
<para>
Now, about combining class template metafunctions and metafunction classes in the single lambda expression - it can be done like this:
</>
<programlisting><![CDATA[
struct my_predicate
{
template< typename T1, typename T2 > struct apply
{
//...
};
};
typedef mpl::logical_or<
mpl::less< mpl::sizeof_<_>,mpl::int_c<16> >
, mpl::bind< my_predicate,_,_ > // here
> expr;
]]></>
<para>
To bind something to one of its arguments (or change the order of parameters), then use either:
</>
<programlisting><![CDATA[
typedef mpl::logical_or<
mpl::less< mpl::sizeof_<_>,mpl::int_c<16> >
, mpl::bind<my_predicate,int,_>::type // here
> expr;
]]></>
<para>
or
</>
<programlisting><![CDATA[
typedef mpl::logical_or<
mpl::less< mpl::sizeof_<_>,mpl::int_c<16> >
, my_predicate::apply<int,_> // here
> expr;
]]></>
</section>
-282
View File
@@ -1,282 +0,0 @@
<!-- ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| section -->
<section id="metafunctions">
<title>Metafunctions</>
<!-- ||||||||||||||||||||||||||||| subsection -->
<section id="metafunctions.simple">
<title>The simple form</>
<para>
In C++, the basic underlying language construct which allows parameterized compile-time computation is the <firstterm>class template</> (<citation><xref linkend="ref.ISO98"></>, section 14.5.1 [temp.class]). A bare class template is the simplest possible model we could choose for metafunctions: it can take types and/or non-type arguments as actual template parameters, and instantiation <quote>returns</> a new type. For example, the following produces a type derived from its arguments:
</>
<programlisting>
<![CDATA[
template< typename T1, typename T2 >
struct derive : T1, T2
{
};
]]>
</>
<para>
However, this model is far too limiting: it restricts the metafunction result not only to class types, but to instantiations of a given class template, to say nothing of the fact that every metafunction invocation introduces an additional level of template nesting. While that might be acceptable for this particular metafunction, any model which prevented us from <quote>returning</>, say, <literal>int</> is obviously not general enough. To meet this basic requirement, we must rely on a nested type to provide our return value:
</>
<programlisting>
<![CDATA[
template< typename T1, typename T2 >
struct derive
{
struct type : T1, T2 {};
};
// silly specialization, but demonstrates "returning" int
template<>
struct derive<void,void>
{
typedef int type;
};
]]>
</>
<para>
Veldhuizen <citation><xref linkend="ref.Vel95a"></> was first to talk about class templates of this form as <quote>compile-time functions</>, and Czarnecki and Eisenecker <citation><xref linkend="ref.CE00"></> have introduced <quote>template metafunction</> as an equivalent term (they also use the simpler term <quote>metafunction</>, as do we). Czarnecki and Eisenecker have also recognized the limitations of the simple metafunction representation and suggested the form that we discuss in <xref linkend="metafunctions.classes">.
</>
</section>
<!-- ||||||||||||||||||||||||||||| subsection -->
<section id="metafunctions.higherorder">
<title>Higher-order metafunctions</>
<para>
While syntactically simple, the simple template metafunction form does not always interact optimally with the rest of &Cxx;. In particular, the simple metafunction form makes it unnecessarily awkward and tedious to define and work with higher-order metafunctions (metafunctions that operate on other metafunctions). In order to pass a simple metafunction to another template, we need to use <firstterm>template template parameters</>:
</>
<programlisting>
<![CDATA[
// returns F(T1,F(T2,T3))
template<
template<typename,typename> class F
, typename T1
, typename T2
, typename T3
>
struct apply_twice
{
typedef typename F<
T1
, typename F<T2,T3>::type
>::type type;
};
// a new metafunction returning a type derived from T1, T2, and T3
template<
typename T1
, typename T2
, typename T3
>
struct derive3
: apply_twice<derive,T1,T2,T3>
{
};
]]>
</>
<para>
This looks different, but it seems to work.
<footnote id="note.higherorder"><para>In fact it's already broken: <literal>apply_twice</> doesn't even fit the metafunction concept since it requires a template (rather than a type) as its first parameter, which breaks the metafunction protocol.</></>
However, things begin to break down noticeably when we want to <quote>return</> a metafunction from our metafunction:
</>
<programlisting>
<![CDATA[
// returns G s.t. G(T1,T2,T3) == F(T1,F(T2,T3))
template< template<typename,typename> class F >
struct compose_self
{
template<
typename T1
, typename T2
, typename T3
>
struct type
: apply_twice<F,T1,T2,T3>
{
};
};
]]>
</>
<para>
The first and most obvious problem is that the result of applying <literal>compose_self</> is not itself a type, but a template, so it can't be passed in the usual ways to other metafunctions. A more subtle issue, however, is that the metafunction <quote>returned</> is not exactly what we intended. Although it acts just like <literal>apply_twice</>, it differs in one important respect: its identity. In the C++ type system, <literal>compose_self&lt;F&gt;::template type&lt;T,U,V&gt;</> is not a synonym for <literal>apply_twice&lt;F,T,U,V&gt;</>, and any metaprogram which compared metafunctions would discover that fact.
</>
<para>
Because &Cxx; makes a strict distinction between type and class template template parameters, reliance on simple metafunctions creates a <quote>wall</> between metafunctions and metadata, relegating metafunctions to the status of second-class citizens. For example, recalling our introduction to type sequences, there's no way to make a <literal>cons</> list of metafunctions:
</>
<programlisting>
<![CDATA[
typedef cons<derive, cons<derive3, nil> > derive_functions; // error!
]]>
</>
<para>
We might consider redefining our <literal>cons</> cell so we can pass <literal>derive</> as the head element:
</>
<programlisting>
<![CDATA[
template <
template< template<typename T, typename U> class F
, typename Tail
>
struct cons;
]]>
</>
<para>
However, now we have another problem: &Cxx; templates are polymorphic with respect to their type arguments, but not with respect to template template parameters. The arity (number of parameters) of any template template parameter is strictly enforced, so we <emphasis>still</> can't embed <literal>derive3</> in a <literal>cons</> list. Moreover, polymorphism <emphasis>between</> types and metafunctions is not supported (the compiler expects one or the other), and as we've seen, the syntax and semantics of <quote>returned</> metafunctions is different from that of returned types. Trying to accomplish everything with the simple template metafunction form would seriously limit the applicability of higher-order metafunctions and would have an overall negative effect on the both conceptual and implementation clarity, simplicity and size of the library.
</>
</section>
<!-- ||||||||||||||||||||||||||||| subsection -->
<section id="metafunctions.classes">
<title>Metafunction classes</>
<para>
Fortunately, the truism that <quote>there is no problem in software which can't be solved by adding yet another level of indirection</> applies here. To elevate metafunctions to the status of first-class objects, the &MPL; introduces the concept of a <quote>metafunction class</>:
</>
<programlisting>
<![CDATA[
// metafunction class form of derive
struct derive
{
template< typename N1, typename N2 >
struct apply
{
struct type : N1, N2 {};
};
};
]]>
</>
<para>
This form should look familiar to anyone acquainted with function objects in STL, with the nested <literal>apply</> template taking the same role as the runtime function-call operator. In fact, compile-time metafunction classes have the same relationship to metafunctions that runtime function objects have to functions:
</>
<programlisting>
<![CDATA[
// function form of add
template< typename T > T add(T x, T y) { return x + y; }
// function object form of add
struct add
{
template< typename T >
T operator()(T x, T y) { return x + y; }
};
]]>
</>
</section>
<!-- ||||||||||||||||||||||||||||| subsection -->
<section id="metafunctions.onesize">
<title>One size fits all?</>
<para>
The metafunction class form solves all the problems with ordinary template metafunction mentioned earlier: since it is a regular class, it can be placed in compile-time metadata sequences and manipulated by other metafunctions using the same protocols as for any other metadata. We thereby avoid the code-duplication needed to provide versions of each library component to operate on ordinary metadata and on metafunctions with each distinct supported arity.
</>
<para>
On the other hand, it seems that accepting metafunction classes as <emphasis>the</> representation for compile-time function entities imposes code duplication danger as well: if the library's own primitives, algorithms, etc. are represented as class templates, that means that one either cannot reuse these algorithms in the context of higher-order functions, or she have to duplicate all algorithms in the second form, so, for instance, there would be two versions of <literal>find</>:
</>
<programlisting>
<![CDATA[
// user-friendly form
template<
typename Sequence
, typename T
>
struct find
{
typedef /* ... */ type;
};
// "metafunction class" form
struct find_func
{
template< typename Sequence, typename T >
struct apply
{
typedef /* ... */ type;
};
};
]]>
</>
<para>
Of course, the third option is to eliminate <quote>user-friendly form</> completely so one would always have to write:
</>
<programlisting>
<![CDATA[
typedef mpl::find::apply<list,long>::type iter;
// or, if one prefers,
// typedef mpl::apply< mpl::find,list,long >::type iter;
]]>
</>
<para>
instead of
</>
<programlisting>
<![CDATA[
typedef mpl::find<list,long>::type iter;
]]>
</>
<para>
That too would hurt usability, considering that the direct invocations of library's algorithms are far more often-used than passing algorithms as arguments to other algorithms/metafunctions.
</>
</section>
<!-- ||||||||||||||||||||||||||||| subsection -->
<section id="metafunctions.lambda">
<title>From metafunction to metafunction class</>
<para>
The &MPL;'s answer to this dilemma is <firstterm>lambda expressions</>. Lambda is the mechanism that enables the library to curry metafunctions and convert them into metafunction classes, so when one wants to pass the <literal>find</> algorithm as an argument to a higher-order metafunction, she just write:
</>
<programlisting>
<![CDATA[
using namespace mpl::placeholder;
typedef mpl::apply< my_f, mpl::find<_1,_2> >::type result;
]]>
</>
<para>
where <literal>_1</> and <literal>_2</> are placeholders for the first and second arguments to the resulting metafunction class. This preserves the intuitive syntax below for when the user wants to use <literal>find</> directly in her code:
</>
<programlisting>
<![CDATA[
typedef mpl::find<list,long>::type iter;
]]>
</>
<para>
Lambda facility is described in more details in <xref linkend="lambda">.
</>
</section>
</section>
-247
View File
@@ -1,247 +0,0 @@
<bibliography id="refs">
<title>References</>
<biblioentry id="ref.Abr01">
<abbrev>Abr01</>
<authorgroup>
<author><firstname>David</><surname>Abrahams</></>
<author><firstname>Carlos Pinto</><surname>Coelho</></>
</>
<title><ulink url="http://users.rcn.com/abrahams/instantiation_speed/index.html">Effects of Metaprogramming Style on Compilation Time</></>
<date>2001</>
</biblioentry>
<biblioentry id="ref.Ale01">
<abbrev>Ale01</>
<author><firstname>Andrei</><surname>Alexandrescu</></>
<title>Modern C++ Design: Generic Programming and Design Patterns Applied</>
<publishername>Addison-Wesley</>
<isbn>0-201-70431-5</>
<date>2001</>
</biblioentry>
<biblioentry id="ref.CE98">
<abbrev>CE98</>
<authorgroup>
<author><firstname>Krzysztof</><surname>Czarnecki</></>
<author><firstname>Ulrich</><surname>Eisenecker</></>
</>
<title>Metalisp</>
<bibliomisc><ulink url="http://home.t-online.de/home/Ulrich.Eisenecker/meta.htm"></></>
</biblioentry>
<biblioentry id="ref.CE00">
<abbrev>CE00</>
<authorgroup>
<author><firstname>Krzysztof</><surname>Czarnecki</></>
<author><firstname>Ulrich</><surname>Eisenecker</></>
</>
<title>Generative Programming: Methods, Tools, and Applications</>
<publishername>Addison-Wesley</>
<isbn>0-201-30977-7</>
<date>2000</>
</biblioentry>
<biblioentry id="ref.EBNF">
<abbrev>EBNF</>
<title>ISO/IEC 14977:1996(E), Information technology — Syntactic metalanguage — Extended BNF</>
<orgname>ISO/IEC</>
<date>1996</>
</biblioentry>
<biblioentry id="ref.GHJ95">
<abbrev>GHJ+95</>
<authorgroup>
<author><firstname>Erich</><surname>Gamma</></>
<author><firstname>Richard</><surname>Helm</></>
<author><firstname>Ralph</><surname>Johnson</></>
<author><firstname>John</><surname>Vlissides</></>
</>
<title>Design Patterns, Elements of Reusable Object-Oriented Software</>
<publishername>Addison-Wesley</>
<isbn>0-201-63361-2</>
<date>1995</>
</biblioentry>
<biblioentry id="ref.HU79">
<abbrev>HU79</>
<authorgroup>
<author><surname>Hopcroft</></>
<author><surname>Ullman</></>
</>
<title>Introduction to automata theory, languages and computations</>
<publishername>Addison-Wesley</>
<date>1979</>
</biblioentry>
<biblioentry id="ref.Hud89">
<abbrev>Hud89</>
<author><firstname>Paul</><surname>Hudak</></>
<title>Conception, Evolution, and Application of Functional Programming Languages</>
<biblioset relation='journal'>
<title>ACM Computing Surveys</>
<publishername>Association for Computing Machinery (ACM)</>
<issn>0360-0300</>
</>
<volumenum>21</>
<issuenum>3</>
<pagenums>359-411</>
<date>September, 1989</>
</biblioentry>
<biblioentry id="ref.Hun91">
<abbrev>Hun91</>
<author><firstname>Immo</><surname>Huneke</></>
<title>Finite State Machines: A Model of Behavior for C++</>
<biblioset relation='journal'>
<title>C++ Report</>
<publishername>SIGS Publications Inc.</>
<issn>1040-6042</>
</>
<date>1991</>
</biblioentry>
<biblioentry id="ref.ISO98">
<abbrev>ISO98</>
<title>ISO/IEC 14882:1998(E), Programming languages — C++</>
<orgname>ISO/IEC</>
<date>1998</>
</biblioentry>
<biblioentry id="ref.Joh79">
<abbrev>Joh79</>
<author><firstname>Stephen C.</><surname>Johnson</></>
<title><ulink url="http://dinosaur.compilertools.net/yacc/index.html">Yacc: Yet Another Compiler Compiler</></>
<publishername>UNIX Programmer's Manual</>
<volumenum>2b</>
<pagenums>353-387</>
<date>1979</>
</biblioentry>
<biblioentry id="ref.Laf00">
<abbrev>Laf00</>
<author><firstname>David</><surname>Lafreniere</></>
<title><ulink url="http://www.cuj.com/articles/2000/0005/0005f/0005f.htm?topic=articles">State Machine Design in C++</></>
<biblioset relation='journal'>
<title>C/C++ User Journal</>
<publishername>CMP Media LCC</>
<issn>1075-2838</>
</>
<volumenum>18</>
<issuenum>5</>
<date>May 1998</>
</biblioentry>
<biblioentry id="ref.Loki">
<abbrev>Loki</>
<title>The Loki library</>
<bibliomisc><ulink url="http://sourceforge.net/projects/loki-lib/"></></>
</biblioentry>
<biblioentry id="ref.Mar98">
<abbrev>Mar98</>
<author><firstname>Robert C.</><surname>Martin</></>
<title><ulink url="http://www.objectmentor.com/resources/articles/umlfsm.pdf">UML Tutorial: Finite State Machines</></>
<biblioset relation='journal'>
<title>C++ Report</>
<publishername>SIGS Publications Inc.</>
<issn>1040-6042</>
</>
<date>June 1998</>
</biblioentry>
<biblioentry id="ref.MPLR">
<abbrev>MPLR</>
<title>Boost MPL Library Reference Documentation</>
<bibliomisc><ulink url="http://www.mywikinet.com/mpl/ref/Table_of_Content.html"></></>
</biblioentry>
<biblioentry id="ref.PRE">
<abbrev>PRE</>
<author><firstname>Vesa</><surname>Karvonen</></>
<title>Boost Preprocessor Metaprogramming library</>
<bibliomisc><ulink url="http://www.boost.org/libs/preprocessor/doc/"></></>
</biblioentry>
<biblioentry id="ref.SMC">
<abbrev>SMC</>
<author><firstname>Robert C.</><surname>Martin</></>
<title>SMC - Finite State Machine Compiler (C++)</>
<bibliomisc><ulink url="http://www.objectmentor.com/resources/downloads/index"></></>
</biblioentry>
<biblioentry id="ref.STL94">
<abbrev>STL94</>
<authorgroup>
<author><surname>A. A. Stepanov</></>
<author><surname>M. Lee</></>
</authorgroup>
<title>The Standard Template Library</>
<orgname>Hewlett-Packard Laboratories</>
<date>1994</>
</biblioentry>
<biblioentry id="ref.SPL">
<abbrev>SPL</>
<title>Boost Smart Pointer library</>
<bibliomisc><ulink url="http://www.boost.org/libs/smart_ptr/"></></>
</biblioentry>
<biblioentry id="ref.SS75">
<abbrev>SS75</>
<authorgroup>
<author><firstname>Gerald J.</><surname>Sussman</></>
<author><firstname>Guy L.</><surname>Steele Jr.</></>
</>
<title>Scheme: An interpreter for extended lambda calculus</>
<biblioset relation='journal'>
<title>MIT AI Memo 349</>
<publishername>Massachusetts Institute of Technology</>
</>
<date>May 1975</>
</biblioentry>
<biblioentry id="ref.TTL">
<abbrev>TTL</>
<title>Boost Type Traits library</>
<bibliomisc><ulink url="http://www.boost.org/libs/type_traits/"></></>
</biblioentry>
<biblioentry id="ref.vel95a">
<abbrev>Vel95a</>
<author><firstname>Todd</><surname>Veldhuizen</></>
<title><ulink url="http://osl.iu.edu/~tveldhui/papers/Template-Metaprograms/meta-art.html">Using C++ template metaprograms</></>
<biblioset relation='journal'>
<title>C++ Report</>
<publishername>SIGS Publications Inc.</>
<issn>1040-6042</>
</>
<volumenum>7</>
<issuenum>4</>
<pagenums>36-43</>
<date>May 1995</>
</biblioentry>
<biblioentry id="ref.Vel95b">
<abbrev>Vel95b</>
<author><firstname>Todd</><surname>Veldhuizen</></>
<title><ulink url="http://osl.iu.edu/~tveldhui/papers/Expression-Templates/exprtmpl.html">Expression templates</></>
<biblioset relation='journal'>
<title>C++ Report</>
<publishername>SIGS Publications Inc.</>
<issn>1040-6042</>
</>
<volumenum>7</>
<issuenum>5</>
<pagenums>26-31</>
<date>Jun 1995</>
</biblioentry>
<biblioentry id="ref.Unr">
<abbrev>Unr</>
<author><firstname>Erwin</><surname>Unruh</></>
<title>Prime number computation</>
<publishername>ANSI X3J16-94-0075/ISO WG21-462</>
</biblioentry>
</bibliography>
-566
View File
@@ -1,566 +0,0 @@
<!-- ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| section -->
<section id="sequences">
<title>Sequences, algorithms, and iterators</>
<!-- ||||||||||||||||||||||||||||| subsection -->
<section id="sequences.intro">
<title>Introduction</>
<para>
Compile-time iteration over a sequence (of types) is one of the basic concepts of template metaprogramming. Differences in types of objects being manipulated is the most common point of variability of similar but not identical code/design, and such designs are the direct target for some metaprogramming. Templates were originally designed to solve this exact problem (e.g. <literal>std::vector</>). However, without predefined abstractions/constructs for manipulating/iterating over <emphasis>sequences</> of types (as opposed to standalone types), and without known techniques for emulating these constructs using the current language facilities, their effect on helping high-level metaprogramming happen has been limited.
</>
<para>
Czarnecki and Eisenecker <citation><xref linkend="ref.CE98"></>, <citation><xref linkend="ref.CE00"></> were the first to introduce compile-time sequences of types and some simple algorithms on them, although the idea of representing common data structures like trees, lists, etc. at compile time, using class template composition has been around for a while (e.g. most of the expression template libraries build such trees as a part of their expression "parsing" process <citation><xref linkend="ref.Vel95b"></>). Alexandrescu <citation><xref linkend="ref.Ale01"></> used lists of types and some algorithms on them to implement several design patterns; the accompanying code is known as the Loki library <citation><xref linkend="ref.Loki"></>.
</>
</section>
<!-- ||||||||||||||||||||||||||||| subsection -->
<section id="sequences.algo">
<title>Algorithms and sequences</>
<para>
Most of the algorithms in the &BMPL; operate on sequences. For example, searching for a type in a list looks like this:
</>
<programlisting>
<![CDATA[
typedef mpl::list<char,short,int,long,float,double> types;
typedef mpl::find<types,long>::type iter;
]]>
</>
<para>
Here, <literal>find</> accepts two parameters - a sequence to search (<literal>types</>) and the type to search for (<literal>long</>) - and returns an iterator <literal>iter</> pointing to the first element of the sequence such that <literal>iter::type</> is identical to <literal>long</>. If no such element exists, <literal>iter</> is identical to <literal>end&lt;types&gt;::type</>. Basically, this is how one would search for a value in a <literal>std::list</> or <literal>std::vector</>, except that <literal>mpl::find</> accepts the sequence as a single parameter, while <literal>std::find</> takes two iterators. Everything else is pretty much the same - the names are the same, the semantics are very close, there are iterators, and one can search not only by type, but also by using a predicate:
</>
<programlisting>
<![CDATA[
typedef mpl::find_if< types,boost::is_float<_> >::type iter;
]]></>
<para>
This conceptual/syntactical similarity with the STL is not coincidental. Reusing the conceptual framework of the STL in the compile-time world allows us to apply familiar and sound approaches for dealing with sequential data structures. The algorithms and idioms which programmers already know from the STL can be applied again at compile-time. We consider this to be one of &MPL;'s greatest strengths, distinguishing it from earlier attempts to build a template metaprogramming library.
</>
</section>
<!-- ||||||||||||||||||||||||||||| subsection -->
<section id="sequences.concepts">
<title>Sequence concepts</>
<para>
In the <literal>find</> example above, we searched for the type in a sequence built using the <literal>mpl::list</> template; but <literal>list</> is not the only sequence that the library provides. Neither is <literal>mpl::find</> or any other algorithm hard-coded to work only with <literal>list</> sequences. <literal>list</> is just one model of &MPL;'s <phrase role="concept">Forward Sequence</> concept, and <literal>find</> works with anything that satisfies this concept's requirements. The hierarchy of sequence concepts in &MPL; is quite simple - a <phrase role="concept">Sequence</> is any compile-time entity for which <literal>begin&lt;&gt;</> and <literal>end&lt;&gt;</> produce iterators to the range of its elements; a <phrase role="concept">Forward Sequence</> is a Sequence whose iterators satisfy <phrase role="concept">Forward Iterator</> requirements; a <phrase role="concept">Bidirectional Sequence</> is a Forward Sequence whose iterators satisfy <phrase role="concept">Bidirectional Iterator</> requirements; finally, a <phrase role="concept">Random Access Sequence</> is a Bidirectional Sequence whose iterators satisfy <phrase role="concept">Random Access Iterator</> requirements.
<footnote id="note.seqconcepts"><para>
A more precise definition of these concepts can be found in the library reference documentation <citation><xref linkend="ref.MPLR"></>.
</></>
</>
<para>
Decoupling algorithms from particular sequence implementations (through iterators) allows a metaprogrammer to create her own sequence types and to retain the rest of the library at her disposal. For example, one can define a <literal>tiny_list</> for dealing with sequences of three types as follows:
</>
<programlisting>
<![CDATA[
template< typename TinyList, long Pos >
struct tiny_list_item;
template< typename TinyList, long Pos >
struct tiny_list_iterator
{
typedef typename tiny_list_item<TinyList,Pos>::type type;
typedef tiny_list_iterator<TinyList, Pos-1> prior;
typedef tiny_list_iterator<TinyList, Pos+1> next;
};
template< typename T0, typename T1, typename T2 >
struct tiny_list
{
typedef tiny_list_iterator<tiny_list, 0> begin;
typedef tiny_list_iterator<tiny_list, 3> end;
typedef T0 type0;
typedef T1 type1;
typedef T2 type2;
};
template< typename TinyList >
struct tiny_list_item<TinyList,0>
{
typedef typename TinyList::type0 type;
};
template< typename TinyList >
struct tiny_list_item<TinyList,1>
{
typedef typename TinyList::type1 type;
};
template< typename TinyList >
struct tiny_list_item<TinyList,2>
{
typedef typename TinyList::type2 type;
};
]]>
</>
<para>
and then use it with any of the library algorithms as if it were <literal>mpl::list</>:
</>
<programlisting>
<![CDATA[
typedef tiny_list< char,short,int > types;
typedef mpl::transform<
types
, boost::add_pointer<_1>
>::type pointers;
]]>
</>
<para>
Note that <literal>tiny_list</> is a model of Bidirectional Sequence; it would be a Random Access Sequence if we added <literal>advance</> and <literal>distance</> members to <literal>tiny_list_iterator</>:
</>
<programlisting>
<![CDATA[
template< typename TinyList, long Pos >
struct tiny_list_iterator
{
static long const position = Pos;
typedef typename tiny_list_item<TinyList,Pos>::type type;
typedef tiny_list_iterator<TinyList, Pos-1> prior;
typedef tiny_list_iterator<TinyList, Pos+1> next;
template< typename N > struct advance
{
typedef tiny_list_iterator<
TinyList
, Pos + N::value
> type;
};
template< typename Other > struct distance
{
typedef mpl::integral_c<
long
, Other::position - position
> type;
};
};
]]>
</>
<para>
While the <literal>tiny_list</> itself might be not that interesting (after all, it can hold only three elements), if the technique above could be automated so we would be able to define not-so-tiny sequences (with five, ten, twenty, etc. elements), it would be very valuable.
<footnote id="note.tinylist"><para>
Random access is almost as important at compile-time as it is at run-time. For example, searching for an item in a sorted random-access sequence using <literal>lower_bound</> can be much faster than performing the same operation on a forward-access-only <literal>list</>.
</></>
</>
<para>
External code generation is an option, but there exists a solution within the language. However, it is not a template metaprogramming, but rather <emphasis>preprocessor metaprogramming</>. In fact, &MPL;'s <literal>vector</> - a fixed-size type sequence that provides random-access iterators - is implemented very much like the above <literal>tiny_list</> - using the Boost Preprocessor library <citation><xref linkend="ref.PRE"></>.
</>
</section>
<!-- ||||||||||||||||||||||||||||| subsection -->
<section id="sequences.revisited">
<title>Ad hoc example revisited</>
<para>
So, the library provides its users with almost complete compile-time equivalent of the STL framework. Does it help them to solve their metaprogramming tasks? Let's return to our earlier <link linkend="example.largest"><literal>largest</></> example to see if we can rewrite it in a better way with what &MPL; has to offer. Well, actually, there is not much to look at, because the &MPL; implementation is a one-liner (we'll spread it out here for readability)
<footnote id="note.maxelement"><para>Here is another, even more elegant implementation:</>
<programlisting>
<![CDATA[
template< typename Sequence >
struct largest
{
typedef typename mpl::max_element<
mpl::transform_view<
Sequence
, mpl::sizeof_<_>
>
>::type type;
};
]]></>
</>
:
</>
<programlisting>
<![CDATA[
template< typename Sequence >
struct largest
{
typedef typename mpl::max_element<
Sequence
mpl::less<
mpl::sizeof_<_1>
, mpl::sizeof_<_2>
>
>::type iter;
typedef typename iter::type type;
};
]]></>
<para>
There are no more termination conditions with tricky pattern matching, no more partial specializations; and even more importantly, it's <emphasis>obvious</> what the above code does - even although it's all templates - something that one could not say about the original version.
</>
</section>
<!-- ||||||||||||||||||||||||||||| subsection -->
<section id="sequences.iterfold">
<title>iter_fold as the main iteration algorithm</>
<para>
For the purpose of examining a little bit more of the library's internal structure, let's look at how <literal>max_element</> from the above example is implemented. One might expect that <emphasis>now</> we will again see all these awkward partial specializations, esoteric pattern matching, etc. Well, let's see:
</>
<programlisting>
<![CDATA[
template<
typename Sequence
, typename Predicate
>
struct max_element
{
typedef typename mpl::iter_fold<
Sequence
, typename mpl::begin<Sequence>::type
, if_< less< deref<_1>,deref<_2> >, _2, _1 >
>::type type;
};
]]>
</>
<para>
The first thing to notice here is that this algorithm is implemented in terms of another one: <literal>iter_fold</>. In fact, this is probably the most important point of the example, because nearly all other generic sequence algorithms in the library are implemented in terms of <literal>iter_fold</>. If a user should ever need to implement her own sequence algorithm, she'll almost certainly be able to do so using this primitive, which means she won't have to resort to implementing hand-crafted iteration, pattern matching of special cases for loop termination, or workarounds for lack of partial specialization. It also means that her algorithm will automatically benefit from any optimizations the library has implemented, (e.g. recursion unrolling), and that it will work with any sequence that is a model of ForwardSequence, because <literal>iter_fold</> does not require anything more of its sequence argument.
</>
<para>
<literal>iter_fold</> algorithm is basically a compile-time equivalent of the <literal>fold</> or <literal>reduce</> functions that comprise the basic and well-known primitives of many functional programming languages. An analogy more familiar to a &Cxx; programmer would be the <literal>std::accumulate</> algorithm from the &Cxx; standard library (<citation><xref linkend="ref.ISO98"></>, section 26.4.1 [lib.accumulate]). However, <literal>iter_fold</> is designed to take advantage of the natural characteristics of recursive traversal: it accepts <emphasis>two</> metafunction class arguments, the first of which is applied to the state "on the way in" and the second of which is applied "on the
way out".
</>
<para>
The interface to <literal>iter_fold</> is defined in &MPL; as follows:
</>
<programlisting>
<![RCDATA[
template<
typename Sequence
, typename InitialState
, typename ForwardOp
, typename BackwardOp = _1
>
struct iter_fold
{
typedef &unspec; type;
};
]]>
</>
<para>
The algorithm <quote>returns</> the result of two-way successive applications of binary <literal>ForwardOp</> and <literal>BackwardOp</> operations to iterators in range [<literal>begin&lt;Sequence&gt;::type</>, <literal>end&lt;Sequence&gt;::type</>) and previous result of an operation; the <literal>InitialState</> is logically placed before the sequence and included in the forward traversal. The result <literal>type</> is identical to <literal>InitialState</> if the sequence is empty.
</>
<para>
The library also provides <literal>iter_fold_backward</>, <literal>fold</>, and <literal>fold_backward</> algorithms which wrap <literal>iter_fold</> to accommodate its most common usage patterns.
</>
</section>
<!-- ||||||||||||||||||||||||||||| subsection -->
<section id="sequences.numbers">
<title>Sequences of numbers</>
<para>
What we've seen so far were sequences (and algorithms on sequences) of types. It is both possible and easy to manipulate compile-time <emphasis>values</> using the library as well. The only thing to remember is that in &Cxx;, class template non-type template parameters give us one more example of non-polymorphic behavior. In other words, if one declared a metafunction to take a non-type template parameter (e.g. <literal>long</>) it's not possible to pass anything besides compile-time integral constants to it:
</>
<programlisting>
<![CDATA[
template< long N1, long N2 >
struct equal_to
{
static bool const value = (N1 == N2);
};
equal_to<5,5>::value; // ok
equal_to<int,int>::value; // error!
]]>
</>
<para>
And of course this doesn't work the other way around either:
</>
<programlisting>
<![CDATA[
typedef mpl::list<1,2,3,4,5> numbers; // error!
]]>
</>
<para>
While this may be an obvious limitation, it imposes yet another dilemma on the library design: on the one hand, we don't want to restrict users to type manipulations only, and on the other hand, full support for integral manipulations would require at least duplication of most of the library facilities
<footnote id="note.nontype"><para>Ideally, if going this route, all the templates should be re-implemented for every integral type - <literal>char</>, <literal>int</>, <literal>short</>, <literal>long</>, etc.
</></>
- the same situation as we would have if we had chosen to represent metafunctions as ordinary class templates. The solution for this issue is the same as well: we represent integral values by wrapping them in types
<footnote id="note.valuewrapping"><para>
The same technique was suggested by Czarnecki and Eisenecker in <citation><xref linkend="ref.CE00"></>.
</></>
. For example, to create a list of numbers one can write:
</>
<programlisting>
<![CDATA[
typedef mpl::list<
mpl::int_c<1>
, mpl::int_c<2>
, mpl::int_c<3>
, mpl::int_c<4>
, mpl::int_c<5>
> numbers;
]]>
</>
<para>
Wrapping integral constants into types to make them first-class citizens is important well inside metaprograms,
where one often doesn't know (and doesn't care) if the metafunctions she is using operate on types, integral values, other metafunctions, or something else, like fixed-point or rational numbers (<literal>mpl::fixed_c</> and <literal>mpl::rational_c</>).
</>
<para>
But, from the user's perspective, the above example is much more verbose than the shorter, incorrect one. Thus, for the purpose of convenience, the library does provide users with a template that takes non-type template parameters, but offers a more compact notation:
</>
<programlisting>
<![CDATA[
typedef mpl::list_c<long,1,2,3,4,5> numbers;
]]></>
<para>
There is a similar <literal>vector</> counterpart as well:
</>
<programlisting>
<![CDATA[
typedef mpl::vector_c<long,1,2,3,4,5> numbers;
]]>
</>
</section>
<!-- ||||||||||||||||||||||||||||| subsection -->
<section id="sequences.variety">
<title>A variety of sequences</>
<para>
Previous efforts to provide generalized metaprogramming facilities for &Cxx; have always concentrated on <literal>cons</>-style type lists and a few core algorithms like <literal>size</> and <literal>at</>, which are tied to the specific sequence implementation. Such systems have an elegant simplicity reminiscent of the analogous functionality in pure functional Lisp. It is much more time-consuming to implement even a basic set of the sequence algorithms provided by equivalent run-time libraries (the STL in particular), but if we have learned anything from the STL, it is that tying those algorithms' implementations to a specific sequence implementation is a misguided effort!
</>
<para>
The truth is that there is no single <quote>best</> type sequence implementation for the same reasons that there will never be a single <quote>best</> runtime sequence implementation. Furthermore, there are <emphasis>already</> quite a number of type list implementations in use today; and just as the STL algorithms can operate on sequences which don't come from STL containers, so the MPL algorithms are designed to work with foreign type sequences.
</>
<para>
It may be an eye-opening fact for some that type lists are not the only useful compile-time sequence. Again, the need for a variety of compile-time containers arises for the same reasons that we have lists, vectors, deques, and sets in the &Cxx; standard library &mdash; different containers have different functional and performance characteristics which determine not only applicability and efficiency of particular algorithms, but also the expressiveness or verbosity of the code that uses them. While runtime performance is not an issue for &Cxx; metaprograms, compilation speed is often a significant bottleneck to advanced &Cxx; software development <citation><xref linkend="ref.Abr01"></>.
</>
<para>
The &MPL; provides five built-in sequences: <literal>list</>, <literal>list_c</> (really just a <literal>list</> of value wrappers), <literal>vector</>, a randomly-accessible sequence of fixed maximum size, <literal>vector_c</>, and <literal>range_c</>, a randomly-accessible sequence of consecutive integral values. More important, however, is its ability to adapt to arbitrary sequence types. The only core operations that a sequence is required to provide in order to be used with the library algorithms are <literal>begin&lt;&gt;</> and <literal>end&lt;&gt;</> metafunctions which "return" iterators into the sequence. As with the STL, it is the iterators which are used to implement most of the general-purpose sequence algorithms the library provides. Also, as with the STL, algorithm specialization is used to take advantage of implementation knowledge about particular sequences: many of the "basic" sequence operations such as <literal>back&lt;&gt;</>, <literal>front&lt;&gt;</>, <literal>size&lt;&gt;</>, and <literal>at&lt;&gt;</> are specialized on sequence type to provide a more efficient implementation than the fully generic version.
</>
</section>
<!-- ||||||||||||||||||||||||||||| subsection -->
<section id="sequences.unrolling">
<title>Loop/recursion unrolling</>
<para>
Almost coincidentally, loop unrolling can be as important to compile-time iterative algorithms as it is to runtime algorithms. To see why, one must first remember that all "loops" in &Cxx; metaprograms, are in fact, implemented with recursion, and that the template instantiation depth can be a valuable resource in a compiler implementation. In fact, Annex B of the &Cxx; standard (<citation><xref linkend="ref.ISO98"></>, annex B [limits]) <emphasis>recommends</> a minimum depth of 17 recursively nested template instantiations; but this is far too low for many serious metaprograms, some of which easily exceed the hard-coded instantiation limits of some otherwise excellent compilers. To see how this works in action, let's examine a straightforward implementation of the <literal>fold</> metafunction, which combines some algorithm state with each element of a sequence:
</>
<programlisting>
<![CDATA[
namespace aux {
// unspecialized version combines the initial state and first element
// and recurses to process the rest
template<
typename Start
, typename Finish
, typename State
, typename BinaryFunction
>
struct fold_impl
: fold_impl<
typename Start::next
, Finish
, typename apply<
BinaryFunction
, State
, typename Start::type
>::type
, BinaryFunction
>
{
};
// specialization for loop termination
template<
typename Finish
, typename State
, typename BinaryFunction
>
struct fold_impl<Finish,Finish,State,BinaryFunction>
{
typedef State type;
};
} // namespace aux
// public interface
template<
typename Sequence
, typename State
, typename ForwardOp
>
struct fold
: aux::fold_impl<
, typename begin<Sequence>::type
, typename end<Sequence>::type
, State
, typename lambda<ForwardOp>::type
>
{
};
]]>
</>
<para>
Although simple and elegant, this implementation will always incur at least as many levels of recursive template instantiation as there are elements in the input sequence.
<footnote id="note.unrolling1"><para>It could be much more, depending on the complexity of the <literal>apply&lt;...&gt;</> expression, whose depth is added to the overall recursion depth.
</></>
The library addresses this problem by explicitly "unrolling" the recursion. To apply the technique to our <literal>fold</> example, we begin by factoring out a single step of the algorithm. Our <literal>fold_impl_step</> metafunction has two results: <literal>type</> (the next state), and <literal>iterator</> (the next sequence position).
</>
<programlisting>
<![CDATA[
template<
typename BinaryFunction
, typename State
, typename Start
, typename Finish
>
struct fold_impl_step
{
typedef typename apply<
BinaryFunction
, State
, typename Start::type
>::type type;
typedef typename Start::next iterator;
};
]]>
</>
<para>
As with our main algorithm implementation, we specialize for the loop termination condition so that the step becomes a no-op:
</>
<programlisting>
<![CDATA[
template<
typename BinaryFunction
, typename State
, typename Finish
>
struct fold_impl_step<BinaryFunction,State,Finish,Finish>
{
typedef State type;
typedef Finish iterator;
};
]]>
</>
<para>
Now we can now reduce <literal>fold</>'s instantiation depth by any constant factor N simply by inserting N invocations of <literal>fold_impl_step</>. Here we've chosen a factor of 4:
</>
<programlisting>
<![CDATA[
template<
typename Start
, typename Finish
, typename State
, typename BinaryFunction
>
struct fold_impl
{
private:
typedef fold_impl_step<
BinaryFunction
, State
, Start
, Finish
> next1;
typedef fold_impl_step<
BinaryFunction
, typename next1::type
, typename next1::iterator
, Finish
> next2;
typedef fold_impl_step<
BinaryFunction
, typename next2::type
, typename next2::iterator
, Finish
> next3;
typedef fold_impl_step<
BinaryFunction
, typename next3::type
, typename next3::iterator
, Finish
> next4;
typedef fold_impl_step<
typename next4::iterator
, Finish
, typename next4::type
, BinaryFunction
> recursion;
public:
typedef typename recursion::type type;
};
]]>
</>
<para>
The &MPL; applies this unrolling technique across all algorithms with an unrolling factor tuned according to the demands of the &Cxx; implementation in use, and with an option for the user to override the value.
<footnote id="note.unrolling2"><para>
This implementation detail is made relatively painless through heavy reliance on the Boost Preprocessor Library, so only one copy of the code needs to be maintained.
</></>
This fact enables users to push beyond the metaprogramming limits they would usually encounter with more naive algorithm implementations. Experiments also show a small (up to 10%) increase in metaprogram instantiation speed on some compilers when loop unrolling is used.
</>
</section>
</section>
-242
View File
@@ -1,242 +0,0 @@
<!-- ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| section -->
<section id="typeselection">
<title>Conditional type selection</>
<para>
Conditional type selection is the simplest basic construct of &Cxx; template metaprogramming. Veldhuizen <citation><xref linkend="ref.Vel95a"></> was the first to show how to implement it, and Czarnecki and Eisenecker <citation><xref linkend="ref.CE00"></> first presented it as a standalone library primitive. The &MPL; defines the corresponding facility as follows:
</>
<programlisting>
<![RCDATA[
template<
typename Condition
, typename T1
, typename T2
>
struct if_
{
typedef &unspec; type;
};
]]>
</>
<para>
Note that the first template parameter of the template is a type.
</>
<programlisting>
<![CDATA[
// usage/semantics
typedef mpl::if_<mpl::true_c,char,long>::type t1;
typedef mpl::if_<mpl::false_c,char,long>::type t2;
BOOST_MPL_ASSERT_IS_SAME(t1, char);
BOOST_MPL_ASSERT_IS_SAME(t2, long);
]]>
</>
<para>
The construct is important because template metaprograms often contain a lot of decision-making code, and, as we will show, spelling it manually every time via (partial) class template specialization quickly becomes impractical. The template is also important from the point of encapsulating the compiler workarounds.
</>
<!-- ||||||||||||||||||||||||||||| subsection -->
<section id="delayedeval">
<title>Delayed evaluation</>
<para>
The way the &Cxx; template instantiation mechanism works imposes some subtle limitations on applicability of the type selection primitive (<literal>if_</>), compared to a manually implemented equivalent of the selection code. For example, suppose we are implementing a <literal>pointed_type</> traits template such that <literal>pointed_type&lt;T&gt;::type</> instantiated for a <literal>T</> that is either a plain pointer (<literal>U*</>), <literal>std::auto_ptr&lt;U&gt;</>, or any of the Boost smart pointers <citation><xref linkend="ref.SPL"></>, e.g. <literal>boost::scoped_ptr&lt;U&gt;</>, will give us the pointed type (<literal>U</>):
</>
<programlisting>
<![CDATA[
BOOST_MPL_ASSERT_IS_SAME(pointed_type<my*>::type, my);
BOOST_MPL_ASSERT_IS_SAME(pointed_type< std::auto_ptr<my> >::type, my);
BOOST_MPL_ASSERT_IS_SAME(pointed_type< boost::scoped_ptr<my> >::type, my);
]]>
</>
<para>
Unfortunately, the straightforward application of <literal>if_</> to this problem does not work:
<footnote id="note.pointedtype"><para>
Although it would be easy to implement <literal>pointed_type</> using partial specialization to distinguish the case where <literal>T</> is a pointer, <literal>if_</> is likely to be the right tool for dealing with more complex conditionals. For the purposes of exposition, please suspend disbelief!
</></>
</>
<programlisting>
<![CDATA[
template< typename T >
struct pointed_type
: mpl::if_<
boost::is_pointer<T>
, typename boost::remove_pointer<T>::type
, typename T::element_type // #1
>
{
};
// the following code causes compilation error in line #1:
// name followed by "::" must be a class or namespace name
typedef pointed_type<char*>::type result;
]]>
</>
<para>
Clearly, the expression <literal>typename T::element_type</> is not valid in the case of <literal>T == char*</>, and that's what the compiler is complaining about. Implementing the selection code manually solves the problem:
</>
<programlisting>
<![CDATA[
namespace aux {
// general case
template< typename T, bool is_pointer = false >
struct select_pointed_type
{
typedef typename T::element_type type;
};
// specialization for plain pointers
template< typename T >
struct select_pointed_type<T,true>
{
typedef typename boost::remove_pointer<T>::type type;
};
}
template< typename T >
struct pointed_type
: aux::select_pointed_type<
T, boost::is_pointer<T>::value
>
{
};
]]>
</>
<para>
But this quickly becomes awkward if needs to be done repeatedly, and this awkwardness is compounded when partial specialization is not available. We can try to work around the problem as follows:
</>
<programlisting>
<![CDATA[
namespace aux {
template< typename T >
struct element_type
{
typedef typename T::element_type type;
};
}
template< typename T >
struct pointed_type
{
typedef typename mpl::if_<
boost::is_pointer<T>
, typename boost::remove_pointer<T>::type
, typename aux::element_type<T>::type
>::type type;
};
]]>
</>
<para>
but this doesn't work either - the access to the <literal>aux::element_type&lt;T&gt;</>'s nested <literal>type</> member still forces the compiler to instantiate <literal>element_type&lt;T&gt;</> with <literal>T == char*</>, and that instantiation is, of course, invalid. Also, although in our case this does not lead to a compile error, the <literal>boost::remove_pointer&lt;T&gt;</> template always gets instantiated as well, and for the same reason (because we are accessing its nested <literal>type</> member). Unnecessary instantiation that is not fatal may or may be not a problem, depending on the <quote>weight</> of the template (how much the instantiation taxes the compiler), but a general rule of thumb would be to avoid such code.
</>
<para>
Returning to our error, to make the above code compile, we need to factor the act of <quote>asking</> <literal>aux::element_type&lt;T&gt;</> for its nested <literal>type</> out of the <literal>if_</> invocation. The fact that both the <literal>boost::remove_pointer&lt;T&gt;</> trait template and <literal>aux::element_type&lt;T&gt;</> use the same naming convention for their result types makes the refactoring easier:
</>
<programlisting>
<![CDATA[
template< typename T >
struct pointed_type
{
private:
typedef typename mpl::if_<
boost::is_pointer<T>
, boost::remove_pointer<T>
, aux::element_type<T>
>::type func_;
public:
typedef typename func_::type type;
};
]]>
</>
<para>
Now the compiler is guaranteed not to instantiate both <literal>boost::remove_pointer&lt;T&gt;</> and <literal>aux::element_type&lt;T&gt;</>, even although they are used as actual parameters to the <literal>if_</> template, so we are allowed to get away with <literal>aux::element_type&lt;char*&gt;</> so long as it won't end up being selected as <literal>func_</>.
</>
<para>
The above technique is so common in template metaprograms, that it even makes sense to facilitate the selection of a nested <literal>type</> member by introducing a high-level equivalent to <literal>if_</> - the one that will do the <literal>func_::type</> operation (that is called [nullary] metafunction class application) as a part of its invocation. The &MPL; provides such template - it's called <literal>apply_if</>. Using it, we can re-write the above code as simple as:
</>
<programlisting>
<![CDATA[
template< typename T >
struct pointed_type
{
typedef typename mpl::apply_if<
boost::is_pointer<T>
, boost::remove_pointer<T>
, aux::element_type<T>
>::type type;
};
]]>
</>
<para>
To make our techniques review complete, let's consider a slightly different example - suppose we want to define a high-level wrapper around <literal>boost::remove_pointer</> traits template <citation><xref linkend="ref.TTL"></>, which will strip the pointer qualification conditionally. We will call it <literal>remove_pointer_if</>:
</>
<programlisting>
<![CDATA[
template<
typename Condition
, typename T
>
struct remove_pointer_if
{
typedef typename mpl::if_<
Condition
, typename boost::remove_pointer<T>::type
, T
>::type type;
};
]]>
</>
<para>
Now the above works the first time, but it suffers from the problem we mentioned earlier - <literal>boost::remove_pointer&lt;T&gt;</> gets instantiated even if its result is never used. In the metaprogramming world compilation time is an important resource <citation><xref linkend="ref.Abr01"></>, and it is wasted by unnecessary template instantiations. We've just seen how to deal with the problem when both arguments to <literal>if_</> are the results of nullary metafunction class applications, but in this example one of the arguments (<literal>T</>) is just a simple type, so the refactoring just doesn't seem possible.
</>
<para>
The easiest way out of this situation would be to pass to <literal>if_</> a real nullary metafunction instead of <literal>T</> - the one that returns <literal>T</> on its invocation. The &MPL; provides a simple way to do it - we just substitute <literal>identity&lt;T&gt;</> and <literal>apply_if</> for <literal>T</> and <literal>if_</>:
</>
<programlisting>
<![CDATA[
template<
typename Condition
, typename T
>
struct remove_pointer_if
{
typedef typename mpl::apply_if<
Condition
, boost::remove_pointer<T>
, mpl::identity<T>
>::type type;
};
]]>
</>
<para>
which gives us exactly what we wanted.
</>
</section>
</section>
-8
View File
@@ -1,8 +0,0 @@
<section id="usage">
<title>Basic usage</>
&typeselection;
&metafunctions;
&sequences;
</section>
-18
View File
@@ -1,18 +0,0 @@
To re-generate the docs in the exact format as they appear here, you would
need a slightly tweaked DocBook XSLT stylesheets disrtibution available at
http://www.mywikinet.com/mpl/docbook-xsl-1.50.0.zip
If you are to use the build scripts as-is, you also need these tools:
sx - an SGML to XML convertor, a part of James Clark's SP package,
available at http://www.jclark.com/sp/
msxsl - Microsoft XSLT processor, available at
http://msdn.microsoft.com/library/en-us/dnxml/html/msxsl.asp
tidy - http://tidy.sourceforge.net/
Python - to be able to run 'tidy_attr.py',
available at http://www.python.org or
http://www.activestate.com/Products/ActivePython/
-10
View File
@@ -1,10 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="refresh" content="0; URL=../index.html">
</head>
<body>
Automatic redirection failed, please go to
<a href="../index.html">../index.html</a>.
</body>
</html>
-10
View File
@@ -1,10 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="refresh" content="0; URL=../index.html">
</head>
<body>
Automatic redirection failed, please go to
<a href="../index.html">../index.html</a>.
</body>
</html>
-10
View File
@@ -1,10 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="refresh" content="0; URL=../index.html">
</head>
<body>
Automatic redirection failed, please go to
<a href="../index.html">../index.html</a>.
</body>
</html>
-10
View File
@@ -1,10 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="refresh" content="0; URL=../index.html">
</head>
<body>
Automatic redirection failed, please go to
<a href="../index.html">../index.html</a>.
</body>
</html>
-10
View File
@@ -1,10 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="refresh" content="0; URL=../index.html">
</head>
<body>
Automatic redirection failed, please go to
<a href="../index.html">../index.html</a>.
</body>
</html>
+49
View File
@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.3.6: http://docutils.sourceforge.net/" />
<title>The MPL Reference Manual</title>
<meta name="copyright" content="Copyright © Aleksey Gurtovoy and David Abrahams, 2001-2005." />
<link rel="stylesheet" href="style.css" type="text/css" />
</head>
<body class="docframe refmanual">
<h1 class="title">The MPL Reference Manual</h1>
<table class="docinfo" frame="void" rules="none">
<col class="docinfo-name" />
<col class="docinfo-content" />
<tbody valign="top">
<tr><th class="docinfo-name">Copyright:</th>
<td>Copyright © Aleksey Gurtovoy and David Abrahams, 2001-2005.</td></tr>
<tr class="field"><th class="docinfo-name">License:</th><td class="field-body">Distributed under the Boost Software License, Version 1.0. (See
accompanying file <tt class="literal"><span class="pre">LICENSE_1_0.txt</span></tt> or copy at
<a class="reference" href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)</td>
</tr>
</tbody>
</table>
<div class="document" id="the-mpl-reference-manual">
<!-- no .. section-numbering:: -->
<ul class="toc simple" id="outline">
<li><a class="reference" href="./refmanual/sequences.html" id="id322" name="id322">Sequences</a></li>
<li><a class="reference" href="./refmanual/iterators.html" id="id376" name="id376">Iterators</a></li>
<li><a class="reference" href="./refmanual/algorithms.html" id="id388" name="id388">Algorithms</a></li>
<li><a class="reference" href="./refmanual/metafunctions.html" id="id436" name="id436">Metafunctions</a></li>
<li><a class="reference" href="./refmanual/data-types.html" id="id496" name="id496">Data Types</a></li>
<li><a class="reference" href="./refmanual/macros.html" id="id509" name="id509">Macros</a></li>
<li><a class="reference" href="./refmanual/terminology.html" id="id529" name="id529">Terminology</a></li>
<li><a class="reference" href="./refmanual/categorized-index.html" id="id530" name="id530">Categorized Index</a></li>
<li><a class="reference" href="./refmanual/acknowledgements.html" id="id533" name="id533">Acknowledgements</a></li>
<li><a class="reference" href="./refmanual/refmanual_toc.html">Full TOC</a></li>
</ul>
<!-- workaround weird substitution bug (used to work!): -->
<!-- workaround weird substitution bug (works with t's!): -->
<!-- "[*Note:*" instead of "|Note:|" to workaround another subst. bug -->
</div>
<hr class="footer" />
<div class="footer">
Generated on: 2004-11-15 12:15 UTC.
Generated by <a class="reference" href="http://docutils.sourceforge.net/" target="_top">Docutils</a> from <a class="reference" href="http://docutils.sourceforge.net/rst.html" target="_top">reStructuredText</a> source.
</div>
</body>
</html>
+123
View File
@@ -0,0 +1,123 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.3.6: http://docutils.sourceforge.net/" />
<title>The MPL Reference Manual: accumulate</title>
<link rel="stylesheet" href="../style.css" type="text/css" />
</head>
<body class="docframe refmanual">
<table class="header"><tr class="header"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./reverse-iter-fold.html" class="navigation-link">Prev</a>&nbsp;<a href="./querying-algorithms.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./reverse-iter-fold.html" class="navigation-link">Back</a>&nbsp;Along</span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./iteration-algorithms.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>
<td class="header-group page-location"><a href="../refmanual.html" class="navigation-link">Front Page</a> / <a href="./algorithms.html" class="navigation-link">Algorithms</a> / <a href="./iteration-algorithms.html" class="navigation-link">Iteration Algorithms</a> / <a href="./accumulate.html" class="navigation-link">accumulate</a></td>
</tr></table><div class="header-separator"></div>
<div class="section" id="accumulate">
<h1><a class="toc-backref" href="./iteration-algorithms.html#id401" name="accumulate">accumulate</a></h1>
<div class="section" id="accumulate-synopsis">
<h3><a class="subsection-title" href="#synopsis" name="synopsis">Synopsis</a></h3>
<pre class="literal-block">
template&lt;
typename Sequence
, typename State
, typename ForwardOp
&gt;
struct <a href="./accumulate.html" class="identifier">accumulate</a>
{
typedef <em>unspecified</em> type;
};
</pre>
</div>
<div class="section" id="accumulate-description">
<h3><a class="subsection-title" href="#description" name="description">Description</a></h3>
<p>Returns the result of the successive application of binary <tt class="literal"><span class="pre">ForwardOp</span></tt> to the
result of the previous <tt class="literal"><span class="pre">ForwardOp</span></tt> invocation (<tt class="literal"><span class="pre">State</span></tt> if it's the first call)
and every element of the sequence in the range [<tt class="literal"><span class="pre"><a href="./begin.html" class="identifier">begin</a>&lt;Sequence&gt;::type</span></tt>, <tt class="literal"><span class="pre"><a href="./end.html" class="identifier">end</a>&lt;Sequence&gt;::type</span></tt>) in order.
[<em>Note:</em> <tt class="literal"><span class="pre"><a href="./accumulate.html" class="identifier">accumulate</a></span></tt> is a synonym for <a class="refentry reference" href="./fold.html"><tt class="refentry literal"><span class="pre">fold</span></tt></a> — <em>end note</em>]</p>
</div>
<div class="section" id="accumulate-header">
<h3><a class="subsection-title" href="#header" name="header">Header</a></h3>
<pre class="literal-block">
#include &lt;<a href="../../../../boost/mpl/accumulate.hpp" class="header">boost/mpl/accumulate.hpp</a>&gt;
</pre>
</div>
<div class="section" id="accumulate-parameters">
<h3><a class="subsection-title" href="#parameters" name="parameters">Parameters</a></h3>
<table border="1" class="table">
<colgroup>
<col width="15%" />
<col width="32%" />
<col width="53%" />
</colgroup>
<thead valign="bottom">
<tr><th>Parameter</th>
<th>Requirement</th>
<th>Description</th>
</tr>
</thead>
<tbody valign="top">
<tr><td><tt class="literal"><span class="pre">Sequence</span></tt></td>
<td><a class="reference" href="./forward-sequence.html">Forward Sequence</a></td>
<td>A sequence to iterate.</td>
</tr>
<tr><td><tt class="literal"><span class="pre">State</span></tt></td>
<td>Any type</td>
<td>The initial state for the first <tt class="literal"><span class="pre">ForwardOp</span></tt>
application.</td>
</tr>
<tr><td><tt class="literal"><span class="pre">ForwardOp</span></tt></td>
<td>Binary <a class="reference" href="./lambda-expression.html">Lambda Expression</a></td>
<td>The operation to be executed on forward
traversal.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="accumulate-expression-semantics">
<h3><a class="subsection-title" href="#expression-semantics" name="expression-semantics">Expression semantics</a></h3>
<p>For any <a class="reference" href="./forward-sequence.html">Forward Sequence</a> <tt class="literal"><span class="pre">s</span></tt>, binary <a class="reference" href="./lambda-expression.html">Lambda Expression</a> <tt class="literal"><span class="pre">op</span></tt>, and arbitrary type <tt class="literal"><span class="pre">state</span></tt>:</p>
<pre class="literal-block">
typedef <a href="./accumulate.html" class="identifier">accumulate</a>&lt;s,state,op&gt;::type t;
</pre>
<table class="field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Return type:</th><td class="field-body">A type.</td>
</tr>
<tr class="field"><th class="field-name">Semantics:</th><td class="field-body"><p class="first">Equivalent to</p>
<pre class="last literal-block">
typedef <a href="./fold.html" class="identifier">fold</a>&lt;s,state,op&gt;::type t;
</pre>
</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="accumulate-complexity">
<h3><a class="subsection-title" href="#complexity" name="complexity">Complexity</a></h3>
<p>Linear. Exactly <tt class="literal"><span class="pre"><a href="./size.html" class="identifier">size</a>&lt;s&gt;::value</span></tt> applications of <tt class="literal"><span class="pre">op</span></tt>.</p>
</div>
<div class="section" id="accumulate-example">
<h3><a class="subsection-title" href="#example" name="example">Example</a></h3>
<pre class="literal-block">
typedef <a href="./vector.html" class="identifier">vector</a>&lt;long,float,short,double,float,long,long double&gt; types;
typedef <a href="./accumulate.html" class="identifier">accumulate</a>&lt;
types
, <a href="./int.html" class="identifier">int_</a>&lt;0&gt;
, <a href="./if.html" class="identifier">if_</a>&lt; is_float&lt;_2&gt;,<a href="./next.html" class="identifier">next</a>&lt;_1&gt;,_1 &gt;
&gt;::type number_of_floats;
<a href="./assert-relation.html" class="identifier">BOOST_MPL_ASSERT_RELATION</a>( number_of_floats::value, ==, 4 );
</pre>
</div>
<div class="section" id="accumulate-see-also">
<h3><a class="subsection-title" href="#see-also" name="see-also">See also</a></h3>
<p><a class="reference" href="./algorithms.html">Algorithms</a>, <a class="refentry reference" href="./fold.html"><tt class="refentry literal"><span class="pre">fold</span></tt></a>, <a class="refentry reference" href="./reverse-fold.html"><tt class="refentry literal"><span class="pre">reverse_fold</span></tt></a>, <a class="refentry reference" href="./iter-fold.html"><tt class="refentry literal"><span class="pre">iter_fold</span></tt></a>, <a class="refentry reference" href="./reverse-iter-fold.html"><tt class="refentry literal"><span class="pre">reverse_iter_fold</span></tt></a>, <a class="refentry reference" href="./copy.html"><tt class="refentry literal"><span class="pre">copy</span></tt></a>, <a class="refentry reference" href="./copy-if.html"><tt class="refentry literal"><span class="pre">copy_if</span></tt></a></p>
<!-- modtime: November 10, 2004 04:25:46 +0000 -->
</div>
</div>
<div class="footer-separator"></div>
<table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./reverse-iter-fold.html" class="navigation-link">Prev</a>&nbsp;<a href="./querying-algorithms.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./reverse-iter-fold.html" class="navigation-link">Back</a>&nbsp;Along</span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./iteration-algorithms.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>
</tr></table></body>
</html>
+24
View File
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.3.6: http://docutils.sourceforge.net/" />
<title>The MPL Reference Manual: Acknowledgements</title>
<link rel="stylesheet" href="../style.css" type="text/css" />
</head>
<body class="docframe refmanual">
<table class="header"><tr class="header"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./components.html" class="navigation-link">Prev</a>&nbsp;Next</span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./categorized-index.html" class="navigation-link">Back</a>&nbsp;Along</span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="../refmanual.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>
<td class="header-group page-location"><a href="../refmanual.html" class="navigation-link">Front Page</a> / <a href="./acknowledgements.html" class="navigation-link">Acknowledgements</a></td>
</tr></table><div class="header-separator"></div>
<div class="section" id="acknowledgements">
<h1><a class="toc-backref" href="../refmanual.html#id533" name="acknowledgements">Acknowledgements</a></h1>
<a class="target" id="label-acknowledgements" name="label-acknowledgements"></a><p>The format and language of this reference documentation has been greatly influenced by
the SGI's <a class="reference" href="http://www.sgi.com/tech/stl/" target="_top">Standard Template Library Programmer's Guide</a>.</p>
<!-- modtime: November 09, 2004 17:18:37 +0000 -->
</div>
<div class="footer-separator"></div>
<table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./components.html" class="navigation-link">Prev</a>&nbsp;Next</span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./categorized-index.html" class="navigation-link">Back</a>&nbsp;Along</span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="../refmanual.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>
</tr></table></body>
</html>
+138
View File
@@ -0,0 +1,138 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.3.6: http://docutils.sourceforge.net/" />
<title>The MPL Reference Manual: advance</title>
<link rel="stylesheet" href="../style.css" type="text/css" />
</head>
<body class="docframe refmanual">
<table class="header"><tr class="header"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./iterator-metafunctions.html" class="navigation-link">Prev</a>&nbsp;<a href="./distance.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group">Back&nbsp;<a href="./distance.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./iterator-metafunctions.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>
<td class="header-group page-location"><a href="../refmanual.html" class="navigation-link">Front Page</a> / <a href="./iterators.html" class="navigation-link">Iterators</a> / <a href="./iterator-metafunctions.html" class="navigation-link">Iterator Metafunctions</a> / <a href="./advance.html" class="navigation-link">advance</a></td>
</tr></table><div class="header-separator"></div>
<div class="section" id="advance">
<h1><a class="toc-backref" href="./iterator-metafunctions.html#id382" name="advance">advance</a></h1>
<div class="section" id="advance-synopsis">
<h3><a class="subsection-title" href="#synopsis" name="synopsis">Synopsis</a></h3>
<pre class="literal-block">
template&lt;
typename Iterator
, typename N
&gt;
struct <a href="./advance.html" class="identifier">advance</a>
{
typedef <em>unspecified</em> type;
};
</pre>
</div>
<div class="section" id="advance-description">
<h3><a class="subsection-title" href="#description" name="description">Description</a></h3>
<p>Moves <tt class="literal"><span class="pre">Iterator</span></tt> by the distance <tt class="literal"><span class="pre">N</span></tt>. For <a class="reference" href="./bidirectional-iterator.html">bidirectional</a> and
<a class="reference" href="./random-access-iterator.html">random access</a> iterators, the distance may be negative.</p>
</div>
<div class="section" id="advance-header">
<h3><a class="subsection-title" href="#header" name="header">Header</a></h3>
<pre class="literal-block">
#include &lt;<a href="../../../../boost/mpl/advance.hpp" class="header">boost/mpl/advance.hpp</a>&gt;
</pre>
</div>
<div class="section" id="advance-parameters">
<h3><a class="subsection-title" href="#parameters" name="parameters">Parameters</a></h3>
<table border="1" class="table">
<colgroup>
<col width="19%" />
<col width="35%" />
<col width="45%" />
</colgroup>
<thead valign="bottom">
<tr><th>Parameter</th>
<th>Requirement</th>
<th>Description</th>
</tr>
</thead>
<tbody valign="top">
<tr><td><tt class="literal"><span class="pre">Iterator</span></tt></td>
<td><a class="reference" href="./forward-iterator.html">Forward Iterator</a></td>
<td>An iterator to advance.</td>
</tr>
<tr><td><tt class="literal"><span class="pre">N</span></tt></td>
<td><a class="reference" href="./integral-constant.html">Integral Constant</a></td>
<td>A distance.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="advance-model-of">
<h3><a class="subsection-title" href="#model-of" name="model-of">Model Of</a></h3>
<p><a class="reference" href="./tag-dispatched.html">Tag Dispatched Metafunction</a></p>
</div>
<div class="section" id="advance-expression-semantics">
<h3><a class="subsection-title" href="#expression-semantics" name="expression-semantics">Expression semantics</a></h3>
<p>For a <a class="reference" href="./forward-iterator.html">Forward Iterator</a> <tt class="literal"><span class="pre">iter</span></tt> and arbitrary <a class="reference" href="./integral-constant.html">Integral Constant</a> <tt class="literal"><span class="pre">n</span></tt>:</p>
<pre class="literal-block">
typedef <a href="./advance.html" class="identifier">advance</a>&lt;iter,n&gt;::type j;
</pre>
<table class="field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Return type:</th><td class="field-body"><a class="reference" href="./forward-iterator.html">Forward Iterator</a>.</td>
</tr>
<tr class="field"><th class="field-name">Precondition:</th><td class="field-body">If <tt class="literal"><span class="pre">Iterator</span></tt> is a <a class="reference" href="./forward-iterator.html">Forward Iterator</a>, <tt class="literal"><span class="pre">n::value</span></tt> must be nonnegative.</td>
</tr>
<tr class="field"><th class="field-name">Semantics:</th><td class="field-body"><p class="first">Equivalent to:</p>
<pre class="literal-block">
typedef iter i0;
typedef <a href="./next.html" class="identifier">next</a>&lt;i0&gt;::type i1;
<em>...</em>
typedef <a href="./next.html" class="identifier">next</a>&lt;i<em>n-1</em>&gt;::type j;
</pre>
<p>if <tt class="literal"><span class="pre">n::value</span> <span class="pre">&gt;</span> <span class="pre">0</span></tt>, and</p>
<pre class="literal-block">
typedef iter i0;
typedef <a href="./prior.html" class="identifier">prior</a>&lt;i0&gt;::type i1;
<em>...</em>
typedef <a href="./prior.html" class="identifier">prior</a>&lt;i<em>n-1</em>&gt;::type j;
</pre>
<p class="last">otherwise.</p>
</td>
</tr>
<tr class="field"><th class="field-name">Postcondition:</th><td class="field-body"><tt class="literal"><span class="pre">j</span></tt> is dereferenceable or past-the-end;
<tt class="literal"><span class="pre"><a href="./distance.html" class="identifier">distance</a>&lt;iter,j&gt;::value</span> <span class="pre">==</span> <span class="pre">n::value</span></tt> if <tt class="literal"><span class="pre">n::value</span> <span class="pre">&gt;</span> <span class="pre">0</span></tt>, and
<tt class="literal"><span class="pre"><a href="./distance.html" class="identifier">distance</a>&lt;j,iter&gt;::value</span> <span class="pre">==</span> <span class="pre">n::value</span></tt> otherwise.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="advance-complexity">
<h3><a class="subsection-title" href="#complexity" name="complexity">Complexity</a></h3>
<p>Amortized constant time if <tt class="literal"><span class="pre">iter</span></tt> is a model of
<a class="reference" href="./random-access-iterator.html">Random Access Iterator</a>, otherwise linear time.</p>
</div>
<div class="section" id="advance-example">
<h3><a class="subsection-title" href="#example" name="example">Example</a></h3>
<pre class="literal-block">
typedef <a href="./range-c.html" class="identifier">range_c</a>&lt;int,0,10&gt; numbers;
typedef <a href="./begin.html" class="identifier">begin</a>&lt;numbers&gt;::type first;
typedef <a href="./end.html" class="identifier">end</a>&lt;numbers&gt;::type last;
typedef <a href="./advance.html" class="identifier">advance</a>&lt;first,<a href="./int.html" class="identifier">int_</a>&lt;10&gt; &gt;::type i1;
typedef <a href="./advance.html" class="identifier">advance</a>&lt;last,<a href="./int.html" class="identifier">int_</a>&lt;-10&gt; &gt;::type i2;
<a href="./assert.html" class="identifier">BOOST_MPL_ASSERT</a>(( boost::is_same&lt;i1,last&gt; ));
<a href="./assert.html" class="identifier">BOOST_MPL_ASSERT</a>(( boost::is_same&lt;i2,first&gt; ));
</pre>
</div>
<div class="section" id="advance-see-also">
<h3><a class="subsection-title" href="#see-also" name="see-also">See also</a></h3>
<p><a class="reference" href="./iterators.html">Iterators</a>, <a class="reference" href="./tag-dispatched.html">Tag Dispatched Metafunction</a>, <a class="refentry reference" href="./distance.html"><tt class="refentry literal"><span class="pre">distance</span></tt></a>, <a class="refentry reference" href="./next.html"><tt class="refentry literal"><span class="pre">next</span></tt></a></p>
<!-- modtime: November 11, 2004 11:16:39 +0000 -->
<!-- Iterators/Iterator Metafunctions//distance |20 -->
</div>
</div>
<div class="footer-separator"></div>
<table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./iterator-metafunctions.html" class="navigation-link">Prev</a>&nbsp;<a href="./distance.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group">Back&nbsp;<a href="./distance.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./iterator-metafunctions.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>
</tr></table></body>
</html>
+26
View File
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.3.6: http://docutils.sourceforge.net/" />
<title>The MPL Reference Manual: Concepts</title>
<link rel="stylesheet" href="../style.css" type="text/css" />
</head>
<body class="docframe refmanual">
<table class="header"><tr class="header"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./algorithms.html" class="navigation-link">Prev</a>&nbsp;<a href="./inserter.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group">Back&nbsp;<a href="./inserters.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./algorithms.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>
<td class="header-group page-location"><a href="../refmanual.html" class="navigation-link">Front Page</a> / <a href="./algorithms.html" class="navigation-link">Algorithms</a> / <a href="./algorithms-concepts.html" class="navigation-link">Concepts</a></td>
</tr></table><div class="header-separator"></div>
<div class="section" id="algorithms-concepts">
<h1><a class="toc-backref" href="./algorithms.html#id389" name="algorithms-concepts">Concepts</a></h1>
<a class="target" id="label-algorithms-concepts" name="label-algorithms-concepts"></a><!-- Algorithms/Concepts//Inserter -->
<ul class="toc simple" id="outline">
<li><a class="reference" href="./inserter.html" id="id390" name="id390">Inserter</a></li>
<li><a class="reference" href="./reversible-algorithm.html" id="id391" name="id391">Reversible Algorithm</a></li>
</ul>
</div>
<div class="footer-separator"></div>
<table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./algorithms.html" class="navigation-link">Prev</a>&nbsp;<a href="./inserter.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group">Back&nbsp;<a href="./inserters.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./algorithms.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>
</tr></table></body>
</html>
+59
View File
@@ -0,0 +1,59 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.3.6: http://docutils.sourceforge.net/" />
<title>The MPL Reference Manual: Algorithms</title>
<link rel="stylesheet" href="../style.css" type="text/css" />
</head>
<body class="docframe refmanual">
<table class="header"><tr class="header"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./iterator-category.html" class="navigation-link">Prev</a>&nbsp;<a href="./algorithms-concepts.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./iterators.html" class="navigation-link">Back</a>&nbsp;<a href="./metafunctions.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="../refmanual.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>
<td class="header-group page-location"><a href="../refmanual.html" class="navigation-link">Front Page</a> / <a href="./algorithms.html" class="navigation-link">Algorithms</a></td>
</tr></table><div class="header-separator"></div>
<div class="section" id="algorithms">
<h1><a class="toc-backref" href="../refmanual.html#id388" name="algorithms">Algorithms</a></h1>
<a class="target" id="label-algorithms" name="label-algorithms"></a><p>The MPL provides a broad range of fundamental algorithms aimed to
satisfy the majority of sequential compile-time data processing
needs. The algorithms include compile-time counterparts
of many of the STL algorithms, iteration algorithms borrowed from
functional programming languages, and more.</p>
<p>Unlike the algorithms in the C++ Standard Library, which operate on
implict <em>iterator ranges</em>, the majority of MPL counterparts take
and return <em>sequences</em>. This derivation is not dictated by the
functional nature of C++ compile-time computations per se, but
rather by a desire to improve general usability of the library,
making programming with compile-time data structures as enjoyable
as possible.</p>
<!-- This can be seen as a further generalization and extension of
the STL's conceptual framework. -->
<p>In the spirit of the STL, MPL algorithms are <em>generic</em>, meaning
that they are not tied to particular sequence class
implementations, and can operate on a wide range of arguments as
long as they satisfy the documented requirements. The requirements
are formulated in terms of concepts. Under the hood,
algorithms are decoupled from concrete sequence
implementations by operating on <a class="reference" href="./iterators.html">Iterators</a>.</p>
<p>All MPL algorithms can be sorted into three
major categories: iteration algorithms, querying algorithms, and
transformation algorithms. The transformation algorithms introduce
an associated <a class="reference" href="./inserter.html">Inserter</a> concept, a rough equivalent for the notion of
<a class="reference" href="http://www.sgi.com/tech/stl/OutputIterator.html" target="_top">Output Iterator</a> in the Standard Library. Moreover, every
transformation algorithm provides a <tt class="literal"><span class="pre">reverse_</span></tt> counterpart,
allowing for a wider range of efficient transformations — a
common functionality documented by the <a class="reference" href="./reversible-algorithm.html">Reversible Algorithm</a>
concept.</p>
<!-- modtime: November 08, 2004 10:32:25 +0000 -->
<ul class="toc simple" id="outline">
<li><a class="reference" href="./algorithms-concepts.html" id="id389" name="id389">Concepts</a></li>
<li><a class="reference" href="./inserters.html" id="id392" name="id392">Inserters</a></li>
<li><a class="reference" href="./iteration-algorithms.html" id="id396" name="id396">Iteration Algorithms</a></li>
<li><a class="reference" href="./querying-algorithms.html" id="id402" name="id402">Querying Algorithms</a></li>
<li><a class="reference" href="./transformation-algorithms.html" id="id413" name="id413">Transformation Algorithms</a></li>
</ul>
</div>
<div class="footer-separator"></div>
<table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./iterator-category.html" class="navigation-link">Prev</a>&nbsp;<a href="./algorithms-concepts.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./iterators.html" class="navigation-link">Back</a>&nbsp;<a href="./metafunctions.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="../refmanual.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>
</tr></table></body>
</html>
+108
View File
@@ -0,0 +1,108 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.3.6: http://docutils.sourceforge.net/" />
<title>The MPL Reference Manual: always</title>
<link rel="stylesheet" href="../style.css" type="text/css" />
</head>
<body class="docframe refmanual">
<table class="header"><tr class="header"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./identity.html" class="navigation-link">Prev</a>&nbsp;<a href="./inherit.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./identity.html" class="navigation-link">Back</a>&nbsp;<a href="./inherit.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>
<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="./always.html" class="navigation-link">always</a></td>
</tr></table><div class="header-separator"></div>
<div class="section" id="always">
<h1><a class="toc-backref" href="./miscellaneous.html#id489" name="always">always</a></h1>
<div class="section" id="always-synopsis">
<h3><a class="subsection-title" href="#synopsis" name="synopsis">Synopsis</a></h3>
<pre class="literal-block">
template&lt;
typename X
&gt;
struct <a href="./always.html" class="identifier">always</a>
{
// <em>unspecified</em>
// <em>...</em>
};
</pre>
</div>
<div class="section" id="always-description">
<h3><a class="subsection-title" href="#description" name="description">Description</a></h3>
<p><tt class="literal"><span class="pre"><a href="./always.html" class="identifier">always</a>&lt;X&gt;</span></tt> specialization is a variadic <a class="reference" href="./metafunction-class.html">Metafunction Class</a> always returning the
same type, <tt class="literal"><span class="pre">X</span></tt>, regardless of the number and types of passed arguments.</p>
</div>
<div class="section" id="always-header">
<h3><a class="subsection-title" href="#header" name="header">Header</a></h3>
<pre class="literal-block">
#include &lt;<a href="../../../../boost/mpl/always.hpp" class="header">boost/mpl/always.hpp</a>&gt;
</pre>
</div>
<div class="section" id="always-model-of">
<h3><a class="subsection-title" href="#model-of" name="model-of">Model of</a></h3>
<p><a class="reference" href="./metafunction-class.html">Metafunction Class</a></p>
</div>
<div class="section" id="always-parameters">
<h3><a class="subsection-title" href="#parameters" name="parameters">Parameters</a></h3>
<table border="1" class="table">
<colgroup>
<col width="22%" />
<col width="28%" />
<col width="51%" />
</colgroup>
<thead valign="bottom">
<tr><th>Parameter</th>
<th>Requirement</th>
<th>Description</th>
</tr>
</thead>
<tbody valign="top">
<tr><td><tt class="literal"><span class="pre">X</span></tt></td>
<td>Any type</td>
<td>A type to be returned.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="always-expression-semantics">
<h3><a class="subsection-title" href="#expression-semantics" name="expression-semantics">Expression semantics</a></h3>
<p>For an arbitrary type <tt class="literal"><span class="pre">x</span></tt>:</p>
<pre class="literal-block">
typedef <a href="./always.html" class="identifier">always</a>&lt;x&gt; f;
</pre>
<table class="field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Return type:</th><td class="field-body"><a class="reference" href="./metafunction-class.html">Metafunction Class</a>.</td>
</tr>
<tr class="field"><th class="field-name">Semantics:</th><td class="field-body"><p class="first">Equivalent to</p>
<pre class="last literal-block">
struct f : <a href="./bind.html" class="identifier">bind</a>&lt; <a href="./identity.html" class="identifier">identity</a>&lt;_1&gt;, x > {};
</pre>
</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="always-example">
<h3><a class="subsection-title" href="#example" name="example">Example</a></h3>
<pre class="literal-block">
typedef <a href="./always.html" class="identifier">always</a>&lt;true_&gt; always_true;
<a href="./assert.html" class="identifier">BOOST_MPL_ASSERT</a>(( <a href="./apply.html" class="identifier">apply</a>&lt; always_true,false_&gt; ));
<a href="./assert.html" class="identifier">BOOST_MPL_ASSERT</a>(( <a href="./apply.html" class="identifier">apply</a>&lt; always_true,false_,false_ &gt; ));
<a href="./assert.html" class="identifier">BOOST_MPL_ASSERT</a>(( <a href="./apply.html" class="identifier">apply</a>&lt; always_true,false_,false_,false_ > ));
</pre>
</div>
<div class="section" id="always-see-also">
<h3><a class="subsection-title" href="#see-also" name="see-also">See also</a></h3>
<p><a class="reference" href="./metafunctions.html">Metafunctions</a>, <a class="reference" href="./metafunction-class.html">Metafunction Class</a>, <a class="refentry reference" href="./identity.html"><tt class="refentry literal"><span class="pre">identity</span></tt></a>, <a class="refentry reference" href="./bind.html"><tt class="refentry literal"><span class="pre">bind</span></tt></a>, <a class="refentry reference" href="./apply.html"><tt class="refentry literal"><span class="pre">apply</span></tt></a></p>
<!-- modtime: November 13, 2004 02:52:37 +0000 -->
<!-- Metafunctions/Miscellaneous//inherit |30 -->
</div>
</div>
<div class="footer-separator"></div>
<table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./identity.html" class="navigation-link">Prev</a>&nbsp;<a href="./inherit.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./identity.html" class="navigation-link">Back</a>&nbsp;<a href="./inherit.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>
</tr></table></body>
</html>
+126
View File
@@ -0,0 +1,126 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.3.6: http://docutils.sourceforge.net/" />
<title>The MPL Reference Manual: and_</title>
<link rel="stylesheet" href="../style.css" type="text/css" />
</head>
<body class="docframe refmanual">
<table class="header"><tr class="header"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./logical-operations.html" class="navigation-link">Prev</a>&nbsp;<a href="./or.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group">Back&nbsp;<a href="./or.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./logical-operations.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>
<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="./logical-operations.html" class="navigation-link">Logical Operations</a> / <a href="./and.html" class="navigation-link">and_</a></td>
</tr></table><div class="header-separator"></div>
<div class="section" id="and">
<h1><a class="toc-backref" href="./logical-operations.html#id476" name="and">and_</a></h1>
<div class="section" id="and-synopsis">
<h3><a class="subsection-title" href="#synopsis" name="synopsis">Synopsis</a></h3>
<pre class="literal-block">
template&lt;
typename F1
, typename F2
<em>...</em>
, typename F<em>n</em> = <em>unspecified</em>
&gt;
struct <a href="./and.html" class="identifier">and_</a>
{
typedef <em>unspecified</em> type;
};
</pre>
</div>
<div class="section" id="and-description">
<h3><a class="subsection-title" href="#description" name="description">Description</a></h3>
<p>Returns the result of short-circuit <em>logical and</em> (<tt class="literal"><span class="pre">&amp;&amp;</span></tt>) operation on its arguments.</p>
</div>
<div class="section" id="and-header">
<h3><a class="subsection-title" href="#header" name="header">Header</a></h3>
<pre class="literal-block">
#include &lt;<a href="../../../../boost/mpl/and.hpp" class="header">boost/mpl/and.hpp</a>&gt;
#include &lt;<a href="../../../../boost/mpl/logical.hpp" class="header">boost/mpl/logical.hpp</a>&gt;
</pre>
</div>
<div class="section" id="and-parameters">
<h3><a class="subsection-title" href="#parameters" name="parameters">Parameters</a></h3>
<table border="1" class="table">
<colgroup>
<col width="17%" />
<col width="30%" />
<col width="53%" />
</colgroup>
<thead valign="bottom">
<tr><th>Parameter</th>
<th>Requirement</th>
<th>Description</th>
</tr>
</thead>
<tbody valign="top">
<tr><td><tt class="literal"><span class="pre">F1</span></tt>, <tt class="literal"><span class="pre">F2</span></tt>,... <tt class="literal"><span class="pre">Fn</span></tt></td>
<td>Nullary <a class="reference" href="./metafunction.html">Metafunction</a></td>
<td>Operation's arguments.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="and-expression-semantics">
<h3><a class="subsection-title" href="#expression-semantics" name="expression-semantics">Expression semantics</a></h3>
<p>For arbitrary nullary <a class="reference" href="./metafunction.html">Metafunction</a>s <tt class="literal"><span class="pre">f1</span></tt>, <tt class="literal"><span class="pre">f2</span></tt>,... <tt class="literal"><span class="pre">fn</span></tt>:</p>
<pre class="literal-block">
typedef <a href="./and.html" class="identifier">and_</a>&lt;f1,f2,<em>...</em>,f<em>n</em>&gt;::type r;
</pre>
<table class="field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Return type:</th><td class="field-body"><a class="reference" href="./integral-constant.html">Integral Constant</a>.</td>
</tr>
<tr class="field"><th class="field-name">Semantics:</th><td class="field-body"><tt class="literal"><span class="pre">r</span></tt> is <tt class="literal"><span class="pre">false_</span></tt> if either of <tt class="literal"><span class="pre">f1::type::value</span></tt>, <tt class="literal"><span class="pre">f2::type::value</span></tt>,...
<tt class="literal"><span class="pre">fn::type::value</span></tt> expressions evaluates to <tt class="literal"><span class="pre">false</span></tt>, and <tt class="literal"><span class="pre">true_</span></tt> otherwise;
guarantees left-to-right evaluation; the operands subsequent to the first
<tt class="literal"><span class="pre">f</span></tt><em>i</em> metafunction that evaluates to <tt class="literal"><span class="pre">false</span></tt> are not evaluated.</td>
</tr>
</tbody>
</table>
<!-- .......................................................................... -->
<pre class="literal-block">
typedef <a href="./and.html" class="identifier">and_</a>&lt;f1,f2,<em>...</em>,f<em>n</em>&gt; r;
</pre>
<table class="field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Return type:</th><td class="field-body"><a class="reference" href="./integral-constant.html">Integral Constant</a>.</td>
</tr>
<tr class="field"><th class="field-name">Semantics:</th><td class="field-body"><p class="first">Equivalent to</p>
<pre class="last literal-block">
struct r : <a href="./and.html" class="identifier">and_</a>&lt;f1,f2,<em>...</em>,f<em>n</em>&gt;::type {};
</pre>
</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="and-example">
<h3><a class="subsection-title" href="#example" name="example">Example</a></h3>
<pre class="literal-block">
struct unknown;
<a href="./assert.html" class="identifier">BOOST_MPL_ASSERT</a>(( <a href="./and.html" class="identifier">and_</a>&lt; true_,true_ &gt; ));
<a href="./assert-not.html" class="identifier">BOOST_MPL_ASSERT_NOT</a>(( <a href="./and.html" class="identifier">and_</a>&lt; false_,true_ &gt; ));
<a href="./assert-not.html" class="identifier">BOOST_MPL_ASSERT_NOT</a>(( <a href="./and.html" class="identifier">and_</a>&lt; true_,false_ &gt; ));
<a href="./assert-not.html" class="identifier">BOOST_MPL_ASSERT_NOT</a>(( <a href="./and.html" class="identifier">and_</a>&lt; false_,false_ &gt; ));
<a href="./assert-not.html" class="identifier">BOOST_MPL_ASSERT_NOT</a>(( <a href="./and.html" class="identifier">and_</a>&lt; false_,unknown &gt; )); // OK
<a href="./assert-not.html" class="identifier">BOOST_MPL_ASSERT_NOT</a>(( <a href="./and.html" class="identifier">and_</a>&lt; false_,unknown,unknown &gt; )); // OK too
</pre>
</div>
<div class="section" id="and-see-also">
<h3><a class="subsection-title" href="#see-also" name="see-also">See also</a></h3>
<p><a class="reference" href="./metafunctions.html">Metafunctions</a>, <a class="reference" href="./logical-operations.html">Logical Operations</a>, <a class="refentry reference" href="./or.html"><tt class="refentry literal"><span class="pre">or_</span></tt></a>, <a class="refentry reference" href="./not.html"><tt class="refentry literal"><span class="pre">not_</span></tt></a></p>
<!-- modtime: November 10, 2004 04:46:17 +0000 -->
<!-- Metafunctions/Logical Operations//or_ |20 -->
</div>
</div>
<div class="footer-separator"></div>
<table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./logical-operations.html" class="navigation-link">Prev</a>&nbsp;<a href="./or.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group">Back&nbsp;<a href="./or.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./logical-operations.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>
</tr></table></body>
</html>
+151
View File
@@ -0,0 +1,151 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.3.6: http://docutils.sourceforge.net/" />
<title>The MPL Reference Manual: apply_wrap</title>
<link rel="stylesheet" href="../style.css" type="text/css" />
</head>
<body class="docframe refmanual">
<table class="header"><tr class="header"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./apply.html" class="navigation-link">Prev</a>&nbsp;<a href="./unpack-args.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./apply.html" class="navigation-link">Back</a>&nbsp;<a href="./unpack-args.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./invocation.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>
<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="./invocation.html" class="navigation-link">Invocation</a> / <a href="./apply-wrap.html" class="navigation-link">apply_wrap</a></td>
</tr></table><div class="header-separator"></div>
<div class="section" id="apply-wrap">
<h1><a class="toc-backref" href="./invocation.html#id452" name="apply-wrap">apply_wrap</a></h1>
<div class="section" id="invocation-apply-synopsis">
<h3><a class="subsection-title" href="#synopsis" name="synopsis">Synopsis</a></h3>
<pre class="literal-block">
template&lt;
typename F
&gt;
struct apply_wrap0
{
typedef <em>unspecified</em> type;
};
template&lt;
typename F, typename A1
&gt;
struct apply_wrap1
{
typedef <em>unspecified</em> type;
};
<em>...</em>
template&lt;
typename F, typename A1,<em>...</em> typename An
&gt;
struct <a href="./apply-wrap.html" class="identifier">apply_wrap</a><em>n</em>
{
typedef <em>unspecified</em> type;
};
</pre>
</div>
<div class="section" id="invocation-apply-description">
<h3><a class="subsection-title" href="#description" name="description">Description</a></h3>
<p>Invokes a <a class="reference" href="./metafunction-class.html">Metafunction Class</a> <tt class="literal"><span class="pre">F</span></tt> with arguments <tt class="literal"><span class="pre">A1</span></tt>,... <tt class="literal"><span class="pre">An</span></tt>.</p>
<p>In essence, <tt class="literal"><span class="pre"><a href="./apply-wrap.html" class="identifier">apply_wrap</a></span></tt> forms are nothing more than syntactic wrappers around
<tt class="literal"><span class="pre">F::<a href="./apply.html" class="identifier">apply</a>&lt;A1,...</span> <span class="pre">An&gt;::type</span></tt> / <tt class="literal"><span class="pre">F::<a href="./apply.html" class="identifier">apply</a>::type</span></tt> expressions (hence the name).
They provide a more concise notation and higher portability than their
underlaying constructs at the cost of an extra template instantiation.</p>
</div>
<div class="section" id="invocation-apply-header">
<h3><a class="subsection-title" href="#header" name="header">Header</a></h3>
<pre class="literal-block">
#include &lt;<a href="../../../../boost/mpl/apply_wrap.hpp" class="header">boost/mpl/apply_wrap.hpp</a>&gt;
</pre>
</div>
<div class="section" id="invocation-apply-parameters">
<h3><a class="subsection-title" href="#parameters" name="parameters">Parameters</a></h3>
<table border="1" class="table">
<colgroup>
<col width="15%" />
<col width="36%" />
<col width="48%" />
</colgroup>
<thead valign="bottom">
<tr><th>Parameter</th>
<th>Requirement</th>
<th>Description</th>
</tr>
</thead>
<tbody valign="top">
<tr><td><tt class="literal"><span class="pre">F</span></tt></td>
<td><a class="reference" href="./metafunction-class.html">Metafunction Class</a></td>
<td>A metafunction class to invoke.</td>
</tr>
<tr><td><tt class="literal"><span class="pre">A1</span></tt>,... <tt class="literal"><span class="pre">An</span></tt></td>
<td>Any type</td>
<td>Invocation arguments.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="invocation-apply-expression-semantics">
<h3><a class="subsection-title" href="#expression-semantics" name="expression-semantics">Expression semantics</a></h3>
<p>For any <a class="reference" href="./metafunction-class.html">Metafunction Class</a> <tt class="literal"><span class="pre">f</span></tt> and arbitrary types <tt class="literal"><span class="pre">a1</span></tt>,... <tt class="literal"><span class="pre">an</span></tt>:</p>
<pre class="literal-block">
typedef <a href="./apply-wrap.html" class="identifier">apply_wrap</a><em>n</em>&lt;f,a1,<em>...</em>an&gt;::type t;
</pre>
<table class="field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Return type:</th><td class="field-body">Any type.</td>
</tr>
<tr class="field"><th class="field-name">Semantics:</th><td class="field-body">If <tt class="literal"><span class="pre">n</span> <span class="pre">&gt;</span> <span class="pre">0</span></tt>, equivalent to <tt class="literal"><span class="pre">typedef</span> <span class="pre">f::<a href="./apply.html" class="identifier">apply</a>&lt;a1,...</span> <span class="pre">an&gt;::type</span> <span class="pre">t;</span></tt>,
otherwise equivalent to either <tt class="literal"><span class="pre">typedef</span> <span class="pre">f::<a href="./apply.html" class="identifier">apply</a>::type</span> <span class="pre">t;</span></tt> or
<tt class="literal"><span class="pre">typedef</span> <span class="pre">f::<a href="./apply.html" class="identifier">apply</a>&lt;&gt;::type</span> <span class="pre">t;</span></tt> depending on whether <tt class="literal"><span class="pre">f::<a href="./apply.html" class="identifier">apply</a></span></tt> is
a class or a class template.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="invocation-apply-example">
<h3><a class="subsection-title" href="#example" name="example">Example</a></h3>
<pre class="literal-block">
struct f0
{
template&lt; typename T = int &gt; struct <a href="./apply.html" class="identifier">apply</a>
{
typedef char type;
};
};
struct g0
{
struct <a href="./apply.html" class="identifier">apply</a> { typedef char type; };
};
struct f2
{
template&lt; typename T1, typename T2 &gt; struct <a href="./apply.html" class="identifier">apply</a>
{
typedef T2 type;
};
};
typedef <a href="./apply-wrap.html" class="identifier">apply_wrap</a><tt class="literal"><span class="pre">0</span></tt>&lt; f0 &gt;::type r1;
typedef <a href="./apply-wrap.html" class="identifier">apply_wrap</a><tt class="literal"><span class="pre">0</span></tt>&lt; g0 &gt;::type r2;
typedef <a href="./apply-wrap.html" class="identifier">apply_wrap</a><tt class="literal"><span class="pre">2</span></tt>&lt; f2,int,char &gt;::type r3;
<a href="./assert.html" class="identifier">BOOST_MPL_ASSERT</a>(( is_same&lt;r1,char&gt; ));
<a href="./assert.html" class="identifier">BOOST_MPL_ASSERT</a>(( is_same&lt;r2,char&gt; ));
<a href="./assert.html" class="identifier">BOOST_MPL_ASSERT</a>(( is_same&lt;r3,char&gt; ));
</pre>
</div>
<div class="section" id="invocation-apply-see-also">
<h3><a class="subsection-title" href="#see-also" name="see-also">See also</a></h3>
<p><a class="reference" href="./metafunctions.html">Metafunctions</a>, <a class="reference" href="./invocation.html">invocation</a>, <a class="refentry reference" href="./apply.html"><tt class="refentry literal"><span class="pre">apply</span></tt></a>, <a class="refentry reference" href="./lambda.html"><tt class="refentry literal"><span class="pre">lambda</span></tt></a>, <a class="refentry reference" href="./quote.html"><tt class="refentry literal"><span class="pre">quote</span></tt></a>, <a class="refentry reference" href="./bind.html"><tt class="refentry literal"><span class="pre">bind</span></tt></a>, <a class="refentry reference" href="./protect.html"><tt class="refentry literal"><span class="pre">protect</span></tt></a></p>
<!-- modtime: November 10, 2004 04:46:09 +0000 -->
<!-- Metafunctions/Invocation//unpack_args |30 -->
</div>
</div>
<div class="footer-separator"></div>
<table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./apply.html" class="navigation-link">Prev</a>&nbsp;<a href="./unpack-args.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./apply.html" class="navigation-link">Back</a>&nbsp;<a href="./unpack-args.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./invocation.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>
</tr></table></body>
</html>
+137
View File
@@ -0,0 +1,137 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.3.6: http://docutils.sourceforge.net/" />
<title>The MPL Reference Manual: apply</title>
<link rel="stylesheet" href="../style.css" type="text/css" />
</head>
<body class="docframe refmanual">
<table class="header"><tr class="header"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./invocation.html" class="navigation-link">Prev</a>&nbsp;<a href="./apply-wrap.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group">Back&nbsp;<a href="./apply-wrap.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./invocation.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>
<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="./invocation.html" class="navigation-link">Invocation</a> / <a href="./apply.html" class="navigation-link">apply</a></td>
</tr></table><div class="header-separator"></div>
<div class="section" id="apply">
<h1><a class="toc-backref" href="./invocation.html#id451" name="apply">apply</a></h1>
<div class="section" id="apply-synopsis">
<h3><a class="subsection-title" href="#synopsis" name="synopsis">Synopsis</a></h3>
<pre class="literal-block">
template&lt;
typename F
&gt;
struct apply0
{
typedef <em>unspecified</em> type;
};
template&lt;
typename F, typename A1
&gt;
struct apply1
{
typedef <em>unspecified</em> type;
};
<em>...</em>
template&lt;
typename F, typename A1,<em>...</em> typename An
&gt;
struct <a href="./apply.html" class="identifier">apply</a><em>n</em>
{
typedef <em>unspecified</em> type;
};
template&lt;
typename F
, typename A1 = <em>unspecified</em>
<em>...</em>
, typename An = <em>unspecified</em>
&gt;
struct <a href="./apply.html" class="identifier">apply</a>
{
typedef <em>unspecified</em> type;
};
</pre>
</div>
<div class="section" id="apply-description">
<h3><a class="subsection-title" href="#description" name="description">Description</a></h3>
<p>Invokes a <a class="reference" href="./metafunction-class.html">Metafunction Class</a> or a <a class="reference" href="./lambda-expression.html">Lambda Expression</a> <tt class="literal"><span class="pre">F</span></tt> with arguments <tt class="literal"><span class="pre">A1</span></tt>,... <tt class="literal"><span class="pre">An</span></tt>.</p>
</div>
<div class="section" id="apply-header">
<h3><a class="subsection-title" href="#header" name="header">Header</a></h3>
<pre class="literal-block">
#include &lt;<a href="../../../../boost/mpl/apply.hpp" class="header">boost/mpl/apply.hpp</a>&gt;
</pre>
</div>
<div class="section" id="apply-parameters">
<h3><a class="subsection-title" href="#parameters" name="parameters">Parameters</a></h3>
<table border="1" class="table">
<colgroup>
<col width="15%" />
<col width="36%" />
<col width="48%" />
</colgroup>
<thead valign="bottom">
<tr><th>Parameter</th>
<th>Requirement</th>
<th>Description</th>
</tr>
</thead>
<tbody valign="top">
<tr><td><tt class="literal"><span class="pre">F</span></tt></td>
<td><a class="reference" href="./lambda-expression.html">Lambda Expression</a></td>
<td>An expression to invoke.</td>
</tr>
<tr><td><tt class="literal"><span class="pre">A1</span></tt>,... <tt class="literal"><span class="pre">An</span></tt></td>
<td>Any type</td>
<td>Invocation arguments.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="apply-expression-semantics">
<h3><a class="subsection-title" href="#expression-semantics" name="expression-semantics">Expression semantics</a></h3>
<p>For any <a class="reference" href="./lambda-expression.html">Lambda Expression</a> <tt class="literal"><span class="pre">f</span></tt> and arbitrary types <tt class="literal"><span class="pre">a1</span></tt>,... <tt class="literal"><span class="pre">an</span></tt>:</p>
<pre class="literal-block">
typedef <a href="./apply.html" class="identifier">apply</a><em>n</em>&lt;f,a1,<em>...</em>a<em>n</em>&gt;::type t;
typedef <a href="./apply.html" class="identifier">apply</a>&lt;f,a1,<em>...</em>a<em>n</em>&gt;::type t;
</pre>
<table class="field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Return type:</th><td class="field-body">Any type.</td>
</tr>
<tr class="field"><th class="field-name">Semantics:</th><td class="field-body">Equivalent to <tt class="literal"><span class="pre">typedef</span> <span class="pre"><a href="./apply-wrap.html" class="identifier">apply_wrap</a></span></tt><em>n</em><tt class="literal"><span class="pre">&lt;</span> <span class="pre"><a href="./lambda.html" class="identifier">lambda</a>&lt;f&gt;::type,a1,...</span> <span class="pre">an&gt;::type</span> <span class="pre">t;</span></tt>.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="apply-example">
<h3><a class="subsection-title" href="#example" name="example">Example</a></h3>
<pre class="literal-block">
template&lt; typename N1, typename N2 &gt; struct int_plus
: <a href="./int.html" class="identifier">int_</a>&lt;( N1::value + N2::value )&gt;
{
};
typedef <a href="./apply.html" class="identifier">apply</a>&lt; int_plus&lt;_1,_2&gt;, <a href="./int.html" class="identifier">int_</a>&lt;2&gt;, <a href="./int.html" class="identifier">int_</a>&lt;3&gt; &gt;::type r1;
typedef <a href="./apply.html" class="identifier">apply</a>&lt; <a href="./quote.html" class="identifier">quote</a><tt class="literal"><span class="pre">2</span></tt>&lt;int_plus&gt;, <a href="./int.html" class="identifier">int_</a>&lt;2&gt;, <a href="./int.html" class="identifier">int_</a>&lt;3&gt; &gt;::type r2;
<a href="./assert-relation.html" class="identifier">BOOST_MPL_ASSERT_RELATION</a>( r1::value, ==, 5 );
<a href="./assert-relation.html" class="identifier">BOOST_MPL_ASSERT_RELATION</a>( r2::value, ==, 5 );
</pre>
</div>
<div class="section" id="apply-see-also">
<h3><a class="subsection-title" href="#see-also" name="see-also">See also</a></h3>
<p><a class="reference" href="./metafunctions.html">Metafunctions</a>, <a class="refentry reference" href="./apply-wrap.html"><tt class="refentry literal"><span class="pre">apply_wrap</span></tt></a>, <a class="refentry reference" href="./lambda.html"><tt class="refentry literal"><span class="pre">lambda</span></tt></a>, <a class="refentry reference" href="./quote.html"><tt class="refentry literal"><span class="pre">quote</span></tt></a>, <a class="refentry reference" href="./bind.html"><tt class="refentry literal"><span class="pre">bind</span></tt></a></p>
<!-- modtime: November 10, 2004 04:46:13 +0000 -->
<!-- Metafunctions/Invocation//apply_wrap |20 -->
</div>
</div>
<div class="footer-separator"></div>
<table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./invocation.html" class="navigation-link">Prev</a>&nbsp;<a href="./apply-wrap.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group">Back&nbsp;<a href="./apply-wrap.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./invocation.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>
</tr></table></body>
</html>
+113
View File
@@ -0,0 +1,113 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.3.6: http://docutils.sourceforge.net/" />
<title>The MPL Reference Manual: arg</title>
<link rel="stylesheet" href="../style.css" type="text/css" />
</head>
<body class="docframe refmanual">
<table class="header"><tr class="header"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./quote.html" class="navigation-link">Prev</a>&nbsp;<a href="./protect.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./quote.html" class="navigation-link">Back</a>&nbsp;<a href="./protect.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./composition-and-argument.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>
<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="./composition-and-argument.html" class="navigation-link">Composition and Argument Binding</a> / <a href="./arg.html" class="navigation-link">arg</a></td>
</tr></table><div class="header-separator"></div>
<div class="section" id="arg">
<h1><a class="toc-backref" href="./composition-and-argument.html#id459" name="arg">arg</a></h1>
<div class="section" id="arg-synopsis">
<h3><a class="subsection-title" href="#synopsis" name="synopsis">Synopsis</a></h3>
<pre class="literal-block">
template&lt; int n &gt; struct <a href="./arg.html" class="identifier">arg</a>;
template&lt;&gt; struct <a href="./arg.html" class="identifier">arg</a>&lt;1&gt;
{
template&lt; typename A1,<em>...</em> typename A<em>n</em> = <em>unspecified</em> &gt;
struct <a href="./apply.html" class="identifier">apply</a>
{
typedef A1 type;
};
};
<em>...</em>
template&lt;&gt; struct <a href="./arg.html" class="identifier">arg</a>&lt;<em>n</em>&gt;
{
template&lt; typename A1,<em>...</em> typename A<em>n</em> &gt;
struct <a href="./apply.html" class="identifier">apply</a>
{
typedef A<em>n</em> type;
};
};
</pre>
</div>
<div class="section" id="arg-description">
<h3><a class="subsection-title" href="#description" name="description">Description</a></h3>
<p><tt class="literal"><span class="pre"><a href="./arg.html" class="identifier">arg</a>&lt;n&gt;</span></tt> specialization is a <a class="reference" href="./metafunction-class.html">Metafunction Class</a> that return the <tt class="literal"><span class="pre">n</span></tt>th of its arguments.</p>
</div>
<div class="section" id="arg-header">
<h3><a class="subsection-title" href="#header" name="header">Header</a></h3>
<pre class="literal-block">
#include &lt;<a href="../../../../boost/mpl/arg.hpp" class="header">boost/mpl/arg.hpp</a>&gt;
</pre>
</div>
<div class="section" id="arg-parameters">
<h3><a class="subsection-title" href="#parameters" name="parameters">Parameters</a></h3>
<table border="1" class="table">
<colgroup>
<col width="15%" />
<col width="36%" />
<col width="48%" />
</colgroup>
<thead valign="bottom">
<tr><th>Parameter</th>
<th>Requirement</th>
<th>Description</th>
</tr>
</thead>
<tbody valign="top">
<tr><td><tt class="literal"><span class="pre">n</span></tt></td>
<td>An integral constant</td>
<td>A number of argument to return.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="arg-expression-semantics">
<h3><a class="subsection-title" href="#expression-semantics" name="expression-semantics">Expression semantics</a></h3>
<p>For any integral constant <tt class="literal"><span class="pre">n</span></tt> in the range [1, <a class="refentry reference" href="./limit-metafunction-arity.html"><tt class="refentry literal"><span class="pre">BOOST_MPL_LIMIT_METAFUNCTION_ARITY</span></tt></a>] and
arbitrary types <tt class="literal"><span class="pre">a1</span></tt>,... <tt class="literal"><span class="pre">an</span></tt>:</p>
<pre class="literal-block">
typedef <a href="./apply-wrap.html" class="identifier">apply_wrap</a><em>n</em>&lt; <a href="./arg.html" class="identifier">arg</a>&lt;<em>n</em>&gt;,a1,<em>...</em>a<em>n</em> &gt;::type x;
</pre>
<table class="field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Return type:</th><td class="field-body">A type.</td>
</tr>
<tr class="field"><th class="field-name">Semantics:</th><td class="field-body"><tt class="literal"><span class="pre">x</span></tt> is identical to <tt class="literal"><span class="pre">an</span></tt>.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="arg-example">
<h3><a class="subsection-title" href="#example" name="example">Example</a></h3>
<pre class="literal-block">
typedef <a href="./apply-wrap.html" class="identifier">apply_wrap</a><tt class="literal"><span class="pre">5</span></tt>&lt; <a href="./arg.html" class="identifier">arg</a>&lt;1&gt;,bool,char,short,int,long &gt;::type t1;
typedef <a href="./apply-wrap.html" class="identifier">apply_wrap</a><tt class="literal"><span class="pre">5</span></tt>&lt; <a href="./arg.html" class="identifier">arg</a>&lt;3&gt;,bool,char,short,int,long &gt;::type t3;
<a href="./assert.html" class="identifier">BOOST_MPL_ASSERT</a>(( is_same&lt; t1, bool &gt; ));
<a href="./assert.html" class="identifier">BOOST_MPL_ASSERT</a>(( is_same&lt; t3, short > ));
</pre>
</div>
<div class="section" id="arg-see-also">
<h3><a class="subsection-title" href="#see-also" name="see-also">See also</a></h3>
<p><a class="reference" href="./composition-and-argument.html">Composition and Argument Binding</a>, <a class="reference" href="./placeholders.html">Placeholders</a>, <a class="refentry reference" href="./lambda.html"><tt class="refentry literal"><span class="pre">lambda</span></tt></a>, <a class="refentry reference" href="./bind.html"><tt class="refentry literal"><span class="pre">bind</span></tt></a>, <a class="refentry reference" href="./apply.html"><tt class="refentry literal"><span class="pre">apply</span></tt></a>, <a class="refentry reference" href="./apply-wrap.html"><tt class="refentry literal"><span class="pre">apply_wrap</span></tt></a></p>
<!-- modtime: November 13, 2004 18:35:04 +0000 -->
<!-- Metafunctions/Composition and Argument Binding//protect |60 -->
</div>
</div>
<div class="footer-separator"></div>
<table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./quote.html" class="navigation-link">Prev</a>&nbsp;<a href="./protect.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./quote.html" class="navigation-link">Back</a>&nbsp;<a href="./protect.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./composition-and-argument.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>
</tr></table></body>
</html>
+31
View File
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.3.6: http://docutils.sourceforge.net/" />
<title>The MPL Reference Manual: Arithmetic Operations</title>
<link rel="stylesheet" href="../style.css" type="text/css" />
</head>
<body class="docframe refmanual">
<table class="header"><tr class="header"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./protect.html" class="navigation-link">Prev</a>&nbsp;<a href="./plus.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./composition-and-argument.html" class="navigation-link">Back</a>&nbsp;<a href="./comparisons.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./metafunctions.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>
<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="./arithmetic-operations.html" class="navigation-link">Arithmetic Operations</a></td>
</tr></table><div class="header-separator"></div>
<div class="section" id="arithmetic-operations">
<h1><a class="toc-backref" href="./metafunctions.html#id461" name="arithmetic-operations">Arithmetic Operations</a></h1>
<a class="target" id="id227" name="id227"></a><!-- modtime: November 08, 2004 05:37:53 +0000 -->
<!-- Metafunctions/Arithmetic Operations//plus |10 -->
<ul class="toc simple" id="outline">
<li><a class="reference" href="./plus.html" id="id462" name="id462">plus</a></li>
<li><a class="reference" href="./minus.html" id="id463" name="id463">minus</a></li>
<li><a class="reference" href="./times.html" id="id464" name="id464">times</a></li>
<li><a class="reference" href="./divides.html" id="id465" name="id465">divides</a></li>
<li><a class="reference" href="./modulus.html" id="id466" name="id466">modulus</a></li>
<li><a class="reference" href="./negate.html" id="id467" name="id467">negate</a></li>
</ul>
</div>
<div class="footer-separator"></div>
<table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./protect.html" class="navigation-link">Prev</a>&nbsp;<a href="./plus.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./composition-and-argument.html" class="navigation-link">Back</a>&nbsp;<a href="./comparisons.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./metafunctions.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>
</tr></table></body>
</html>
+152
View File
@@ -0,0 +1,152 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.3.6: http://docutils.sourceforge.net/" />
<title>The MPL Reference Manual: BOOST_MPL_ASSERT_MSG</title>
<link rel="stylesheet" href="../style.css" type="text/css" />
</head>
<body class="docframe refmanual">
<table class="header"><tr class="header"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./assert.html" class="navigation-link">Prev</a>&nbsp;<a href="./assert-not.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./assert.html" class="navigation-link">Back</a>&nbsp;<a href="./assert-not.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./asserts.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>
<td class="header-group page-location"><a href="../refmanual.html" class="navigation-link">Front Page</a> / <a href="./macros.html" class="navigation-link">Macros</a> / <a href="./asserts.html" class="navigation-link">Asserts</a> / <a href="./assert-msg.html" class="navigation-link">BOOST_MPL_ASSERT_MSG</a></td>
</tr></table><div class="header-separator"></div>
<div class="section" id="assert-msg">
<h1><a class="toc-backref" href="./asserts.html#id512" name="assert-msg">BOOST_MPL_ASSERT_MSG</a></h1>
<div class="section" id="asserts-assert-synopsis">
<h3><a class="subsection-title" href="#synopsis" name="synopsis">Synopsis</a></h3>
<pre class="literal-block">
#define <a href="./assert-msg.html" class="identifier">BOOST_MPL_ASSERT_MSG</a>( condition, message, types ) \
<em>unspecified token sequence</em> \
/**/
</pre>
</div>
<div class="section" id="asserts-assert-description">
<h3><a class="subsection-title" href="#description" name="description">Description</a></h3>
<p>Generates a compilation error with an embedded custom message when the condition
doesn't hold.</p>
</div>
<div class="section" id="asserts-assert-header">
<h3><a class="subsection-title" href="#header" name="header">Header</a></h3>
<pre class="literal-block">
#include &lt;<a href="../../../../boost/mpl/assert.hpp" class="header">boost/mpl/assert.hpp</a>&gt;
</pre>
</div>
<div class="section" id="asserts-assert-parameters">
<h3><a class="subsection-title" href="#parameters" name="parameters">Parameters</a></h3>
<table border="1" class="table">
<colgroup>
<col width="15%" />
<col width="36%" />
<col width="48%" />
</colgroup>
<thead valign="bottom">
<tr><th>Parameter</th>
<th>Requirement</th>
<th>Description</th>
</tr>
</thead>
<tbody valign="top">
<tr><td><tt class="literal"><span class="pre">condition</span></tt></td>
<td>An integral constant expression</td>
<td>A condition to be asserted.</td>
</tr>
<tr><td><tt class="literal"><span class="pre">message</span></tt></td>
<td>A legal identifier token</td>
<td>A custom message in a form of a legal C++
identifier token.</td>
</tr>
<tr><td><tt class="literal"><span class="pre">types</span></tt></td>
<td>A legal function parameter list</td>
<td>A parenthized list of types to be displayed
in the error message.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="asserts-assert-expression-semantics">
<h3><a class="subsection-title" href="#expression-semantics" name="expression-semantics">Expression semantics</a></h3>
<p>For any integral constant expression <tt class="literal"><span class="pre">expr</span></tt>, legal C++ identifier <tt class="literal"><span class="pre">message</span></tt>, and
arbitrary types <tt class="literal"><span class="pre">t1</span></tt>, <tt class="literal"><span class="pre">t2</span></tt>,... <tt class="literal"><span class="pre">tn</span></tt>:</p>
<pre class="literal-block">
<a href="./assert-msg.html" class="identifier">BOOST_MPL_ASSERT_MSG</a>( expr, message, (t1, t2,... tn) );
</pre>
<table class="field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Return type:</th><td class="field-body">None.</td>
</tr>
<tr class="field"><th class="field-name">Precondition:</th><td class="field-body"><tt class="literal"><span class="pre">t1</span></tt>, <tt class="literal"><span class="pre">t2</span></tt>,... <tt class="literal"><span class="pre">tn</span></tt> are non-<tt class="literal"><span class="pre">void</span></tt>.</td>
</tr>
<tr class="field"><th class="field-name">Semantics:</th><td class="field-body"><p class="first">Generates a compilation error if <tt class="literal"><span class="pre">expr::value</span> <span class="pre">!=</span> <span class="pre">true</span></tt>, otherwise
has no effect.</p>
<p>When possible within the compiler's diagnostic capabilities,
the error message will include the <tt class="literal"><span class="pre">message</span></tt> identifier and the parenthized
list of <tt class="literal"><span class="pre">t1</span></tt>, <tt class="literal"><span class="pre">t2</span></tt>,... <tt class="literal"><span class="pre">tn</span></tt> types, and have a general form of:</p>
<pre class="last literal-block">
<em>...</em> ************( <em>...</em>::message )************)(t1, t2,... tn) <em>...</em>
</pre>
</td>
</tr>
</tbody>
</table>
<pre class="literal-block">
<a href="./assert-msg.html" class="identifier">BOOST_MPL_ASSERT_MSG</a>( expr, message, (types&lt;t1, t2,... tn&gt;) );
</pre>
<table class="field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Return type:</th><td class="field-body">None.</td>
</tr>
<tr class="field"><th class="field-name">Precondition:</th><td class="field-body">None.</td>
</tr>
<tr class="field"><th class="field-name">Semantics:</th><td class="field-body"><p class="first">Generates a compilation error if <tt class="literal"><span class="pre">expr::value</span> <span class="pre">!=</span> <span class="pre">true</span></tt>, otherwise
has no effect.</p>
<p>When possible within the compiler's diagnostics capabilities,
the error message will include the <tt class="literal"><span class="pre">message</span></tt> identifier and the list of
<tt class="literal"><span class="pre">t1</span></tt>, <tt class="literal"><span class="pre">t2</span></tt>,... <tt class="literal"><span class="pre">tn</span></tt> types, and have a general form of:</p>
<pre class="last literal-block">
<em>...</em> ************( <em>...</em>::message )************)(types&lt;t1, t2,... tn&gt;) <em>...</em>
</pre>
</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="asserts-assert-example">
<h3><a class="subsection-title" href="#example" name="example">Example</a></h3>
<pre class="literal-block">
template&lt; typename T &gt; struct my
{
// ...
<a href="./assert-msg.html" class="identifier">BOOST_MPL_ASSERT_MSG</a>(
is_integral&lt;T&gt;::value
, NON_INTEGRAL_TYPES_ARE_NOT_ALLOWED
, (T)
);
};
my&lt;void*&gt; test;
// In instantiation of `my&lt;void*&gt;':
// instantiated from here
// conversion from `
// mpl_::failed************(my&lt;void*&gt;::
// NON_INTEGRAL_TYPES_ARE_NOT_ALLOWED::************)(void*)
// ' to non-scalar type `mpl_::assert&lt;false&gt;' requested
</pre>
</div>
<div class="section" id="asserts-assert-see-also">
<h3><a class="subsection-title" href="#see-also" name="see-also">See also</a></h3>
<p><a class="reference" href="./asserts.html">Asserts</a>, <a class="refentry reference" href="./assert.html"><tt class="refentry literal"><span class="pre">BOOST_MPL_ASSERT</span></tt></a>, <a class="refentry reference" href="./assert-not.html"><tt class="refentry literal"><span class="pre">BOOST_MPL_ASSERT_NOT</span></tt></a>, <a class="refentry reference" href="./assert-relation.html"><tt class="refentry literal"><span class="pre">BOOST_MPL_ASSERT_RELATION</span></tt></a></p>
<!-- modtime: November 10, 2004 04:45:24 +0000 -->
<!-- Macros/Asserts//BOOST_MPL_ASSERT_NOT -->
</div>
</div>
<div class="footer-separator"></div>
<table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./assert.html" class="navigation-link">Prev</a>&nbsp;<a href="./assert-not.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./assert.html" class="navigation-link">Back</a>&nbsp;<a href="./assert-not.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./asserts.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>
</tr></table></body>
</html>
+111
View File
@@ -0,0 +1,111 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.3.6: http://docutils.sourceforge.net/" />
<title>The MPL Reference Manual: BOOST_MPL_ASSERT_NOT</title>
<link rel="stylesheet" href="../style.css" type="text/css" />
</head>
<body class="docframe refmanual">
<table class="header"><tr class="header"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./assert-msg.html" class="navigation-link">Prev</a>&nbsp;<a href="./assert-relation.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./assert-msg.html" class="navigation-link">Back</a>&nbsp;<a href="./assert-relation.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./asserts.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>
<td class="header-group page-location"><a href="../refmanual.html" class="navigation-link">Front Page</a> / <a href="./macros.html" class="navigation-link">Macros</a> / <a href="./asserts.html" class="navigation-link">Asserts</a> / <a href="./assert-not.html" class="navigation-link">BOOST_MPL_ASSERT_NOT</a></td>
</tr></table><div class="header-separator"></div>
<div class="section" id="assert-not">
<h1><a class="toc-backref" href="./asserts.html#id513" name="assert-not">BOOST_MPL_ASSERT_NOT</a></h1>
<div class="section" id="macros-asserts-assert-synopsis">
<h3><a class="subsection-title" href="#synopsis" name="synopsis">Synopsis</a></h3>
<pre class="literal-block">
#define <a href="./assert-not.html" class="identifier">BOOST_MPL_ASSERT_NOT</a>( pred ) \
<em>unspecified token sequence</em> \
/**/
</pre>
</div>
<div class="section" id="macros-asserts-assert-description">
<h3><a class="subsection-title" href="#description" name="description">Description</a></h3>
<p>Generates a compilation error when predicate holds true.</p>
</div>
<div class="section" id="macros-asserts-assert-header">
<h3><a class="subsection-title" href="#header" name="header">Header</a></h3>
<pre class="literal-block">
#include &lt;<a href="../../../../boost/mpl/assert.hpp" class="header">boost/mpl/assert.hpp</a>&gt;
</pre>
</div>
<div class="section" id="macros-asserts-assert-parameters">
<h3><a class="subsection-title" href="#parameters" name="parameters">Parameters</a></h3>
<table border="1" class="table">
<colgroup>
<col width="16%" />
<col width="38%" />
<col width="46%" />
</colgroup>
<thead valign="bottom">
<tr><th>Parameter</th>
<th>Requirement</th>
<th>Description</th>
</tr>
</thead>
<tbody valign="top">
<tr><td><tt class="literal"><span class="pre">pred</span></tt></td>
<td>Boolean nullary <a class="reference" href="./metafunction.html">Metafunction</a></td>
<td>A predicate to be asserted to be false.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="macros-asserts-assert-expression-semantics">
<h3><a class="subsection-title" href="#expression-semantics" name="expression-semantics">Expression semantics</a></h3>
<p>For any boolean nullary <a class="reference" href="./metafunction.html">Metafunction</a> <tt class="literal"><span class="pre">pred</span></tt>:</p>
<pre class="literal-block">
<a href="./assert-not.html" class="identifier">BOOST_MPL_ASSERT_NOT</a>(( pred ));
</pre>
<table class="field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Return type:</th><td class="field-body">None.</td>
</tr>
<tr class="field"><th class="field-name">Semantics:</th><td class="field-body"><p class="first">Generates a compilation error if <tt class="literal"><span class="pre">pred::type::value</span> <span class="pre">!=</span> <span class="pre">false</span></tt>, otherwise
has no effect. Note that double parentheses are required even if no commas
appear in the condition.</p>
<p>When possible within the compiler's diagnostic capabilities,
the error message will include the predicate's full type name, and have a
general form of:</p>
<pre class="last literal-block">
<em>...</em> ************boost::mpl::<a href="./not.html" class="identifier">not_</a>&lt; pred >::************ <em>...</em>
</pre>
</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="macros-asserts-assert-example">
<h3><a class="subsection-title" href="#example" name="example">Example</a></h3>
<pre class="literal-block">
template&lt; typename T, typename U &gt; struct my
{
// ...
<a href="./assert-not.html" class="identifier">BOOST_MPL_ASSERT_NOT</a>(( is_same&lt; T,U &gt; ));
};
my&lt;void,void&gt; test;
// In instantiation of `my&lt;void, void&gt;':
// instantiated from here
// conversion from `
// mpl_::failed************boost::mpl::<a href="./not.html" class="identifier">not_</a>&lt;boost::is_same&lt;void, void&gt;
// &gt;::************' to non-scalar type `mpl_::assert&lt;false&gt;' requested
</pre>
</div>
<div class="section" id="macros-asserts-assert-see-also">
<h3><a class="subsection-title" href="#see-also" name="see-also">See also</a></h3>
<p><a class="reference" href="./asserts.html">Asserts</a>, <a class="refentry reference" href="./assert.html"><tt class="refentry literal"><span class="pre">BOOST_MPL_ASSERT</span></tt></a>, <a class="refentry reference" href="./assert-msg.html"><tt class="refentry literal"><span class="pre">BOOST_MPL_ASSERT_MSG</span></tt></a>, <a class="refentry reference" href="./assert-relation.html"><tt class="refentry literal"><span class="pre">BOOST_MPL_ASSERT_RELATION</span></tt></a></p>
<!-- modtime: November 10, 2004 04:45:20 +0000 -->
<!-- Macros/Asserts//BOOST_MPL_ASSERT_RELATION -->
</div>
</div>
<div class="footer-separator"></div>
<table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./assert-msg.html" class="navigation-link">Prev</a>&nbsp;<a href="./assert-relation.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./assert-msg.html" class="navigation-link">Back</a>&nbsp;<a href="./assert-relation.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./asserts.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>
</tr></table></body>
</html>
+120
View File
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.3.6: http://docutils.sourceforge.net/" />
<title>The MPL Reference Manual: BOOST_MPL_ASSERT_RELATION</title>
<link rel="stylesheet" href="../style.css" type="text/css" />
</head>
<body class="docframe refmanual">
<table class="header"><tr class="header"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./assert-not.html" class="navigation-link">Prev</a>&nbsp;<a href="./introspection.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./assert-not.html" class="navigation-link">Back</a>&nbsp;Along</span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./asserts.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>
<td class="header-group page-location"><a href="../refmanual.html" class="navigation-link">Front Page</a> / <a href="./macros.html" class="navigation-link">Macros</a> / <a href="./asserts.html" class="navigation-link">Asserts</a> / <a href="./assert-relation.html" class="navigation-link">BOOST_MPL_ASSERT_RELATION</a></td>
</tr></table><div class="header-separator"></div>
<div class="section" id="assert-relation">
<h1><a class="toc-backref" href="./asserts.html#id514" name="assert-relation">BOOST_MPL_ASSERT_RELATION</a></h1>
<div class="section" id="the-macros-asserts-assert-synopsis">
<h3><a class="subsection-title" href="#synopsis" name="synopsis">Synopsis</a></h3>
<pre class="literal-block">
#define <a href="./assert-relation.html" class="identifier">BOOST_MPL_ASSERT_RELATION</a>( x, relation, y ) \
<em>unspecified token sequence</em> \
/**/
</pre>
</div>
<div class="section" id="the-macros-asserts-assert-description">
<h3><a class="subsection-title" href="#description" name="description">Description</a></h3>
<p>A specialized assertion macro for checking numerical conditions. Generates
a compilation error when the condition <tt class="literal"><span class="pre">(</span> <span class="pre">x</span> <span class="pre">relation</span> <span class="pre">y</span> <span class="pre">)</span></tt>
doesn't hold.</p>
</div>
<div class="section" id="the-macros-asserts-assert-header">
<h3><a class="subsection-title" href="#header" name="header">Header</a></h3>
<pre class="literal-block">
#include &lt;<a href="../../../../boost/mpl/assert.hpp" class="header">boost/mpl/assert.hpp</a>&gt;
</pre>
</div>
<div class="section" id="the-macros-asserts-assert-parameters">
<h3><a class="subsection-title" href="#parameters" name="parameters">Parameters</a></h3>
<table border="1" class="table">
<colgroup>
<col width="15%" />
<col width="36%" />
<col width="48%" />
</colgroup>
<thead valign="bottom">
<tr><th>Parameter</th>
<th>Requirement</th>
<th>Description</th>
</tr>
</thead>
<tbody valign="top">
<tr><td><tt class="literal"><span class="pre">x</span></tt></td>
<td>An integral constant</td>
<td>Left operand of the checked relation.</td>
</tr>
<tr><td><tt class="literal"><span class="pre">y</span></tt></td>
<td>An integral constant</td>
<td>Right operand of the checked relation.</td>
</tr>
<tr><td><tt class="literal"><span class="pre">relation</span></tt></td>
<td>A C++ operator token</td>
<td>An operator token for the relation being
checked.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="the-macros-asserts-assert-expression-semantics">
<h3><a class="subsection-title" href="#expression-semantics" name="expression-semantics">Expression semantics</a></h3>
<p>For any integral constants <tt class="literal"><span class="pre">x</span></tt>, <tt class="literal"><span class="pre">y</span></tt> and a legal C++ operator token <tt class="literal"><span class="pre">op</span></tt>:</p>
<pre class="literal-block">
<a href="./assert-relation.html" class="identifier">BOOST_MPL_ASSERT_RELATION</a>( x, op, y );
</pre>
<table class="field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Return type:</th><td class="field-body">None.</td>
</tr>
<tr class="field"><th class="field-name">Semantics:</th><td class="field-body"><p class="first">Generates a compilation error if <tt class="literal"><span class="pre">(</span> <span class="pre">x</span> <span class="pre">op</span> <span class="pre">y</span> <span class="pre">)</span> <span class="pre">!=</span> <span class="pre">true</span></tt>, otherwise
has no effect.</p>
<p>When possible within the compiler's diagnostic capabilities,
the error message will include a name of the relation being checked,
the actual values of both operands, and have a general form of:</p>
<pre class="last literal-block">
<em>...</em> ************<em>...</em>assert_relation&lt;op, x, y&gt;::************) <em>...</em>
</pre>
</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="the-macros-asserts-assert-example">
<h3><a class="subsection-title" href="#example" name="example">Example</a></h3>
<pre class="literal-block">
template&lt; typename T, typename U &gt; struct my
{
// ...
<a href="./assert-relation.html" class="identifier">BOOST_MPL_ASSERT_RELATION</a>( sizeof(T), &lt;, sizeof(U) );
};
my&lt;char[50],char[10]&gt; test;
// In instantiation of `my&lt;char[50], char[10]&gt;':
// instantiated from here
// conversion from `
// mpl_::failed************mpl_::assert_relation&lt;<a href="./less.html" class="identifier">less</a>, 50, 10&gt;::************'
// to non-scalar type `mpl_::assert&lt;false&gt;' requested
</pre>
</div>
<div class="section" id="the-macros-asserts-assert-see-also">
<h3><a class="subsection-title" href="#see-also" name="see-also">See also</a></h3>
<p><a class="reference" href="./asserts.html">Asserts</a>, <a class="refentry reference" href="./assert.html"><tt class="refentry literal"><span class="pre">BOOST_MPL_ASSERT</span></tt></a>, <a class="refentry reference" href="./assert-not.html"><tt class="refentry literal"><span class="pre">BOOST_MPL_ASSERT_NOT</span></tt></a>, <a class="refentry reference" href="./assert-msg.html"><tt class="refentry literal"><span class="pre">BOOST_MPL_ASSERT_MSG</span></tt></a></p>
<!-- modtime: November 10, 2004 04:45:16 +0000 -->
</div>
</div>
<div class="footer-separator"></div>
<table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./assert-not.html" class="navigation-link">Prev</a>&nbsp;<a href="./introspection.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./assert-not.html" class="navigation-link">Back</a>&nbsp;Along</span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./asserts.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>
</tr></table></body>
</html>
+111
View File
@@ -0,0 +1,111 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.3.6: http://docutils.sourceforge.net/" />
<title>The MPL Reference Manual: BOOST_MPL_ASSERT</title>
<link rel="stylesheet" href="../style.css" type="text/css" />
</head>
<body class="docframe refmanual">
<table class="header"><tr class="header"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./asserts.html" class="navigation-link">Prev</a>&nbsp;<a href="./assert-msg.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group">Back&nbsp;<a href="./assert-msg.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./asserts.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>
<td class="header-group page-location"><a href="../refmanual.html" class="navigation-link">Front Page</a> / <a href="./macros.html" class="navigation-link">Macros</a> / <a href="./asserts.html" class="navigation-link">Asserts</a> / <a href="./assert.html" class="navigation-link">BOOST_MPL_ASSERT</a></td>
</tr></table><div class="header-separator"></div>
<div class="section" id="assert">
<h1><a class="toc-backref" href="./asserts.html#id511" name="assert">BOOST_MPL_ASSERT</a></h1>
<div class="section" id="assert-synopsis">
<h3><a class="subsection-title" href="#synopsis" name="synopsis">Synopsis</a></h3>
<pre class="literal-block">
#define <a href="./assert.html" class="identifier">BOOST_MPL_ASSERT</a>( pred ) \
<em>unspecified token sequence</em> \
/**/
</pre>
</div>
<div class="section" id="assert-description">
<h3><a class="subsection-title" href="#description" name="description">Description</a></h3>
<p>Generates a compilation error when the predicate <tt class="literal"><span class="pre">pred</span></tt> holds false.</p>
</div>
<div class="section" id="assert-header">
<h3><a class="subsection-title" href="#header" name="header">Header</a></h3>
<pre class="literal-block">
#include &lt;<a href="../../../../boost/mpl/assert.hpp" class="header">boost/mpl/assert.hpp</a>&gt;
</pre>
</div>
<div class="section" id="assert-parameters">
<h3><a class="subsection-title" href="#parameters" name="parameters">Parameters</a></h3>
<table border="1" class="table">
<colgroup>
<col width="19%" />
<col width="43%" />
<col width="38%" />
</colgroup>
<thead valign="bottom">
<tr><th>Parameter</th>
<th>Requirement</th>
<th>Description</th>
</tr>
</thead>
<tbody valign="top">
<tr><td><tt class="literal"><span class="pre">pred</span></tt></td>
<td>Boolean nullary <a class="reference" href="./metafunction.html">Metafunction</a></td>
<td>A predicate to be asserted.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="assert-expression-semantics">
<h3><a class="subsection-title" href="#expression-semantics" name="expression-semantics">Expression semantics</a></h3>
<p>For any boolean nullary <a class="reference" href="./metafunction.html">Metafunction</a> <tt class="literal"><span class="pre">pred</span></tt>:</p>
<pre class="literal-block">
<a href="./assert.html" class="identifier">BOOST_MPL_ASSERT</a>(( pred ));
</pre>
<table class="field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Return type:</th><td class="field-body">None.</td>
</tr>
<tr class="field"><th class="field-name">Semantics:</th><td class="field-body"><p class="first">Generates a compilation error if <tt class="literal"><span class="pre">pred::type::value</span> <span class="pre">!=</span> <span class="pre">true</span></tt>, otherwise
has no effect. Note that double parentheses are required even if no commas
appear in the condition.</p>
<p>When possible within the compiler's diagnostic capabilities,
the error message will include the predicate's full type name, and have a
general form of:</p>
<pre class="last literal-block">
<em>...</em> ************ pred::************ <em>...</em>
</pre>
</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="assert-example">
<h3><a class="subsection-title" href="#example" name="example">Example</a></h3>
<pre class="literal-block">
template&lt; typename T, typename U &gt; struct my
{
// ...
<a href="./assert.html" class="identifier">BOOST_MPL_ASSERT</a>(( is_same&lt; T,U &gt; ));
};
my&lt;void*,char*&gt; test;
// In instantiation of `my&lt;void, char*&gt;':
// instantiated from here
// conversion from `
// mpl_::failed************boost::is_same&lt;void, char*&gt;::************' to
// non-scalar type `mpl_::assert&lt;false&gt;' requested
</pre>
</div>
<div class="section" id="assert-see-also">
<h3><a class="subsection-title" href="#see-also" name="see-also">See also</a></h3>
<p><a class="reference" href="./asserts.html">Asserts</a>, <a class="refentry reference" href="./assert-not.html"><tt class="refentry literal"><span class="pre">BOOST_MPL_ASSERT_NOT</span></tt></a>, <a class="refentry reference" href="./assert-msg.html"><tt class="refentry literal"><span class="pre">BOOST_MPL_ASSERT_MSG</span></tt></a>, <a class="refentry reference" href="./assert-relation.html"><tt class="refentry literal"><span class="pre">BOOST_MPL_ASSERT_RELATION</span></tt></a></p>
<!-- modtime: November 10, 2004 04:45:28 +0000 -->
<!-- Macros/Asserts//BOOST_MPL_ASSERT_MSG -->
</div>
</div>
<div class="footer-separator"></div>
<table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./asserts.html" class="navigation-link">Prev</a>&nbsp;<a href="./assert-msg.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group">Back&nbsp;<a href="./assert-msg.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./asserts.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>
</tr></table></body>
</html>
+33
View File
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.3.6: http://docutils.sourceforge.net/" />
<title>The MPL Reference Manual: Asserts</title>
<link rel="stylesheet" href="../style.css" type="text/css" />
</head>
<body class="docframe refmanual">
<table class="header"><tr class="header"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./macros.html" class="navigation-link">Prev</a>&nbsp;<a href="./assert.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group">Back&nbsp;<a href="./introspection.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./macros.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>
<td class="header-group page-location"><a href="../refmanual.html" class="navigation-link">Front Page</a> / <a href="./macros.html" class="navigation-link">Macros</a> / <a href="./asserts.html" class="navigation-link">Asserts</a></td>
</tr></table><div class="header-separator"></div>
<div class="section" id="asserts">
<h1><a class="toc-backref" href="./macros.html#id510" name="asserts">Asserts</a></h1>
<a class="target" id="label-macros-asserts" name="label-macros-asserts"></a><p>The MPL supplies a suite of static assertion macros that are specifically
designed to generate maximally useful and informative error messages
within the diagnostic capabilities of each compiler.</p>
<p>All assert macros can be used at class, function, or namespace scope.</p>
<!-- modtime: November 05, 2004 07:25:45 +0000 -->
<!-- Macros/Asserts//BOOST_MPL_ASSERT -->
<ul class="toc simple" id="outline">
<li><a class="reference" href="./assert.html" id="id511" name="id511">BOOST_MPL_ASSERT</a></li>
<li><a class="reference" href="./assert-msg.html" id="id512" name="id512">BOOST_MPL_ASSERT_MSG</a></li>
<li><a class="reference" href="./assert-not.html" id="id513" name="id513">BOOST_MPL_ASSERT_NOT</a></li>
<li><a class="reference" href="./assert-relation.html" id="id514" name="id514">BOOST_MPL_ASSERT_RELATION</a></li>
</ul>
</div>
<div class="footer-separator"></div>
<table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./macros.html" class="navigation-link">Prev</a>&nbsp;<a href="./assert.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group">Back&nbsp;<a href="./introspection.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./macros.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>
</tr></table></body>
</html>
+156
View File
@@ -0,0 +1,156 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.3.6: http://docutils.sourceforge.net/" />
<title>The MPL Reference Manual: Associative Sequence</title>
<link rel="stylesheet" href="../style.css" type="text/css" />
</head>
<body class="docframe refmanual">
<table class="header"><tr class="header"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./back-extensible-sequence.html" class="navigation-link">Prev</a>&nbsp;<a href="./extensible-associative.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./back-extensible-sequence.html" class="navigation-link">Back</a>&nbsp;<a href="./extensible-associative.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./concepts.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>
<td class="header-group page-location"><a href="../refmanual.html" class="navigation-link">Front Page</a> / <a href="./sequences.html" class="navigation-link">Sequences</a> / <a href="./concepts.html" class="navigation-link">Concepts</a> / <a href="./associative-sequence.html" class="navigation-link">Associative Sequence</a></td>
</tr></table><div class="header-separator"></div>
<div class="section" id="associative-sequence">
<h1><a class="toc-backref" href="./concepts.html#id330" name="associative-sequence">Associative Sequence</a></h1>
<div class="section" id="associative-description">
<h3><a class="subsection-title" href="#description" name="description">Description</a></h3>
<p>An <a class="reference" href="./associative-sequence.html">Associative Sequence</a> is a <a class="reference" href="./forward-sequence.html">Forward Sequence</a> that allows efficient retrieval of
elements based on keys. Unlike associative containers in the C++ Standard Library,
MPL associative sequences have no associated ordering relation. Instead,
<em>type identity</em> is used to impose an equivalence relation on keys, and the
order in which sequence elements are traversed during iteration is left
unspecified.</p>
</div>
<div class="section" id="associative-definitions">
<h3><a class="subsection-title" href="#definitions" name="definitions">Definitions</a></h3>
<a class="target" id="key-part" name="key-part"></a><a class="target" id="value-part" name="value-part"></a><ul class="simple">
<li>A <em>key</em> is a part of the element type used to identify and retrieve
the element within the sequence.</li>
<li>A <em>value</em> is a part of the element type retrievied from the sequence
by its key.</li>
</ul>
</div>
<div class="section" id="associative-expression-requirements">
<h3><a class="subsection-title" href="#expression-requirements" name="expression-requirements">Expression requirements</a></h3>
<p>In the following table and subsequent specifications, <tt class="literal"><span class="pre">s</span></tt> is an <a class="reference" href="./associative-sequence.html">Associative Sequence</a>,
<tt class="literal"><span class="pre">x</span></tt> is a sequence element, and <tt class="literal"><span class="pre">k</span></tt> and <tt class="literal"><span class="pre">def</span></tt> are arbitrary types.</p>
<p>In addition to the requirements defined in <a class="reference" href="./forward-sequence.html">Forward Sequence</a>,
the following must be met:</p>
<table border="1" class="table">
<colgroup>
<col width="33%" />
<col width="38%" />
<col width="29%" />
</colgroup>
<thead valign="bottom">
<tr><th>Expression</th>
<th>Type</th>
<th>Complexity</th>
</tr>
</thead>
<tbody valign="top">
<tr><td><tt class="literal"><span class="pre"><a href="./has-key.html" class="identifier">has_key</a>&lt;s,k&gt;::type</span></tt></td>
<td>Boolean <a class="reference" href="./integral-constant.html">Integral Constant</a></td>
<td>Amortized constant time</td>
</tr>
<tr><td><tt class="literal"><span class="pre"><a href="./count.html" class="identifier">count</a>&lt;s,k&gt;::type</span></tt></td>
<td><a class="reference" href="./integral-constant.html">Integral Constant</a></td>
<td>Amortized constant time</td>
</tr>
<tr><td><tt class="literal"><span class="pre"><a href="./order.html" class="identifier">order</a>&lt;s,k&gt;::type</span></tt></td>
<td><a class="reference" href="./integral-constant.html">Integral Constant</a> or <tt class="literal"><span class="pre"><a href="./void.html" class="identifier">void_</a></span></tt></td>
<td>Amortized constant time</td>
</tr>
<tr><td><tt class="literal"><span class="pre"><a href="./at.html" class="identifier">at</a>&lt;s,k&gt;::type</span></tt></td>
<td>Any type</td>
<td>Amortized constant time</td>
</tr>
<tr><td><tt class="literal"><span class="pre"><a href="./at.html" class="identifier">at</a>&lt;s,k,def&gt;::type</span></tt></td>
<td>Any type</td>
<td>Amortized constant time</td>
</tr>
<tr><td><tt class="literal"><span class="pre"><a href="./key-type.html" class="identifier">key_type</a>&lt;s,x&gt;::type</span></tt></td>
<td>Any type</td>
<td>Amortized constant time</td>
</tr>
<tr><td><tt class="literal"><span class="pre"><a href="./value-type.html" class="identifier">value_type</a>&lt;s,x&gt;::type</span></tt></td>
<td>Any type</td>
<td>Amortized constant time</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="associative-expression-semantics">
<h3><a class="subsection-title" href="#expression-semantics" name="expression-semantics">Expression semantics</a></h3>
<p>The semantics of an expression are defined only
where they differ from, or are not defined in <a class="reference" href="./forward-sequence.html">Forward Sequence</a>.</p>
<table border="1" class="table">
<colgroup>
<col width="33%" />
<col width="67%" />
</colgroup>
<thead valign="bottom">
<tr><th>Expression</th>
<th>Semantics</th>
</tr>
</thead>
<tbody valign="top">
<tr><td><tt class="literal"><span class="pre"><a href="./has-key.html" class="identifier">has_key</a>&lt;s,k&gt;::type</span></tt></td>
<td>A boolean <a class="reference" href="./integral-constant.html">Integral Constant</a> <tt class="literal"><span class="pre">c</span></tt> such that
<tt class="literal"><span class="pre">c::value</span> <span class="pre">==</span> <span class="pre">true</span></tt> if and only if there is one or more
elements with the key <tt class="literal"><span class="pre">k</span></tt> in <tt class="literal"><span class="pre">s</span></tt>; see <a class="refentry reference" href="./has-key.html"><tt class="refentry literal"><span class="pre">has_key</span></tt></a>.</td>
</tr>
<tr><td><tt class="literal"><span class="pre"><a href="./count.html" class="identifier">count</a>&lt;s,k&gt;::type</span></tt></td>
<td>The number of elements with the key <tt class="literal"><span class="pre">k</span></tt> in <tt class="literal"><span class="pre">s</span></tt>;
see <a class="refentry reference" href="./count.html"><tt class="refentry literal"><span class="pre">count</span></tt></a>.</td>
</tr>
<tr><td><tt class="literal"><span class="pre"><a href="./order.html" class="identifier">order</a>&lt;s,k&gt;::type</span></tt></td>
<td>A unique unsigned <a class="reference" href="./integral-constant.html">Integral Constant</a> associated
with the key <tt class="literal"><span class="pre">k</span></tt> in the sequence <tt class="literal"><span class="pre">s</span></tt>; see <a class="refentry reference" href="./order.html"><tt class="refentry literal"><span class="pre">order</span></tt></a>.</td>
</tr>
<tr><td><pre class="first last literal-block">
<a href="./at.html" class="identifier">at</a>&lt;s,k&gt;::type
<a href="./at.html" class="identifier">at</a>&lt;s,k,def&gt;::type
</pre>
</td>
<td>The first element associated with the key <tt class="literal"><span class="pre">k</span></tt>
in the sequence <tt class="literal"><span class="pre">s</span></tt>; see <a class="refentry reference" href="./at.html"><tt class="refentry literal"><span class="pre">at</span></tt></a>.</td>
</tr>
<tr><td><tt class="literal"><span class="pre"><a href="./key-type.html" class="identifier">key_type</a>&lt;s,x&gt;::type</span></tt></td>
<td>The key part of the element <tt class="literal"><span class="pre">x</span></tt> that would be
used to identify <tt class="literal"><span class="pre">x</span></tt> in <tt class="literal"><span class="pre">s</span></tt>; see <a class="refentry reference" href="./key-type.html"><tt class="refentry literal"><span class="pre">key_type</span></tt></a>.</td>
</tr>
<tr><td><tt class="literal"><span class="pre"><a href="./value-type.html" class="identifier">value_type</a>&lt;s,x&gt;::type</span></tt></td>
<td>The value part of the element <tt class="literal"><span class="pre">x</span></tt> that would be
used for <tt class="literal"><span class="pre">x</span></tt> in <tt class="literal"><span class="pre">s</span></tt>; see <a class="refentry reference" href="./value-type.html"><tt class="refentry literal"><span class="pre">value_type</span></tt></a>.</td>
</tr>
</tbody>
</table>
<!-- Invariants
- - - - - - - - - -
For any associative sequence ``s`` the following invariants always hold:
* ??? -->
</div>
<div class="section" id="associative-models">
<h3><a class="subsection-title" href="#models" name="models">Models</a></h3>
<ul class="simple">
<li><a class="refentry reference" href="./set.html"><tt class="refentry literal"><span class="pre">set</span></tt></a></li>
<li><a class="refentry reference" href="./map.html"><tt class="refentry literal"><span class="pre">map</span></tt></a></li>
</ul>
<!-- * |multiset| -->
</div>
<div class="section" id="associative-see-also">
<h3><a class="subsection-title" href="#see-also" name="see-also">See also</a></h3>
<p><a class="reference" href="./sequences.html">Sequences</a>, <a class="reference" href="./extensible-associative.html">Extensible Associative Sequence</a>, <a class="refentry reference" href="./has-key.html"><tt class="refentry literal"><span class="pre">has_key</span></tt></a>, <a class="refentry reference" href="./count.html"><tt class="refentry literal"><span class="pre">count</span></tt></a>, <a class="refentry reference" href="./order.html"><tt class="refentry literal"><span class="pre">order</span></tt></a>, <a class="refentry reference" href="./at.html"><tt class="refentry literal"><span class="pre">at</span></tt></a>, <a class="refentry reference" href="./key-type.html"><tt class="refentry literal"><span class="pre">key_type</span></tt></a>, <a class="refentry reference" href="./value-type.html"><tt class="refentry literal"><span class="pre">value_type</span></tt></a></p>
<!-- modtime: November 13, 2004 00:51:14 +0000 -->
<!-- Sequences/Concepts//Extensible Associative Sequence |80 -->
</div>
</div>
<div class="footer-separator"></div>
<table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./back-extensible-sequence.html" class="navigation-link">Prev</a>&nbsp;<a href="./extensible-associative.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./back-extensible-sequence.html" class="navigation-link">Back</a>&nbsp;<a href="./extensible-associative.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./concepts.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>
</tr></table></body>
</html>
+132
View File
@@ -0,0 +1,132 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.3.6: http://docutils.sourceforge.net/" />
<title>The MPL Reference Manual: at_c</title>
<link rel="stylesheet" href="../style.css" type="text/css" />
</head>
<body class="docframe refmanual">
<table class="header"><tr class="header"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./at.html" class="navigation-link">Prev</a>&nbsp;<a href="./back.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./at.html" class="navigation-link">Back</a>&nbsp;<a href="./back.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./intrinsic-metafunctions.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>
<td class="header-group page-location"><a href="../refmanual.html" class="navigation-link">Front Page</a> / <a href="./sequences.html" class="navigation-link">Sequences</a> / <a href="./intrinsic-metafunctions.html" class="navigation-link">Intrinsic Metafunctions</a> / <a href="./at-c.html" class="navigation-link">at_c</a></td>
</tr></table><div class="header-separator"></div>
<div class="section" id="at-c">
<h1><a class="toc-backref" href="./intrinsic-metafunctions.html#id354" name="at-c">at_c</a></h1>
<div class="section" id="intrinsic-at-synopsis">
<h3><a class="subsection-title" href="#synopsis" name="synopsis">Synopsis</a></h3>
<pre class="literal-block">
template&lt;
typename Sequence
, long n
&gt;
struct <a href="./at-c.html" class="identifier">at_c</a>
{
typedef <em>unspecified</em> type;
};
</pre>
</div>
<div class="section" id="intrinsic-at-description">
<h3><a class="subsection-title" href="#description" name="description">Description</a></h3>
<p>Returns a type identical to the <tt class="literal"><span class="pre">n</span></tt>th element from the beginning of
the sequence. <tt class="literal"><span class="pre"><a href="./at-c.html" class="identifier">at_c</a>&lt;Sequence,n&gt;::type</span></tt> is a shorcut notation for
<tt class="literal"><span class="pre"><a href="./at.html" class="identifier">at</a>&lt;</span> <span class="pre">Sequence,</span> <span class="pre"><a href="./long.html" class="identifier">long_</a>&lt;n&gt;</span> <span class="pre">&gt;::type</span></tt>.</p>
</div>
<div class="section" id="intrinsic-at-header">
<h3><a class="subsection-title" href="#header" name="header">Header</a></h3>
<pre class="literal-block">
#include &lt;<a href="../../../../boost/mpl/at.hpp" class="header">boost/mpl/at.hpp</a>&gt;
</pre>
</div>
<div class="section" id="intrinsic-at-parameters">
<h3><a class="subsection-title" href="#parameters" name="parameters">Parameters</a></h3>
<table border="1" class="table">
<colgroup>
<col width="15%" />
<col width="36%" />
<col width="48%" />
</colgroup>
<thead valign="bottom">
<tr><th>Parameter</th>
<th>Requirement</th>
<th>Description</th>
</tr>
</thead>
<tbody valign="top">
<tr><td><tt class="literal"><span class="pre">Sequence</span></tt></td>
<td><a class="reference" href="./forward-sequence.html">Forward Sequence</a></td>
<td>A sequence to be examined.</td>
</tr>
<tr><td><tt class="literal"><span class="pre">n</span></tt></td>
<td>A compile-time integral constant</td>
<td>An offset from the beginning of the sequence
specifying the element to be retrieved.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="intrinsic-at-expression-semantics">
<h3><a class="subsection-title" href="#expression-semantics" name="expression-semantics">Expression semantics</a></h3>
<pre class="literal-block">
typedef <a href="./at-c.html" class="identifier">at_c</a>&lt;Sequence,n&gt;::type t;
</pre>
<table class="field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Return type:</th><td class="field-body">A type</td>
</tr>
<tr class="field"><th class="field-name">Precondition:</th><td class="field-body"><tt class="literal"><span class="pre">0</span> <span class="pre">&lt;=</span> <span class="pre">n</span> <span class="pre">&lt;</span> <span class="pre"><a href="./size.html" class="identifier">size</a>&lt;Sequence&gt;::value</span></tt></td>
</tr>
<tr class="field"><th class="field-name">Semantics:</th><td class="field-body"><p class="first">Equivalent to</p>
<pre class="last literal-block">
typedef <a href="./at.html" class="identifier">at</a>&lt; Sequence, <a href="./long.html" class="identifier">long_</a>&lt;n&gt; &gt;::type t;
</pre>
</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="at-complexity">
<h3><a class="subsection-title" href="#complexity" name="complexity">Complexity</a></h3>
<table border="1" class="table">
<colgroup>
<col width="47%" />
<col width="53%" />
</colgroup>
<thead valign="bottom">
<tr><th>Sequence archetype</th>
<th>Complexity</th>
</tr>
</thead>
<tbody valign="top">
<tr><td><a class="reference" href="./forward-sequence.html">Forward Sequence</a></td>
<td>Linear.</td>
</tr>
<tr><td><a class="reference" href="./random-access-sequence.html">Random Access Sequence</a></td>
<td>Amortized constant time.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="intrinsic-at-example">
<h3><a class="subsection-title" href="#example" name="example">Example</a></h3>
<pre class="literal-block">
typedef <a href="./range-c.html" class="identifier">range_c</a>&lt;long,10,50&gt; range;
<a href="./assert-relation.html" class="identifier">BOOST_MPL_ASSERT_RELATION</a>( (<a href="./at-c.html" class="identifier">at_c</a>&lt; range,0 &gt;::value), ==, 10 );
<a href="./assert-relation.html" class="identifier">BOOST_MPL_ASSERT_RELATION</a>( (<a href="./at-c.html" class="identifier">at_c</a>&lt; range,10 &gt;::value), ==, 20 );
<a href="./assert-relation.html" class="identifier">BOOST_MPL_ASSERT_RELATION</a>( (<a href="./at-c.html" class="identifier">at_c</a>&lt; range,40 &gt;::value), ==, 50 );
</pre>
</div>
<div class="section" id="intrinsic-at-see-also">
<h3><a class="subsection-title" href="#see-also" name="see-also">See also</a></h3>
<p><a class="reference" href="./forward-sequence.html">Forward Sequence</a>, <a class="reference" href="./random-access-sequence.html">Random Access Sequence</a>, <a class="refentry reference" href="./at.html"><tt class="refentry literal"><span class="pre">at</span></tt></a>, <a class="refentry reference" href="./front.html"><tt class="refentry literal"><span class="pre">front</span></tt></a>, <a class="refentry reference" href="./back.html"><tt class="refentry literal"><span class="pre">back</span></tt></a></p>
<!-- modtime: November 13, 2004 01:23:57 +0000 -->
<!-- Sequences/Intrinsic Metafunctions//back -->
</div>
</div>
<div class="footer-separator"></div>
<table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./at.html" class="navigation-link">Prev</a>&nbsp;<a href="./back.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./at.html" class="navigation-link">Back</a>&nbsp;<a href="./back.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./intrinsic-metafunctions.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>
</tr></table></body>
</html>
+211
View File
@@ -0,0 +1,211 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.3.6: http://docutils.sourceforge.net/" />
<title>The MPL Reference Manual: at</title>
<link rel="stylesheet" href="../style.css" type="text/css" />
</head>
<body class="docframe refmanual">
<table class="header"><tr class="header"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./intrinsic-metafunctions.html" class="navigation-link">Prev</a>&nbsp;<a href="./at-c.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group">Back&nbsp;<a href="./at-c.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./intrinsic-metafunctions.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>
<td class="header-group page-location"><a href="../refmanual.html" class="navigation-link">Front Page</a> / <a href="./sequences.html" class="navigation-link">Sequences</a> / <a href="./intrinsic-metafunctions.html" class="navigation-link">Intrinsic Metafunctions</a> / <a href="./at.html" class="navigation-link">at</a></td>
</tr></table><div class="header-separator"></div>
<div class="section" id="at">
<h1><a class="toc-backref" href="./intrinsic-metafunctions.html#id353" name="at">at</a></h1>
<div class="section" id="at-synopsis">
<h3><a class="subsection-title" href="#synopsis" name="synopsis">Synopsis</a></h3>
<pre class="literal-block">
template&lt;
typename Sequence
, typename N
&gt;
struct <a href="./at.html" class="identifier">at</a>
{
typedef <em>unspecified</em> type;
};
template&lt;
typename AssocSeq
, typename Key
, typename Default = <em>unspecified</em>
&gt;
struct <a href="./at.html" class="identifier">at</a>
{
typedef <em>unspecified</em> type;
};
</pre>
</div>
<div class="section" id="at-description">
<h3><a class="subsection-title" href="#description" name="description">Description</a></h3>
<p><tt class="literal"><span class="pre"><a href="./at.html" class="identifier">at</a></span></tt> is an <a class="reference" href="./terminology.html#overloaded-name">overloaded name</a>:</p>
<ul class="simple">
<li><tt class="literal"><span class="pre"><a href="./at.html" class="identifier">at</a>&lt;Sequence,N&gt;</span></tt> returns the <tt class="literal"><span class="pre">N</span></tt>-th element from the beginning of the
<a class="reference" href="./forward-sequence.html">Forward Sequence</a> <tt class="literal"><span class="pre">Sequence</span></tt>.</li>
<li><tt class="literal"><span class="pre"><a href="./at.html" class="identifier">at</a>&lt;AssocSeq,Key,Default&gt;</span></tt> returns the first element associated with <tt class="literal"><span class="pre">Key</span></tt>
in the <a class="reference" href="./associative-sequence.html">Associative Sequence</a> <tt class="literal"><span class="pre">AssocSeq</span></tt>, or <tt class="literal"><span class="pre">Default</span></tt> if no such element
exists.</li>
</ul>
</div>
<div class="section" id="at-header">
<h3><a class="subsection-title" href="#header" name="header">Header</a></h3>
<pre class="literal-block">
#include &lt;<a href="../../../../boost/mpl/at.hpp" class="header">boost/mpl/at.hpp</a>&gt;
</pre>
</div>
<div class="section" id="at-model-of">
<h3><a class="subsection-title" href="#model-of" name="model-of">Model of</a></h3>
<p><a class="reference" href="./tag-dispatched.html">Tag Dispatched Metafunction</a></p>
</div>
<div class="section" id="at-parameters">
<h3><a class="subsection-title" href="#parameters" name="parameters">Parameters</a></h3>
<table border="1" class="table">
<colgroup>
<col width="17%" />
<col width="30%" />
<col width="53%" />
</colgroup>
<thead valign="bottom">
<tr><th>Parameter</th>
<th>Requirement</th>
<th>Description</th>
</tr>
</thead>
<tbody valign="top">
<tr><td><tt class="literal"><span class="pre">Sequence</span></tt></td>
<td><a class="reference" href="./forward-sequence.html">Forward Sequence</a></td>
<td>A sequence to be examined.</td>
</tr>
<tr><td><tt class="literal"><span class="pre">AssocSeq</span></tt></td>
<td><a class="reference" href="./associative-sequence.html">Associative Sequence</a></td>
<td>A sequence to be examined.</td>
</tr>
<tr><td><tt class="literal"><span class="pre">N</span></tt></td>
<td><a class="reference" href="./integral-constant.html">Integral Constant</a></td>
<td>An offset from the beginning of the sequence
specifying the element to be retrieved.</td>
</tr>
<tr><td><tt class="literal"><span class="pre">Key</span></tt></td>
<td>Any type</td>
<td>A key for the element to be retrieved.</td>
</tr>
<tr><td><tt class="literal"><span class="pre">Default</span></tt></td>
<td>Any type</td>
<td>A default value to return if the element is
not found.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="at-expression-semantics">
<h3><a class="subsection-title" href="#expression-semantics" name="expression-semantics">Expression semantics</a></h3>
<div class="expression-semantics compound">
<p class="compound-first">For any <a class="reference" href="./forward-sequence.html">Forward Sequence</a> <tt class="literal"><span class="pre">s</span></tt>, and <a class="reference" href="./integral-constant.html">Integral Constant</a> <tt class="literal"><span class="pre">n</span></tt>:</p>
<pre class="compound-middle literal-block">
typedef <a href="./at.html" class="identifier">at</a>&lt;s,n&gt;::type t;
</pre>
<table class="compound-last field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Return type:</th><td class="field-body">A type.</td>
</tr>
<tr class="field"><th class="field-name">Precondition:</th><td class="field-body"><tt class="literal"><span class="pre">0</span> <span class="pre">&lt;=</span> <span class="pre">n::value</span> <span class="pre">&lt;</span> <span class="pre"><a href="./size.html" class="identifier">size</a>&lt;s&gt;::value</span></tt>.</td>
</tr>
<tr class="field"><th class="field-name">Semantics:</th><td class="field-body"><p class="first">Equivalent to</p>
<pre class="last literal-block">
typedef <a href="./deref.html" class="identifier">deref</a>&lt; <a href="./advance.html" class="identifier">advance</a>&lt; <a href="./begin.html" class="identifier">begin</a>&lt;s&gt;::type,n &gt;::type &gt;::type t;
</pre>
</td>
</tr>
</tbody>
</table>
</div>
<div class="expression-semantics compound">
<p class="compound-first">For any <a class="reference" href="./associative-sequence.html">Associative Sequence</a> <tt class="literal"><span class="pre">s</span></tt>, and arbitrary types <tt class="literal"><span class="pre">key</span></tt> and <tt class="literal"><span class="pre">x</span></tt>:</p>
<pre class="compound-middle literal-block">
typedef <a href="./at.html" class="identifier">at</a>&lt;s,key,x&gt;::type t;
</pre>
<table class="compound-middle field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Return type:</th><td class="field-body">A type.</td>
</tr>
<tr class="field"><th class="field-name">Semantics:</th><td class="field-body">If <tt class="literal"><span class="pre"><a href="./has-key.html" class="identifier">has_key</a>&lt;s,key&gt;::value</span> <span class="pre">==</span> <span class="pre">true</span></tt>, <tt class="literal"><span class="pre">t</span></tt> is the value type associated with <tt class="literal"><span class="pre">key</span></tt>;
otherwise <tt class="literal"><span class="pre">t</span></tt> is identical to <tt class="literal"><span class="pre">x</span></tt>.</td>
</tr>
</tbody>
</table>
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<pre class="compound-middle literal-block">
typedef <a href="./at.html" class="identifier">at</a>&lt;s,key&gt;::type t;
</pre>
<table class="compound-last field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Return type:</th><td class="field-body">A type.</td>
</tr>
<tr class="field"><th class="field-name">Semantics:</th><td class="field-body"><p class="first">Equivalent to</p>
<pre class="last literal-block">
typedef <a href="./at.html" class="identifier">at</a>&lt;s,key,<a href="./void.html" class="identifier">void_</a>&gt;::type t;
</pre>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section" id="complexity">
<h3><a class="subsection-title" href="#complexity" name="complexity">Complexity</a></h3>
<table border="1" class="table">
<colgroup>
<col width="47%" />
<col width="53%" />
</colgroup>
<thead valign="bottom">
<tr><th>Sequence archetype</th>
<th>Complexity</th>
</tr>
</thead>
<tbody valign="top">
<tr><td><a class="reference" href="./forward-sequence.html">Forward Sequence</a></td>
<td>Linear.</td>
</tr>
<tr><td><a class="reference" href="./random-access-sequence.html">Random Access Sequence</a></td>
<td>Amortized constant time.</td>
</tr>
<tr><td><a class="reference" href="./associative-sequence.html">Associative Sequence</a></td>
<td>Amortized constant time.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="at-example">
<h3><a class="subsection-title" href="#example" name="example">Example</a></h3>
<pre class="literal-block">
typedef <a href="./range-c.html" class="identifier">range_c</a>&lt;long,10,50&gt; range;
<a href="./assert-relation.html" class="identifier">BOOST_MPL_ASSERT_RELATION</a>( (<a href="./at.html" class="identifier">at</a>&lt; range, <a href="./int.html" class="identifier">int_</a>&lt;0&gt; &gt;::value), ==, 10 );
<a href="./assert-relation.html" class="identifier">BOOST_MPL_ASSERT_RELATION</a>( (<a href="./at.html" class="identifier">at</a>&lt; range, <a href="./int.html" class="identifier">int_</a>&lt;10&gt; &gt;::value), ==, 20 );
<a href="./assert-relation.html" class="identifier">BOOST_MPL_ASSERT_RELATION</a>( (<a href="./at.html" class="identifier">at</a>&lt; range, <a href="./int.html" class="identifier">int_</a>&lt;40&gt; &gt;::value), ==, 50 );
</pre>
<pre class="literal-block">
typedef <a href="./set.html" class="identifier">set</a>&lt; int const,long*,double &gt; s;
<a href="./assert.html" class="identifier">BOOST_MPL_ASSERT</a>(( is_same&lt; <a href="./at.html" class="identifier">at</a>&lt;s,char&gt;::type, <a href="./void.html" class="identifier">void_</a> &gt; ));
<a href="./assert.html" class="identifier">BOOST_MPL_ASSERT</a>(( is_same&lt; <a href="./at.html" class="identifier">at</a>&lt;s,int&gt;::type, int > ));
</pre>
</div>
<div class="section" id="at-see-also">
<h3><a class="subsection-title" href="#see-also" name="see-also">See also</a></h3>
<p><a class="reference" href="./forward-sequence.html">Forward Sequence</a>, <a class="reference" href="./random-access-sequence.html">Random Access Sequence</a>, <a class="reference" href="./associative-sequence.html">Associative Sequence</a>, <a class="refentry reference" href="./at-c.html"><tt class="refentry literal"><span class="pre">at_c</span></tt></a>, <a class="refentry reference" href="./front.html"><tt class="refentry literal"><span class="pre">front</span></tt></a>, <a class="refentry reference" href="./back.html"><tt class="refentry literal"><span class="pre">back</span></tt></a></p>
<!-- modtime: November 13, 2004 01:23:02 +0000 -->
<!-- Sequences/Intrinsic Metafunctions//at_c -->
</div>
</div>
<div class="footer-separator"></div>
<table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./intrinsic-metafunctions.html" class="navigation-link">Prev</a>&nbsp;<a href="./at-c.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group">Back&nbsp;<a href="./at-c.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./intrinsic-metafunctions.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>
</tr></table></body>
</html>
+120
View File
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.3.6: http://docutils.sourceforge.net/" />
<title>The MPL Reference Manual: BOOST_MPL_AUX_LAMBDA_SUPPORT</title>
<link rel="stylesheet" href="../style.css" type="text/css" />
</head>
<body class="docframe refmanual">
<table class="header"><tr class="header"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./broken-compiler.html" class="navigation-link">Prev</a>&nbsp;<a href="./terminology.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group">Back&nbsp;Along</span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./broken-compiler.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>
<td class="header-group page-location"><a href="../refmanual.html" class="navigation-link">Front Page</a> / <a href="./macros.html" class="navigation-link">Macros</a> / <a href="./broken-compiler.html" class="navigation-link">Broken Compiler Workarounds</a> / <a href="./aux-lambda-support.html" class="navigation-link">BOOST_MPL_AUX_LAMBDA_SUPPORT</a></td>
</tr></table><div class="header-separator"></div>
<div class="section" id="aux-lambda-support">
<h1><a class="toc-backref" href="./broken-compiler.html#id528" name="aux-lambda-support">BOOST_MPL_AUX_LAMBDA_SUPPORT</a></h1>
<div class="section" id="aux-synopsis">
<h3><a class="subsection-title" href="#synopsis" name="synopsis">Synopsis</a></h3>
<pre class="literal-block">
#define <a href="./aux-lambda-support.html" class="identifier">BOOST_MPL_AUX_LAMBDA_SUPPORT</a>(arity, fun, params) \
<em>unspecified token sequence</em> \
/**/
</pre>
</div>
<div class="section" id="aux-description">
<h3><a class="subsection-title" href="#description" name="description">Description</a></h3>
<p>Enables metafunction <tt class="literal"><span class="pre">fun</span></tt> for the use in <a class="reference" href="./lambda-expression.html">Lambda Expression</a>s on
compilers that don't support partial template specialization or/and
template template parameters. Expands to nothing on conforming compilers.</p>
</div>
<div class="section" id="aux-header">
<h3><a class="subsection-title" href="#header" name="header">Header</a></h3>
<pre class="literal-block">
#include &lt;<a href="../../../../boost/mpl/aux_/lambda_support.hpp" class="header">boost/mpl/aux_/lambda_support.hpp</a>&gt;
</pre>
</div>
<div class="section" id="aux-parameters">
<h3><a class="subsection-title" href="#parameters" name="parameters">Parameters</a></h3>
<table border="1" class="table">
<colgroup>
<col width="15%" />
<col width="32%" />
<col width="53%" />
</colgroup>
<thead valign="bottom">
<tr><th>Parameter</th>
<th>Requirement</th>
<th>Description</th>
</tr>
</thead>
<tbody valign="top">
<tr><td><tt class="literal"><span class="pre">arity</span></tt></td>
<td>An integral constant</td>
<td>The metafunction's arity, i.e. the number of its
template parameters, including the defaults.</td>
</tr>
<tr><td><tt class="literal"><span class="pre">fun</span></tt></td>
<td>A legal identifier token</td>
<td>The metafunction's name.</td>
</tr>
<tr><td><tt class="literal"><span class="pre">params</span></tt></td>
<td>A <a class="reference" href="http://www.boost.org/libs/preprocessor/doc/data/tuples.html" target="_top">PP-tuple</a></td>
<td>A tuple of the metafunction's parameter names, in
their original order, including the defaults.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="aux-expression-semantics">
<h3><a class="subsection-title" href="#expression-semantics" name="expression-semantics">Expression semantics</a></h3>
<p>For any integral constant <tt class="literal"><span class="pre">n</span></tt>, a <a class="reference" href="./metafunction.html">Metafunction</a> <tt class="literal"><span class="pre">fun</span></tt>, and arbitrary types <tt class="literal"><span class="pre">A1</span></tt>,... <tt class="literal"><span class="pre">An</span></tt>:</p>
<pre class="literal-block">
template&lt; typename A1,<em>...</em> typename A<em>n</em> &gt; struct fun
{
// <em>...</em>
<a href="./aux-lambda-support.html" class="identifier">BOOST_MPL_AUX_LAMBDA_SUPPORT</a>(n, fun, (A1,<em>...</em>A<em>n</em>))
};
</pre>
<table class="field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Precondition:</th><td class="field-body">Appears in <tt class="literal"><span class="pre">fun</span></tt>'s scope, immediately followed by the scope-closing
bracket (<tt class="literal"><span class="pre">}</span></tt>).</td>
</tr>
<tr class="field"><th class="field-name">Return type:</th><td class="field-body">None.</td>
</tr>
<tr class="field"><th class="field-name">Semantics:</th><td class="field-body">Expands to nothing and has no effect on conforming compilers. On compilers that
don't support partial template specialization or/and template template parameters
expands to an unspecified token sequence enabling <tt class="literal"><span class="pre">fun</span></tt> to participate in
<a class="reference" href="./lambda-expression.html">Lambda Expression</a>s with the semantics described in this manual.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="aux-example">
<h3><a class="subsection-title" href="#example" name="example">Example</a></h3>
<pre class="literal-block">
template&lt; typename T, typename U = int &gt; struct f
{
typedef T type[sizeof(U)];
<a href="./aux-lambda-support.html" class="identifier">BOOST_MPL_AUX_LAMBDA_SUPPORT</a>(2, f, (T,U))
};
typedef <a href="./apply.html" class="identifier">apply</a><tt class="literal"><span class="pre">1</span></tt>&lt; f&lt;char,_1&gt;,long &gt;::type r;
<a href="./assert.html" class="identifier">BOOST_MPL_ASSERT</a>(( is_same&lt; r, char[sizeof(long)] > ));
</pre>
</div>
<div class="section" id="aux-see-also">
<h3><a class="subsection-title" href="#see-also" name="see-also">See also</a></h3>
<p><a class="reference" href="./macros.html">Macros</a>, <a class="reference" href="./metafunctions.html">Metafunctions</a>, <a class="reference" href="./lambda-expression.html">Lambda Expression</a></p>
<!-- modtime: November 10, 2004 04:45:01 +0000 -->
</div>
</div>
<div class="footer-separator"></div>
<table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./broken-compiler.html" class="navigation-link">Prev</a>&nbsp;<a href="./terminology.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group">Back&nbsp;Along</span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./broken-compiler.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>
</tr></table></body>
</html>
+104
View File
@@ -0,0 +1,104 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.3.6: http://docutils.sourceforge.net/" />
<title>The MPL Reference Manual: Back Extensible Sequence</title>
<link rel="stylesheet" href="../style.css" type="text/css" />
</head>
<body class="docframe refmanual">
<table class="header"><tr class="header"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./front-extensible-sequence.html" class="navigation-link">Prev</a>&nbsp;<a href="./associative-sequence.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./front-extensible-sequence.html" class="navigation-link">Back</a>&nbsp;<a href="./associative-sequence.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./concepts.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>
<td class="header-group page-location"><a href="../refmanual.html" class="navigation-link">Front Page</a> / <a href="./sequences.html" class="navigation-link">Sequences</a> / <a href="./concepts.html" class="navigation-link">Concepts</a> / <a href="./back-extensible-sequence.html" class="navigation-link">Back Extensible Sequence</a></td>
</tr></table><div class="header-separator"></div>
<div class="section" id="back-extensible-sequence">
<h1><a class="toc-backref" href="./concepts.html#id329" name="back-extensible-sequence">Back Extensible Sequence</a></h1>
<div class="section" id="back-description">
<h3><a class="subsection-title" href="#description" name="description">Description</a></h3>
<p>A <a class="reference" href="./back-extensible-sequence.html">Back Extensible Sequence</a> is an <a class="reference" href="./extensible-sequence.html">Extensible Sequence</a> that supports amortized constant
time insertion and removal operations at the end.</p>
</div>
<div class="section" id="back-refinement-of">
<h3><a class="subsection-title" href="#refinement-of" name="refinement-of">Refinement of</a></h3>
<p><a class="reference" href="./extensible-sequence.html">Extensible Sequence</a></p>
</div>
<div class="section" id="back-expression-requirements">
<h3><a class="subsection-title" href="#expression-requirements" name="expression-requirements">Expression requirements</a></h3>
<p>In addition to the requirements defined in <a class="reference" href="./extensible-sequence.html">Extensible Sequence</a>,
for any <a class="reference" href="./back-extensible-sequence.html">Back Extensible Sequence</a> <tt class="literal"><span class="pre">s</span></tt> the following must be met:</p>
<table border="1" class="table">
<colgroup>
<col width="35%" />
<col width="35%" />
<col width="30%" />
</colgroup>
<thead valign="bottom">
<tr><th>Expression</th>
<th>Type</th>
<th>Complexity</th>
</tr>
</thead>
<tbody valign="top">
<tr><td><tt class="literal"><span class="pre"><a href="./push-back.html" class="identifier">push_back</a>&lt;s,x&gt;::type</span></tt></td>
<td><a class="reference" href="./back-extensible-sequence.html">Back Extensible Sequence</a></td>
<td>Amortized constant time</td>
</tr>
<tr><td><tt class="literal"><span class="pre"><a href="./pop-back.html" class="identifier">pop_back</a>&lt;s&gt;::type</span></tt></td>
<td><a class="reference" href="./back-extensible-sequence.html">Back Extensible Sequence</a></td>
<td>Amortized constant time</td>
</tr>
<tr><td><tt class="literal"><span class="pre"><a href="./back.html" class="identifier">back</a>&lt;s&gt;::type</span></tt></td>
<td>Any type</td>
<td>Amortized constant time</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="back-expression-semantics">
<h3><a class="subsection-title" href="#expression-semantics" name="expression-semantics">Expression semantics</a></h3>
<p>The semantics of an expression are defined only
where they differ from, or are not defined in <a class="reference" href="./extensible-sequence.html">Extensible Sequence</a>.</p>
<table border="1" class="table">
<colgroup>
<col width="34%" />
<col width="66%" />
</colgroup>
<thead valign="bottom">
<tr><th>Expression</th>
<th>Semantics</th>
</tr>
</thead>
<tbody valign="top">
<tr><td><tt class="literal"><span class="pre"><a href="./push-back.html" class="identifier">push_back</a>&lt;s,x&gt;::type</span></tt></td>
<td>Equivalent to <tt class="literal"><span class="pre"><a href="./insert.html" class="identifier">insert</a>&lt;s,<a href="./end.html" class="identifier">end</a>&lt;s&gt;::type,x&gt;::type</span></tt>;
see <a class="refentry reference" href="./push-back.html"><tt class="refentry literal"><span class="pre">push_back</span></tt></a>.</td>
</tr>
<tr><td><tt class="literal"><span class="pre"><a href="./pop-back.html" class="identifier">pop_back</a>&lt;v&gt;::type</span></tt></td>
<td>Equivalent to <tt class="literal"><span class="pre"><a href="./erase.html" class="identifier">erase</a>&lt;s,<a href="./end.html" class="identifier">end</a>&lt;s&gt;::type&gt;::type</span></tt>;
see <a class="refentry reference" href="./pop-back.html"><tt class="refentry literal"><span class="pre">pop_back</span></tt></a>.</td>
</tr>
<tr><td><tt class="literal"><span class="pre"><a href="./back.html" class="identifier">back</a>&lt;s&gt;::type</span></tt></td>
<td>The last element in the sequence; see <a class="refentry reference" href="./back.html"><tt class="refentry literal"><span class="pre">back</span></tt></a>.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="back-models">
<h3><a class="subsection-title" href="#models" name="models">Models</a></h3>
<ul class="simple">
<li><a class="refentry reference" href="./vector.html"><tt class="refentry literal"><span class="pre">vector</span></tt></a></li>
<li><a class="refentry reference" href="./deque.html"><tt class="refentry literal"><span class="pre">deque</span></tt></a></li>
</ul>
</div>
<div class="section" id="back-see-also">
<h3><a class="subsection-title" href="#see-also" name="see-also">See also</a></h3>
<p><a class="reference" href="./sequences.html">Sequences</a>, <a class="reference" href="./extensible-sequence.html">Extensible Sequence</a>, <a class="reference" href="./front-extensible-sequence.html">Front Extensible Sequence</a>, <a class="refentry reference" href="./push-back.html"><tt class="refentry literal"><span class="pre">push_back</span></tt></a>, <a class="refentry reference" href="./pop-back.html"><tt class="refentry literal"><span class="pre">pop_back</span></tt></a>, <a class="refentry reference" href="./back.html"><tt class="refentry literal"><span class="pre">back</span></tt></a></p>
<!-- modtime: November 10, 2004 04:27:21 +0000 -->
<!-- Sequences/Concepts//Associative Sequence |70 -->
</div>
</div>
<div class="footer-separator"></div>
<table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./front-extensible-sequence.html" class="navigation-link">Prev</a>&nbsp;<a href="./associative-sequence.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./front-extensible-sequence.html" class="navigation-link">Back</a>&nbsp;<a href="./associative-sequence.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./concepts.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>
</tr></table></body>
</html>
+117
View File
@@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.3.6: http://docutils.sourceforge.net/" />
<title>The MPL Reference Manual: back_inserter</title>
<link rel="stylesheet" href="../style.css" type="text/css" />
</head>
<body class="docframe refmanual">
<table class="header"><tr class="header"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./inserters.html" class="navigation-link">Prev</a>&nbsp;<a href="./front-inserter.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group">Back&nbsp;<a href="./front-inserter.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./inserters.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>
<td class="header-group page-location"><a href="../refmanual.html" class="navigation-link">Front Page</a> / <a href="./algorithms.html" class="navigation-link">Algorithms</a> / <a href="./inserters.html" class="navigation-link">Inserters</a> / <a href="./back-inserter.html" class="navigation-link">back_inserter</a></td>
</tr></table><div class="header-separator"></div>
<div class="section" id="back-inserter">
<h1><a class="toc-backref" href="./inserters.html#id393" name="back-inserter">back_inserter</a></h1>
<div class="section" id="inserters-back-synopsis">
<h3><a class="subsection-title" href="#synopsis" name="synopsis">Synopsis</a></h3>
<pre class="literal-block">
template&lt;
typename Seq
&gt;
struct <a href="./back-inserter.html" class="identifier">back_inserter</a>
{
// <em>unspecified</em>
// <em>...</em>
};
</pre>
</div>
<div class="section" id="inserters-back-description">
<h3><a class="subsection-title" href="#description" name="description">Description</a></h3>
<p>Inserts elements at the end of the sequence.</p>
</div>
<div class="section" id="inserters-back-header">
<h3><a class="subsection-title" href="#header" name="header">Header</a></h3>
<pre class="literal-block">
#include &lt;<a href="../../../../boost/mpl/back_inserter.hpp" class="header">boost/mpl/back_inserter.hpp</a>&gt;
</pre>
</div>
<div class="section" id="inserters-back-model-of">
<h3><a class="subsection-title" href="#model-of" name="model-of">Model of</a></h3>
<p><a class="reference" href="./inserter.html">Inserter</a></p>
</div>
<div class="section" id="inserters-back-parameters">
<h3><a class="subsection-title" href="#parameters" name="parameters">Parameters</a></h3>
<table border="1" class="table">
<colgroup>
<col width="18%" />
<col width="36%" />
<col width="46%" />
</colgroup>
<thead valign="bottom">
<tr><th>Parameter</th>
<th>Requirement</th>
<th>Description</th>
</tr>
</thead>
<tbody valign="top">
<tr><td><tt class="literal"><span class="pre">Seq</span></tt></td>
<td><a class="reference" href="./back-extensible-sequence.html">Back Extensible Sequence</a></td>
<td>A sequence to bind the inserter to.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="inserters-back-expression-semantics">
<h3><a class="subsection-title" href="#expression-semantics" name="expression-semantics">Expression semantics</a></h3>
<p>The semantics of an expression are defined only
where they differ from, or are not defined in <a class="reference" href="./inserter.html">Inserter</a>.</p>
<p>For any <a class="reference" href="./back-extensible-sequence.html">Back Extensible Sequence</a> <tt class="literal"><span class="pre">s</span></tt>:</p>
<table border="1" class="table">
<colgroup>
<col width="33%" />
<col width="67%" />
</colgroup>
<thead valign="bottom">
<tr><th>Expression</th>
<th>Semantics</th>
</tr>
</thead>
<tbody valign="top">
<tr><td><tt class="literal"><span class="pre"><a href="./back-inserter.html" class="identifier">back_inserter</a>&lt;s&gt;</span></tt></td>
<td><p class="first">An <a class="reference" href="./inserter.html">Inserter</a> <tt class="literal"><span class="pre">in</span></tt>, equivalent to</p>
<pre class="last literal-block">
struct in : <a href="./inserter.html" class="identifier">inserter</a>&lt;s,<a href="./push-back.html" class="identifier">push_back</a>&lt;_1,_2&gt; > {};
</pre>
</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="inserters-back-complexity">
<h3><a class="subsection-title" href="#complexity" name="complexity">Complexity</a></h3>
<p>Amortized constant time.</p>
</div>
<div class="section" id="inserters-back-example">
<h3><a class="subsection-title" href="#example" name="example">Example</a></h3>
<pre class="literal-block">
typedef <a href="./copy.html" class="identifier">copy</a>&lt;
<a href="./range-c.html" class="identifier">range_c</a>&lt;int,5,10&gt;
, <a href="./back-inserter.html" class="identifier">back_inserter</a>&lt; <a href="./vector-c.html" class="identifier">vector_c</a>&lt;int,0,1,2,3,4&gt; &gt;
&gt;::type range;
<a href="./assert.html" class="identifier">BOOST_MPL_ASSERT</a>(( <a href="./equal.html" class="identifier">equal</a>&lt; range, <a href="./range-c.html" class="identifier">range_c</a>&lt;int,0,10&gt; > ));
</pre>
</div>
<div class="section" id="inserters-back-see-also">
<h3><a class="subsection-title" href="#see-also" name="see-also">See also</a></h3>
<p><a class="reference" href="./algorithms.html">Algorithms</a>, <a class="reference" href="./inserter.html">Inserter</a>, <a class="reference" href="./reversible-algorithm.html">Reversible Algorithm</a>, <a class="refentry reference" href="./inserters-inserter.html"><tt class="refentry literal"><span class="pre">inserter</span></tt></a>, <a class="refentry reference" href="./front-inserter.html"><tt class="refentry literal"><span class="pre">front_inserter</span></tt></a>, <a class="refentry reference" href="./push-back.html"><tt class="refentry literal"><span class="pre">push_back</span></tt></a></p>
<!-- modtime: November 10, 2004 04:44:52 +0000 -->
<!-- Algorithms/Inserters//front_inserter -->
</div>
</div>
<div class="footer-separator"></div>
<table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./inserters.html" class="navigation-link">Prev</a>&nbsp;<a href="./front-inserter.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group">Back&nbsp;<a href="./front-inserter.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./inserters.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>
</tr></table></body>
</html>
+114
View File
@@ -0,0 +1,114 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.3.6: http://docutils.sourceforge.net/" />
<title>The MPL Reference Manual: back</title>
<link rel="stylesheet" href="../style.css" type="text/css" />
</head>
<body class="docframe refmanual">
<table class="header"><tr class="header"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./at-c.html" class="navigation-link">Prev</a>&nbsp;<a href="./begin.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./at-c.html" class="navigation-link">Back</a>&nbsp;<a href="./begin.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./intrinsic-metafunctions.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>
<td class="header-group page-location"><a href="../refmanual.html" class="navigation-link">Front Page</a> / <a href="./sequences.html" class="navigation-link">Sequences</a> / <a href="./intrinsic-metafunctions.html" class="navigation-link">Intrinsic Metafunctions</a> / <a href="./back.html" class="navigation-link">back</a></td>
</tr></table><div class="header-separator"></div>
<div class="section" id="back">
<h1><a class="toc-backref" href="./intrinsic-metafunctions.html#id355" name="back">back</a></h1>
<div class="section" id="back-synopsis">
<h3><a class="subsection-title" href="#synopsis" name="synopsis">Synopsis</a></h3>
<pre class="literal-block">
template&lt;
typename Sequence
&gt;
struct <a href="./back.html" class="identifier">back</a>
{
typedef <em>unspecified</em> type;
};
</pre>
</div>
<div class="section" id="intrinsic-back-description">
<h3><a class="subsection-title" href="#description" name="description">Description</a></h3>
<p>Returns the last element in the sequence.</p>
</div>
<div class="section" id="back-header">
<h3><a class="subsection-title" href="#header" name="header">Header</a></h3>
<pre class="literal-block">
#include &lt;<a href="../../../../boost/mpl/back.hpp" class="header">boost/mpl/back.hpp</a>&gt;
</pre>
</div>
<div class="section" id="back-model-of">
<h3><a class="subsection-title" href="#model-of" name="model-of">Model of</a></h3>
<p><a class="reference" href="./tag-dispatched.html">Tag Dispatched Metafunction</a></p>
</div>
<div class="section" id="back-parameters">
<h3><a class="subsection-title" href="#parameters" name="parameters">Parameters</a></h3>
<table border="1" class="table">
<colgroup>
<col width="19%" />
<col width="35%" />
<col width="45%" />
</colgroup>
<thead valign="bottom">
<tr><th>Parameter</th>
<th>Requirement</th>
<th>Description</th>
</tr>
</thead>
<tbody valign="top">
<tr><td><tt class="literal"><span class="pre">Sequence</span></tt></td>
<td><a class="reference" href="./bidirectional-sequence.html">Bidirectional Sequence</a></td>
<td>A sequence to be examined.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="intrinsic-back-expression-semantics">
<h3><a class="subsection-title" href="#expression-semantics" name="expression-semantics">Expression semantics</a></h3>
<p>For any <a class="reference" href="./bidirectional-sequence.html">Bidirectional Sequence</a> <tt class="literal"><span class="pre">s</span></tt>:</p>
<pre class="literal-block">
typedef <a href="./back.html" class="identifier">back</a>&lt;s&gt;::type t;
</pre>
<table class="field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Return type:</th><td class="field-body">A type.</td>
</tr>
<tr class="field"><th class="field-name">Precondition:</th><td class="field-body"><tt class="literal"><span class="pre"><a href="./empty.html" class="identifier">empty</a>&lt;s&gt;::value</span> <span class="pre">==</span> <span class="pre">false</span></tt>.</td>
</tr>
<tr class="field"><th class="field-name">Semantics:</th><td class="field-body"><p class="first">Equivalent to</p>
<pre class="last literal-block">
typedef <a href="./deref.html" class="identifier">deref</a>&lt; <a href="./prior.html" class="identifier">prior</a>&lt; <a href="./end.html" class="identifier">end</a>&lt;s&gt;::type &gt;::type &gt;::type t;
</pre>
</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="back-complexity">
<h3><a class="subsection-title" href="#complexity" name="complexity">Complexity</a></h3>
<p>Amortized constant time.</p>
</div>
<div class="section" id="back-example">
<h3><a class="subsection-title" href="#example" name="example">Example</a></h3>
<pre class="literal-block">
typedef <a href="./range-c.html" class="identifier">range_c</a>&lt;int,0,1&gt; range1;
typedef <a href="./range-c.html" class="identifier">range_c</a>&lt;int,0,10&gt; range2;
typedef <a href="./range-c.html" class="identifier">range_c</a>&lt;int,-10,0&gt; range3;
<a href="./assert-relation.html" class="identifier">BOOST_MPL_ASSERT_RELATION</a>( <a href="./back.html" class="identifier">back</a>&lt;range1&gt;::value, ==, 0 );
<a href="./assert-relation.html" class="identifier">BOOST_MPL_ASSERT_RELATION</a>( <a href="./back.html" class="identifier">back</a>&lt;range2&gt;::value, ==, 9 );
<a href="./assert-relation.html" class="identifier">BOOST_MPL_ASSERT_RELATION</a>( <a href="./back.html" class="identifier">back</a>&lt;range3&gt;::value, ==, -1 );
</pre>
</div>
<div class="section" id="intrinsic-back-see-also">
<h3><a class="subsection-title" href="#see-also" name="see-also">See also</a></h3>
<p><a class="reference" href="./bidirectional-sequence.html">Bidirectional Sequence</a>, <a class="refentry reference" href="./front.html"><tt class="refentry literal"><span class="pre">front</span></tt></a>, <a class="refentry reference" href="./push-back.html"><tt class="refentry literal"><span class="pre">push_back</span></tt></a>, <a class="refentry reference" href="./end.html"><tt class="refentry literal"><span class="pre">end</span></tt></a>, <a class="refentry reference" href="./deref.html"><tt class="refentry literal"><span class="pre">deref</span></tt></a>, <a class="refentry reference" href="./at.html"><tt class="refentry literal"><span class="pre">at</span></tt></a></p>
<!-- modtime: November 13, 2004 01:24:30 +0000 -->
<!-- Sequences/Intrinsic Metafunctions//begin -->
</div>
</div>
<div class="footer-separator"></div>
<table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./at-c.html" class="navigation-link">Prev</a>&nbsp;<a href="./begin.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./at-c.html" class="navigation-link">Back</a>&nbsp;<a href="./begin.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./intrinsic-metafunctions.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>
</tr></table></body>
</html>
+114
View File
@@ -0,0 +1,114 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.3.6: http://docutils.sourceforge.net/" />
<title>The MPL Reference Manual: begin</title>
<link rel="stylesheet" href="../style.css" type="text/css" />
</head>
<body class="docframe refmanual">
<table class="header"><tr class="header"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./back.html" class="navigation-link">Prev</a>&nbsp;<a href="./clear.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./back.html" class="navigation-link">Back</a>&nbsp;<a href="./clear.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./intrinsic-metafunctions.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>
<td class="header-group page-location"><a href="../refmanual.html" class="navigation-link">Front Page</a> / <a href="./sequences.html" class="navigation-link">Sequences</a> / <a href="./intrinsic-metafunctions.html" class="navigation-link">Intrinsic Metafunctions</a> / <a href="./begin.html" class="navigation-link">begin</a></td>
</tr></table><div class="header-separator"></div>
<div class="section" id="begin">
<h1><a class="toc-backref" href="./intrinsic-metafunctions.html#id356" name="begin">begin</a></h1>
<div class="section" id="begin-synopsis">
<h3><a class="subsection-title" href="#synopsis" name="synopsis">Synopsis</a></h3>
<pre class="literal-block">
template&lt;
typename X
&gt;
struct <a href="./begin.html" class="identifier">begin</a>
{
typedef <em>unspecified</em> type;
};
</pre>
</div>
<div class="section" id="begin-description">
<h3><a class="subsection-title" href="#description" name="description">Description</a></h3>
<p>Returns an iterator that points to the first element of the sequence. If
the argument is not a <a class="reference" href="./forward-sequence.html">Forward Sequence</a>, returns <a class="refentry reference" href="./void.html"><tt class="refentry literal"><span class="pre">void_</span></tt></a>.</p>
</div>
<div class="section" id="begin-header">
<h3><a class="subsection-title" href="#header" name="header">Header</a></h3>
<pre class="literal-block">
#include &lt;<a href="../../../../boost/mpl/begin_end.hpp" class="header">boost/mpl/begin_end.hpp</a>&gt;
</pre>
</div>
<div class="section" id="begin-model-of">
<h3><a class="subsection-title" href="#model-of" name="model-of">Model of</a></h3>
<p><a class="reference" href="./tag-dispatched.html">Tag Dispatched Metafunction</a></p>
</div>
<div class="section" id="begin-parameters">
<h3><a class="subsection-title" href="#parameters" name="parameters">Parameters</a></h3>
<table border="1" class="table">
<colgroup>
<col width="18%" />
<col width="22%" />
<col width="60%" />
</colgroup>
<thead valign="bottom">
<tr><th>Parameter</th>
<th>Requirement</th>
<th>Description</th>
</tr>
</thead>
<tbody valign="top">
<tr><td><tt class="literal"><span class="pre">X</span></tt></td>
<td>Any type</td>
<td>A type whose begin iterator, if any, will be
returned.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="begin-expression-semantics">
<h3><a class="subsection-title" href="#expression-semantics" name="expression-semantics">Expression semantics</a></h3>
<p>For any arbitrary type <tt class="literal"><span class="pre">x</span></tt>:</p>
<pre class="literal-block">
typedef <a href="./begin.html" class="identifier">begin</a>&lt;x&gt;::type first;
</pre>
<table class="field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Return type:</th><td class="field-body"><a class="reference" href="./forward-iterator.html">Forward Iterator</a> or <a class="refentry reference" href="./void.html"><tt class="refentry literal"><span class="pre">void_</span></tt></a>.</td>
</tr>
<tr class="field"><th class="field-name">Semantics:</th><td class="field-body">If <tt class="literal"><span class="pre">x</span></tt> is a <a class="reference" href="./forward-sequence.html">Forward Sequence</a>, <tt class="literal"><span class="pre">first</span></tt> is an iterator pointing to the
first element of <tt class="literal"><span class="pre">s</span></tt>; otherwise <tt class="literal"><span class="pre">first</span></tt> is <a class="refentry reference" href="./void.html"><tt class="refentry literal"><span class="pre">void_</span></tt></a>.</td>
</tr>
<tr class="field"><th class="field-name">Postcondition:</th><td class="field-body">If <tt class="literal"><span class="pre">first</span></tt> is an iterator, it is either dereferenceable or past-the-end; it
is past-the-end if and only if <tt class="literal"><span class="pre"><a href="./size.html" class="identifier">size</a>&lt;x&gt;::value</span> <span class="pre">==</span> <span class="pre">0</span></tt>.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="begin-complexity">
<h3><a class="subsection-title" href="#complexity" name="complexity">Complexity</a></h3>
<p>Amortized constant time.</p>
</div>
<div class="section" id="begin-example">
<h3><a class="subsection-title" href="#example" name="example">Example</a></h3>
<pre class="literal-block">
typedef <a href="./vector.html" class="identifier">vector</a>&lt; unsigned char,unsigned short,
unsigned int,unsigned long &gt; unsigned_types;
typedef <a href="./begin.html" class="identifier">begin</a>&lt;unsigned_types&gt;::type iter;
<a href="./assert.html" class="identifier">BOOST_MPL_ASSERT</a>(( is_same&lt; <a href="./deref.html" class="identifier">deref</a>&lt;iter&gt;::type, unsigned char &gt; ));
<a href="./assert.html" class="identifier">BOOST_MPL_ASSERT</a>(( is_same&lt; <a href="./begin.html" class="identifier">begin</a>&lt;int&gt;::type, <a href="./void.html" class="identifier">void_</a> > ));
</pre>
</div>
<div class="section" id="begin-see-also">
<h3><a class="subsection-title" href="#see-also" name="see-also">See also</a></h3>
<p><a class="reference" href="./iterators.html">Iterators</a>, <a class="reference" href="./forward-sequence.html">Forward Sequence</a>, <a class="refentry reference" href="./end.html"><tt class="refentry literal"><span class="pre">end</span></tt></a>, <a class="refentry reference" href="./size.html"><tt class="refentry literal"><span class="pre">size</span></tt></a>, <a class="refentry reference" href="./empty.html"><tt class="refentry literal"><span class="pre">empty</span></tt></a></p>
<!-- modtime: November 13, 2004 01:25:11 +0000 -->
<!-- Sequences/Intrinsic Metafunctions//clear -->
</div>
</div>
<div class="footer-separator"></div>
<table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./back.html" class="navigation-link">Prev</a>&nbsp;<a href="./clear.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./back.html" class="navigation-link">Back</a>&nbsp;<a href="./clear.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./intrinsic-metafunctions.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>
</tr></table></body>
</html>
+107
View File
@@ -0,0 +1,107 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.3.6: http://docutils.sourceforge.net/" />
<title>The MPL Reference Manual: Bidirectional Iterator</title>
<link rel="stylesheet" href="../style.css" type="text/css" />
</head>
<body class="docframe refmanual">
<table class="header"><tr class="header"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./forward-iterator.html" class="navigation-link">Prev</a>&nbsp;<a href="./random-access-iterator.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./forward-iterator.html" class="navigation-link">Back</a>&nbsp;<a href="./random-access-iterator.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./iterators-concepts.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>
<td class="header-group page-location"><a href="../refmanual.html" class="navigation-link">Front Page</a> / <a href="./iterators.html" class="navigation-link">Iterators</a> / <a href="./iterators-concepts.html" class="navigation-link">Concepts</a> / <a href="./bidirectional-iterator.html" class="navigation-link">Bidirectional Iterator</a></td>
</tr></table><div class="header-separator"></div>
<div class="section" id="bidirectional-iterator">
<h1><a class="toc-backref" href="./iterators-concepts.html#id379" name="bidirectional-iterator">Bidirectional Iterator</a></h1>
<div class="section" id="iterators-bidirectional-description">
<h3><a class="subsection-title" href="#description" name="description">Description</a></h3>
<p>A <a class="reference" href="./bidirectional-iterator.html">Bidirectional Iterator</a> is a <a class="reference" href="./forward-iterator.html">Forward Iterator</a> that provides a way to
obtain an iterator to the previous element in a sequence.</p>
</div>
<div class="section" id="bidirectional-refinement-of">
<h3><a class="subsection-title" href="#refinement-of" name="refinement-of">Refinement of</a></h3>
<p><a class="reference" href="./forward-iterator.html">Forward Iterator</a></p>
</div>
<div class="section" id="bidirectional-definitions">
<h3><a class="subsection-title" href="#definitions" name="definitions">Definitions</a></h3>
<ul class="simple">
<li>a bidirectional iterator <tt class="literal"><span class="pre">i</span></tt> is <cite>decrementable</cite> if there is a &quot;previous&quot;
iterator, that is, if <tt class="literal"><span class="pre"><a href="./prior.html" class="identifier">prior</a>&lt;i&gt;::type</span></tt> expression is well-defined;
iterators pointing to the first element of the sequence are not
decrementable.</li>
</ul>
</div>
<div class="section" id="iterators-bidirectional-expression-requirements">
<h3><a class="subsection-title" href="#expression-requirements" name="expression-requirements">Expression requirements</a></h3>
<p>In addition to the requirements defined in <a class="reference" href="./forward-iterator.html">Forward Iterator</a>,
the following requirements must be met.</p>
<table border="1" class="table">
<colgroup>
<col width="25%" />
<col width="46%" />
<col width="29%" />
</colgroup>
<thead valign="bottom">
<tr><th>Expression</th>
<th>Type</th>
<th>Complexity</th>
</tr>
</thead>
<tbody valign="top">
<tr><td><tt class="literal"><span class="pre"><a href="./next.html" class="identifier">next</a>&lt;i&gt;::type</span></tt></td>
<td><a class="reference" href="./bidirectional-iterator.html">Bidirectional Iterator</a></td>
<td>Amortized constant time</td>
</tr>
<tr><td><tt class="literal"><span class="pre"><a href="./prior.html" class="identifier">prior</a>&lt;i&gt;::type</span></tt></td>
<td><a class="reference" href="./bidirectional-iterator.html">Bidirectional Iterator</a></td>
<td>Amortized constant time</td>
</tr>
<tr><td><tt class="literal"><span class="pre">i::category</span></tt></td>
<td><a class="reference" href="./integral-constant.html">Integral Constant</a>, convertible
to <tt class="literal"><span class="pre">bidirectional_iterator_tag</span></tt></td>
<td>Constant time</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="iterators-bidirectional-expression-semantics">
<h3><a class="subsection-title" href="#expression-semantics" name="expression-semantics">Expression semantics</a></h3>
<pre class="literal-block">
typedef <a href="./prior.html" class="identifier">prior</a>&lt;i&gt;::type j;
</pre>
<table class="field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Precondition:</th><td class="field-body"><tt class="literal"><span class="pre">i</span></tt> is decrementable</td>
</tr>
<tr class="field"><th class="field-name">Semantics:</th><td class="field-body"><tt class="literal"><span class="pre">j</span></tt> is an iterator pointing to the previous element of the
sequence</td>
</tr>
<tr class="field"><th class="field-name">Postcondition:</th><td class="field-body"><tt class="literal"><span class="pre">j</span></tt> is dereferenceable and incrementable</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="bidirectional-invariants">
<h3><a class="subsection-title" href="#invariants" name="invariants">Invariants</a></h3>
<p>For any bidirectional iterators <tt class="literal"><span class="pre">i</span></tt> and <tt class="literal"><span class="pre">j</span></tt> the following invariants
always hold:</p>
<ul class="simple">
<li>If <tt class="literal"><span class="pre">i</span></tt> is incrementable, then <tt class="literal"><span class="pre"><a href="./prior.html" class="identifier">prior</a>&lt;</span> <span class="pre"><a href="./next.html" class="identifier">next</a>&lt;i&gt;::type</span> <span class="pre">&gt;::type</span></tt> is a null
operation; similarly, if <tt class="literal"><span class="pre">i</span></tt> is decrementable, <tt class="literal"><span class="pre"><a href="./next.html" class="identifier">next</a>&lt;</span> <span class="pre"><a href="./prior.html" class="identifier">prior</a>&lt;i&gt;::type</span> <span class="pre">&gt;::type</span></tt>
is a null operation.</li>
</ul>
</div>
<div class="section" id="iterators-bidirectional-see-also">
<h3><a class="subsection-title" href="#see-also" name="see-also">See also</a></h3>
<p><a class="reference" href="./iterators.html">Iterators</a>, <a class="reference" href="./forward-iterator.html">Forward Iterator</a>, <a class="reference" href="./random-access-iterator.html">Random Access Iterator</a>, <a class="reference" href="./bidirectional-sequence.html">Bidirectional Sequence</a>, <a class="refentry reference" href="./prior.html"><tt class="refentry literal"><span class="pre">prior</span></tt></a></p>
<!-- modtime: November 15, 2004 02:44:55 +0000 -->
<!-- Iterators/Concepts//Random Access Iterator |30 -->
</div>
</div>
<div class="footer-separator"></div>
<table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./forward-iterator.html" class="navigation-link">Prev</a>&nbsp;<a href="./random-access-iterator.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./forward-iterator.html" class="navigation-link">Back</a>&nbsp;<a href="./random-access-iterator.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./iterators-concepts.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>
</tr></table></body>
</html>
+96
View File
@@ -0,0 +1,96 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.3.6: http://docutils.sourceforge.net/" />
<title>The MPL Reference Manual: Bidirectional Sequence</title>
<link rel="stylesheet" href="../style.css" type="text/css" />
</head>
<body class="docframe refmanual">
<table class="header"><tr class="header"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./forward-sequence.html" class="navigation-link">Prev</a>&nbsp;<a href="./random-access-sequence.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./forward-sequence.html" class="navigation-link">Back</a>&nbsp;<a href="./random-access-sequence.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./concepts.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>
<td class="header-group page-location"><a href="../refmanual.html" class="navigation-link">Front Page</a> / <a href="./sequences.html" class="navigation-link">Sequences</a> / <a href="./concepts.html" class="navigation-link">Concepts</a> / <a href="./bidirectional-sequence.html" class="navigation-link">Bidirectional Sequence</a></td>
</tr></table><div class="header-separator"></div>
<div class="section" id="bidirectional-sequence">
<h1><a class="toc-backref" href="./concepts.html#id325" name="bidirectional-sequence">Bidirectional Sequence</a></h1>
<div class="section" id="bidirectional-description">
<h3><a class="subsection-title" href="#description" name="description">Description</a></h3>
<p>A <a class="reference" href="./bidirectional-sequence.html">Bidirectional Sequence</a> is a <a class="reference" href="./forward-sequence.html">Forward Sequence</a> whose iterators model
<a class="reference" href="./bidirectional-iterator.html">Bidirectional Iterator</a>.</p>
</div>
<div class="section" id="refinement-of">
<h3><a class="subsection-title" href="#refinement-of" name="refinement-of">Refinement of</a></h3>
<p><a class="reference" href="./forward-sequence.html">Forward Sequence</a></p>
</div>
<div class="section" id="bidirectional-expression-requirements">
<h3><a class="subsection-title" href="#expression-requirements" name="expression-requirements">Expression requirements</a></h3>
<p>In addition to the requirements defined in <a class="reference" href="./forward-sequence.html">Forward Sequence</a>,
for any <a class="reference" href="./bidirectional-sequence.html">Bidirectional Sequence</a> <tt class="literal"><span class="pre">s</span></tt> the following must be met:</p>
<table border="1" class="table">
<colgroup>
<col width="30%" />
<col width="39%" />
<col width="30%" />
</colgroup>
<thead valign="bottom">
<tr><th>Expression</th>
<th>Type</th>
<th>Complexity</th>
</tr>
</thead>
<tbody valign="top">
<tr><td><tt class="literal"><span class="pre"><a href="./begin.html" class="identifier">begin</a>&lt;s&gt;::type</span></tt></td>
<td><a class="reference" href="./bidirectional-iterator.html">Bidirectional Iterator</a></td>
<td>Amortized constant time</td>
</tr>
<tr><td><tt class="literal"><span class="pre"><a href="./end.html" class="identifier">end</a>&lt;s&gt;::type</span></tt></td>
<td><a class="reference" href="./bidirectional-iterator.html">Bidirectional Iterator</a></td>
<td>Amortized constant time</td>
</tr>
<tr><td><tt class="literal"><span class="pre"><a href="./back.html" class="identifier">back</a>&lt;s&gt;::type</span></tt></td>
<td>Any type</td>
<td>Amortized constant time</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="bidirectional-expression-semantics">
<h3><a class="subsection-title" href="#expression-semantics" name="expression-semantics">Expression semantics</a></h3>
<p>The semantics of an expression are defined only
where they differ from, or are not defined in <a class="reference" href="./forward-sequence.html">Forward Sequence</a>.</p>
<table border="1" class="table">
<colgroup>
<col width="28%" />
<col width="72%" />
</colgroup>
<thead valign="bottom">
<tr><th>Expression</th>
<th>Semantics</th>
</tr>
</thead>
<tbody valign="top">
<tr><td><tt class="literal"><span class="pre"><a href="./back.html" class="identifier">back</a>&lt;s&gt;::type</span></tt></td>
<td>The last element in the sequence; see <a class="refentry reference" href="./back.html"><tt class="refentry literal"><span class="pre">back</span></tt></a>.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="bidirectional-models">
<h3><a class="subsection-title" href="#models" name="models">Models</a></h3>
<ul class="simple">
<li><a class="refentry reference" href="./vector.html"><tt class="refentry literal"><span class="pre">vector</span></tt></a></li>
<li><a class="refentry reference" href="./range-c.html"><tt class="refentry literal"><span class="pre">range_c</span></tt></a></li>
</ul>
</div>
<div class="section" id="bidirectional-see-also">
<h3><a class="subsection-title" href="#see-also" name="see-also">See also</a></h3>
<p><a class="reference" href="./sequences.html">Sequences</a>, <a class="reference" href="./forward-sequence.html">Forward Sequence</a>, <a class="reference" href="./random-access-sequence.html">Random Access Sequence</a>, <a class="reference" href="./bidirectional-iterator.html">Bidirectional Iterator</a>, <a class="refentry reference" href="./begin.html"><tt class="refentry literal"><span class="pre">begin</span></tt></a> / <a class="refentry reference" href="./end.html"><tt class="refentry literal"><span class="pre">end</span></tt></a>, <a class="refentry reference" href="./back.html"><tt class="refentry literal"><span class="pre">back</span></tt></a></p>
<!-- modtime: November 13, 2004 00:39:57 +0000 -->
<!-- Sequences/Concepts//Random Access Sequence |30 -->
</div>
</div>
<div class="footer-separator"></div>
<table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./forward-sequence.html" class="navigation-link">Prev</a>&nbsp;<a href="./random-access-sequence.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./forward-sequence.html" class="navigation-link">Back</a>&nbsp;<a href="./random-access-sequence.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./concepts.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>
</tr></table></body>
</html>
+224
View File
@@ -0,0 +1,224 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.3.6: http://docutils.sourceforge.net/" />
<title>The MPL Reference Manual: bind</title>
<link rel="stylesheet" href="../style.css" type="text/css" />
</head>
<body class="docframe refmanual">
<table class="header"><tr class="header"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./lambda.html" class="navigation-link">Prev</a>&nbsp;<a href="./quote.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./lambda.html" class="navigation-link">Back</a>&nbsp;<a href="./quote.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./composition-and-argument.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>
<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="./composition-and-argument.html" class="navigation-link">Composition and Argument Binding</a> / <a href="./bind.html" class="navigation-link">bind</a></td>
</tr></table><div class="header-separator"></div>
<div class="section" id="bind">
<h1><a class="toc-backref" href="./composition-and-argument.html#id457" name="bind">bind</a></h1>
<div class="section" id="bind-synopsis">
<h3><a class="subsection-title" href="#synopsis" name="synopsis">Synopsis</a></h3>
<pre class="literal-block">
template&lt;
typename F
&gt;
struct bind0
{
// <em>unspecified</em>
// <em>...</em>
};
template&lt;
typename F, typename A1
&gt;
struct bind1
{
// <em>unspecified</em>
// <em>...</em>
};
<em>...</em>
template&lt;
typename F, typename A1,<em>...</em> typename An
&gt;
struct <a href="./bind.html" class="identifier">bind</a><em>n</em>
{
// <em>unspecified</em>
// <em>...</em>
};
template&lt;
typename F
, typename A1 = <em>unspecified</em>
<em>...</em>
, typename An = <em>unspecified</em>
&gt;
struct <a href="./bind.html" class="identifier">bind</a>
{
// <em>unspecified</em>
// <em>...</em>
};
</pre>
</div>
<div class="section" id="bind-description">
<h3><a class="subsection-title" href="#description" name="description">Description</a></h3>
<p><tt class="literal"><span class="pre"><a href="./bind.html" class="identifier">bind</a></span></tt> is a higher-order primitive for <a class="reference" href="./metafunction-class.html">Metafunction Class</a> composition
and argument binding. In essence, it's a compile-time counterpart of
the similar run-time functionality provided by <a class="reference" href="http://www.boost.org/libs/bind/bind.html" target="_top">Boost.Bind</a> and <a class="reference" href="http://www.boost.org/libs/lambda/doc/index.html" target="_top">Boost.Lambda</a>
libraries.</p>
</div>
<div class="section" id="bind-header">
<h3><a class="subsection-title" href="#header" name="header">Header</a></h3>
<pre class="literal-block">
#include &lt;<a href="../../../../boost/mpl/bind.hpp" class="header">boost/mpl/bind.hpp</a>&gt;
</pre>
</div>
<div class="section" id="bind-model-of">
<h3><a class="subsection-title" href="#model-of" name="model-of">Model of</a></h3>
<p><a class="reference" href="./metafunction-class.html">Metafunction Class</a></p>
</div>
<div class="section" id="bind-parameters">
<h3><a class="subsection-title" href="#parameters" name="parameters">Parameters</a></h3>
<table border="1" class="table">
<colgroup>
<col width="15%" />
<col width="36%" />
<col width="48%" />
</colgroup>
<thead valign="bottom">
<tr><th>Parameter</th>
<th>Requirement</th>
<th>Description</th>
</tr>
</thead>
<tbody valign="top">
<tr><td><tt class="literal"><span class="pre">F</span></tt></td>
<td><a class="reference" href="./metafunction-class.html">Metafunction Class</a></td>
<td>An metafunction class to perform binding on.</td>
</tr>
<tr><td><tt class="literal"><span class="pre">A1</span></tt>,... <tt class="literal"><span class="pre">An</span></tt></td>
<td>Any type</td>
<td>Arguments to bind.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="bind-expression-semantics">
<h3><a class="subsection-title" href="#expression-semantics" name="expression-semantics">Expression semantics</a></h3>
<p>For any <a class="reference" href="./metafunction-class.html">Metafunction Class</a> <tt class="literal"><span class="pre">f</span></tt> and arbitrary types <tt class="literal"><span class="pre">a1</span></tt>,... <tt class="literal"><span class="pre">an</span></tt>:</p>
<pre class="literal-block">
typedef <a href="./bind.html" class="identifier">bind</a>&lt;f,a1,...a<em>n</em>&gt; g;
typedef <a href="./bind.html" class="identifier">bind</a><em>n</em>&lt;f,a1,...a<em>n</em>&gt; g;
</pre>
<table class="field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Return type:</th><td class="field-body"><a class="reference" href="./metafunction-class.html">Metafunction Class</a></td>
</tr>
</tbody>
</table>
<a class="target" id="bind-semantics" name="bind-semantics"></a><table class="field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Semantics:</th><td class="field-body"><p class="first">Equivalent to</p>
<pre class="literal-block">
struct g
{
template&lt;
typename U1 = <em>unspecified</em>
<em>...</em>
, typename U<em>n</em> = <em>unspecified</em>
&gt;
struct <a href="./apply.html" class="identifier">apply</a>
: <a href="./apply-wrap.html" class="identifier">apply_wrap</a><em>n</em>&lt;
typename h0&lt;f,U1,<em>...</em>U<em>n</em>&gt;::type
, typename h1&lt;a1,U1,<em>...</em>U<em>n</em>&gt;::type
<em>...</em>
, typename h<em>n</em>&lt;a<em>n</em>,U1,<em>...</em>U<em>n</em>&gt;::type
>
{
};
};
</pre>
<p>where <tt class="literal"><span class="pre">h</span></tt><em>k</em> is equivalent to</p>
<pre class="literal-block">
template&lt; typename X, typename U1,<em>...</em> typename U<em>n</em> &gt; struct h<em>k</em>
: <a href="./apply-wrap.html" class="identifier">apply_wrap</a><em>n</em>&lt;X,U1,<em>...</em>U<em>n</em>&gt;
{
};
</pre>
<p>if <tt class="literal"><span class="pre">f</span></tt> or <tt class="literal"><span class="pre">a</span></tt><em>k</em> is a <a class="reference" href="./terminology.html#bind-expression">bind expression</a> or a <a class="reference" href="./placeholders.html">placeholder</a>, and</p>
<pre class="literal-block">
template&lt; typename X, typename U1,<em>...</em> typename U<em>n</em> &gt; struct h<em>k</em>
{
typedef X type;
};
</pre>
<p class="last">otherwise. [<em>Note:</em> Every <tt class="literal"><span class="pre">n</span></tt>th appearance of the <a class="reference" href="./placeholders.html">unnamed placeholder</a>
in the <tt class="literal"><span class="pre"><a href="./bind.html" class="identifier">bind</a>&lt;f,a1,...an&gt;</span></tt> specialization is replaced with the corresponding
numbered placeholder <tt class="literal"><span class="pre">_</span></tt><em>n</em> — <em>end note</em>]</p>
</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="bind-example">
<h3><a class="subsection-title" href="#example" name="example">Example</a></h3>
<pre class="literal-block">
struct f1
{
template&lt; typename T1 &gt; struct <a href="./apply.html" class="identifier">apply</a>
{
typedef T1 type;
};
};
struct f5
{
template&lt; typename T1, typename T2, typename T3, typename T4, typename T5 &gt;
struct <a href="./apply.html" class="identifier">apply</a>
{
typedef T5 type;
};
};
typedef <a href="./apply-wrap.html" class="identifier">apply_wrap</a><tt class="literal"><span class="pre">1</span></tt>&lt;
<a href="./bind.html" class="identifier">bind</a><tt class="literal"><span class="pre">1</span></tt>&lt;f1,_1&gt;
, int
&gt;::type r11;
typedef <a href="./apply-wrap.html" class="identifier">apply_wrap</a><tt class="literal"><span class="pre">5</span></tt>&lt;
<a href="./bind.html" class="identifier">bind</a><tt class="literal"><span class="pre">1</span></tt>&lt;f1,_5&gt;
, void,void,void,void,int
&gt;::type r12;
<a href="./assert.html" class="identifier">BOOST_MPL_ASSERT</a>(( is_same&lt;r11,int&gt; ));
<a href="./assert.html" class="identifier">BOOST_MPL_ASSERT</a>(( is_same&lt;r12,int&gt; ));
typedef <a href="./apply-wrap.html" class="identifier">apply_wrap</a><tt class="literal"><span class="pre">5</span></tt>&lt;
<a href="./bind.html" class="identifier">bind</a><tt class="literal"><span class="pre">5</span></tt>&lt;f5,_1,_2,_3,_4,_5&gt;
, void,void,void,void,int
&gt;::type r51;
typedef <a href="./apply-wrap.html" class="identifier">apply_wrap</a><tt class="literal"><span class="pre">5</span></tt>&lt;
<a href="./bind.html" class="identifier">bind</a><tt class="literal"><span class="pre">5</span></tt>&lt;f5,_5,_4,_3,_2,_1&gt;
, int,void,void,void,void
&gt;::type r52;
<a href="./assert.html" class="identifier">BOOST_MPL_ASSERT</a>(( is_same&lt;r51,int&gt; ));
<a href="./assert.html" class="identifier">BOOST_MPL_ASSERT</a>(( is_same&lt;r52,int&gt; ));
</pre>
</div>
<div class="section" id="bind-see-also">
<h3><a class="subsection-title" href="#see-also" name="see-also">See also</a></h3>
<p><a class="reference" href="./composition-and-argument.html">Composition and Argument Binding</a>, <a class="reference" href="./invocation.html">invocation</a>, <a class="reference" href="./placeholders.html">Placeholders</a>, <a class="refentry reference" href="./lambda.html"><tt class="refentry literal"><span class="pre">lambda</span></tt></a>, <a class="refentry reference" href="./quote.html"><tt class="refentry literal"><span class="pre">quote</span></tt></a>,
<a class="refentry reference" href="./protect.html"><tt class="refentry literal"><span class="pre">protect</span></tt></a>, <a class="refentry reference" href="./apply.html"><tt class="refentry literal"><span class="pre">apply</span></tt></a>, <a class="refentry reference" href="./apply-wrap.html"><tt class="refentry literal"><span class="pre">apply_wrap</span></tt></a></p>
<!-- modtime: November 13, 2004 01:59:44 +0000 -->
<!-- Metafunctions/Composition and Argument Binding//quote |40 -->
</div>
</div>
<div class="footer-separator"></div>
<table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./lambda.html" class="navigation-link">Prev</a>&nbsp;<a href="./quote.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./lambda.html" class="navigation-link">Back</a>&nbsp;<a href="./quote.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./composition-and-argument.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>
</tr></table></body>
</html>
+149
View File
@@ -0,0 +1,149 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.3.6: http://docutils.sourceforge.net/" />
<title>The MPL Reference Manual: bitand_</title>
<link rel="stylesheet" href="../style.css" type="text/css" />
</head>
<body class="docframe refmanual">
<table class="header"><tr class="header"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./bitwise-operations.html" class="navigation-link">Prev</a>&nbsp;<a href="./bitor.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group">Back&nbsp;<a href="./bitor.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./bitwise-operations.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>
<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="./bitwise-operations.html" class="navigation-link">Bitwise Operations</a> / <a href="./bitand.html" class="navigation-link">bitand_</a></td>
</tr></table><div class="header-separator"></div>
<div class="section" id="bitand">
<h1><a class="toc-backref" href="./bitwise-operations.html#id480" name="bitand">bitand_</a></h1>
<div class="section" id="bitand-synopsis">
<h3><a class="subsection-title" href="#synopsis" name="synopsis">Synopsis</a></h3>
<pre class="literal-block">
template&lt;
typename T1
, typename T2
, typename T3 = <em>unspecified</em>
<em>...</em>
, typename T<em>n</em> = <em>unspecified</em>
&gt;
struct <a href="./bitand.html" class="identifier">bitand_</a>
{
typedef <em>unspecified</em> type;
};
</pre>
</div>
<div class="section" id="bitand-description">
<h3><a class="subsection-title" href="#description" name="description">Description</a></h3>
<p>Returns the result of <em>bitwise and</em> (<tt class="literal"><span class="pre">&amp;</span></tt>) operation of its arguments.</p>
</div>
<div class="section" id="bitand-header">
<h3><a class="subsection-title" href="#header" name="header">Header</a></h3>
<pre class="literal-block">
#include &lt;<a href="../../../../boost/mpl/bitand.hpp" class="header">boost/mpl/bitand.hpp</a>&gt;
#include &lt;<a href="../../../../boost/mpl/bitwise.hpp" class="header">boost/mpl/bitwise.hpp</a>&gt;
</pre>
</div>
<div class="section" id="bitand-model-of">
<h3><a class="subsection-title" href="#model-of" name="model-of">Model of</a></h3>
<p><a class="reference" href="./numeric-metafunction.html">Numeric Metafunction</a></p>
</div>
<div class="section" id="bitand-parameters">
<h3><a class="subsection-title" href="#parameters" name="parameters">Parameters</a></h3>
<table border="1" class="table">
<colgroup>
<col width="17%" />
<col width="30%" />
<col width="53%" />
</colgroup>
<thead valign="bottom">
<tr><th>Parameter</th>
<th>Requirement</th>
<th>Description</th>
</tr>
</thead>
<tbody valign="top">
<tr><td><tt class="literal"><span class="pre">T1</span></tt>, <tt class="literal"><span class="pre">T2</span></tt>,... <tt class="literal"><span class="pre">Tn</span></tt></td>
<td><a class="reference" href="./integral-constant.html">Integral Constant</a></td>
<td>Operation's arguments.</td>
</tr>
</tbody>
</table>
<p>[<em>Note:</em> The requirements listed in this specification
are the ones imposed by the default implementation. See <a class="reference" href="./numeric-metafunction.html">Numeric Metafunction</a> concept
for the details on how to provide an implementation for a user-defined numeric type
that does not satisfy the <a class="reference" href="./integral-constant.html">Integral Constant</a> requirements. — <em>end note</em>]</p>
</div>
<div class="section" id="bitand-expression-semantics">
<h3><a class="subsection-title" href="#expression-semantics" name="expression-semantics">Expression semantics</a></h3>
<p>For any <a class="reference" href="./integral-constant.html">Integral Constant</a>s <em>c</em><sub>1</sub>,<em>c</em><sub>2</sub>,... <em>c</em><sub>n</sub>:</p>
<pre class="literal-block">
typedef <a href="./bitand.html" class="identifier">bitand_</a>&lt;c1,<em>...</em>c<em>n</em>&gt;::type r;
</pre>
<table class="field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Return type:</th><td class="field-body"><a class="reference" href="./integral-constant.html">Integral Constant</a>.</td>
</tr>
<tr class="field"><th class="field-name">Semantics:</th><td class="field-body"><p class="first">Equivalent to</p>
<pre class="last literal-block">
typedef <a href="./integral-c.html" class="identifier">integral_c</a>&lt;
typeof(c1::value &amp; c2::value)
, ( c1::value &amp; c2::value )
&gt; c;
typedef <a href="./bitand.html" class="identifier">bitand_</a>&lt;c,c3,<em>...</em>c<em>n</em>&gt;::type r;
</pre>
</td>
</tr>
</tbody>
</table>
<!-- .......................................................................... -->
<pre class="literal-block">
typedef <a href="./bitand.html" class="identifier">bitand_</a>&lt;c1,<em>...</em>c<em>n</em>&gt; r;
</pre>
<table class="field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Return type:</th><td class="field-body"><a class="reference" href="./integral-constant.html">Integral Constant</a>.</td>
</tr>
<tr class="field"><th class="field-name">Semantics:</th><td class="field-body"><p class="first">Equivalent to</p>
<pre class="last literal-block">
struct r : <a href="./bitand.html" class="identifier">bitand_</a>&lt;c1,<em>...</em>c<em>n</em>&gt;::type {};
</pre>
</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="bitand-complexity">
<h3><a class="subsection-title" href="#complexity" name="complexity">Complexity</a></h3>
<p>Amortized constant time.</p>
</div>
<div class="section" id="bitand-example">
<h3><a class="subsection-title" href="#example" name="example">Example</a></h3>
<pre class="literal-block">
typedef <a href="./integral-c.html" class="identifier">integral_c</a>&lt;unsigned,0&gt; u0;
typedef <a href="./integral-c.html" class="identifier">integral_c</a>&lt;unsigned,1&gt; u1;
typedef <a href="./integral-c.html" class="identifier">integral_c</a>&lt;unsigned,2&gt; u2;
typedef <a href="./integral-c.html" class="identifier">integral_c</a>&lt;unsigned,8&gt; u8;
typedef <a href="./integral-c.html" class="identifier">integral_c</a>&lt;unsigned,0xffffffff&gt; uffffffff;
<a href="./assert-relation.html" class="identifier">BOOST_MPL_ASSERT_RELATION</a>( (<a href="./bitand.html" class="identifier">bitand_</a>&lt;u0,u0&gt;::value), ==, 0 );
<a href="./assert-relation.html" class="identifier">BOOST_MPL_ASSERT_RELATION</a>( (<a href="./bitand.html" class="identifier">bitand_</a>&lt;u1,u0&gt;::value), ==, 0 );
<a href="./assert-relation.html" class="identifier">BOOST_MPL_ASSERT_RELATION</a>( (<a href="./bitand.html" class="identifier">bitand_</a>&lt;u0,u1&gt;::value), ==, 0 );
<a href="./assert-relation.html" class="identifier">BOOST_MPL_ASSERT_RELATION</a>( (<a href="./bitand.html" class="identifier">bitand_</a>&lt;u0,uffffffff&gt;::value), ==, 0 );
<a href="./assert-relation.html" class="identifier">BOOST_MPL_ASSERT_RELATION</a>( (<a href="./bitand.html" class="identifier">bitand_</a>&lt;u1,uffffffff&gt;::value), ==, 1 );
<a href="./assert-relation.html" class="identifier">BOOST_MPL_ASSERT_RELATION</a>( (<a href="./bitand.html" class="identifier">bitand_</a>&lt;u8,uffffffff&gt;::value), ==, 8 );
</pre>
</div>
<div class="section" id="bitand-see-also">
<h3><a class="subsection-title" href="#see-also" name="see-also">See also</a></h3>
<p><a class="reference" href="./bitwise-operations.html">Bitwise Operations</a>, <a class="reference" href="./numeric-metafunction.html">Numeric Metafunction</a>, <a class="refentry reference" href="./numeric-cast.html"><tt class="refentry literal"><span class="pre">numeric_cast</span></tt></a>, <a class="refentry reference" href="./bitor.html"><tt class="refentry literal"><span class="pre">bitor_</span></tt></a>, <a class="refentry reference" href="./bitxor.html"><tt class="refentry literal"><span class="pre">bitxor_</span></tt></a>, <a class="refentry reference" href="./shift-left.html"><tt class="refentry literal"><span class="pre">shift_left</span></tt></a></p>
<!-- modtime: November 10, 2004 04:44:32 +0000 -->
<!-- Metafunctions/Bitwise Operations//bitor_ -->
</div>
</div>
<div class="footer-separator"></div>
<table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./bitwise-operations.html" class="navigation-link">Prev</a>&nbsp;<a href="./bitor.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group">Back&nbsp;<a href="./bitor.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./bitwise-operations.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>
</tr></table></body>
</html>
+149
View File
@@ -0,0 +1,149 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.3.6: http://docutils.sourceforge.net/" />
<title>The MPL Reference Manual: bitor_</title>
<link rel="stylesheet" href="../style.css" type="text/css" />
</head>
<body class="docframe refmanual">
<table class="header"><tr class="header"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./bitand.html" class="navigation-link">Prev</a>&nbsp;<a href="./bitxor.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./bitand.html" class="navigation-link">Back</a>&nbsp;<a href="./bitxor.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./bitwise-operations.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>
<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="./bitwise-operations.html" class="navigation-link">Bitwise Operations</a> / <a href="./bitor.html" class="navigation-link">bitor_</a></td>
</tr></table><div class="header-separator"></div>
<div class="section" id="bitor">
<h1><a class="toc-backref" href="./bitwise-operations.html#id481" name="bitor">bitor_</a></h1>
<div class="section" id="bitor-synopsis">
<h3><a class="subsection-title" href="#synopsis" name="synopsis">Synopsis</a></h3>
<pre class="literal-block">
template&lt;
typename T1
, typename T2
, typename T3 = <em>unspecified</em>
<em>...</em>
, typename T<em>n</em> = <em>unspecified</em>
&gt;
struct <a href="./bitor.html" class="identifier">bitor_</a>
{
typedef <em>unspecified</em> type;
};
</pre>
</div>
<div class="section" id="bitor-description">
<h3><a class="subsection-title" href="#description" name="description">Description</a></h3>
<p>Returns the result of <em>bitwise or</em> (<tt class="literal"><span class="pre">|</span></tt>) operation of its arguments.</p>
</div>
<div class="section" id="bitor-header">
<h3><a class="subsection-title" href="#header" name="header">Header</a></h3>
<pre class="literal-block">
#include &lt;<a href="../../../../boost/mpl/bitor.hpp" class="header">boost/mpl/bitor.hpp</a>&gt;
#include &lt;<a href="../../../../boost/mpl/bitwise.hpp" class="header">boost/mpl/bitwise.hpp</a>&gt;
</pre>
</div>
<div class="section" id="bitor-model-of">
<h3><a class="subsection-title" href="#model-of" name="model-of">Model of</a></h3>
<p><a class="reference" href="./numeric-metafunction.html">Numeric Metafunction</a></p>
</div>
<div class="section" id="bitor-parameters">
<h3><a class="subsection-title" href="#parameters" name="parameters">Parameters</a></h3>
<table border="1" class="table">
<colgroup>
<col width="17%" />
<col width="30%" />
<col width="53%" />
</colgroup>
<thead valign="bottom">
<tr><th>Parameter</th>
<th>Requirement</th>
<th>Description</th>
</tr>
</thead>
<tbody valign="top">
<tr><td><tt class="literal"><span class="pre">T1</span></tt>, <tt class="literal"><span class="pre">T2</span></tt>,... <tt class="literal"><span class="pre">Tn</span></tt></td>
<td><a class="reference" href="./integral-constant.html">Integral Constant</a></td>
<td>Operation's arguments.</td>
</tr>
</tbody>
</table>
<p>[<em>Note:</em> The requirements listed in this specification
are the ones imposed by the default implementation. See <a class="reference" href="./numeric-metafunction.html">Numeric Metafunction</a> concept
for the details on how to provide an implementation for a user-defined numeric type
that does not satisfy the <a class="reference" href="./integral-constant.html">Integral Constant</a> requirements. — <em>end note</em>]</p>
</div>
<div class="section" id="bitor-expression-semantics">
<h3><a class="subsection-title" href="#expression-semantics" name="expression-semantics">Expression semantics</a></h3>
<p>For any <a class="reference" href="./integral-constant.html">Integral Constant</a>s <em>c</em><sub>1</sub>,<em>c</em><sub>2</sub>,... <em>c</em><sub>n</sub>:</p>
<pre class="literal-block">
typedef <a href="./bitor.html" class="identifier">bitor_</a>&lt;c1,<em>...</em>c<em>n</em>&gt;::type r;
</pre>
<table class="field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Return type:</th><td class="field-body"><a class="reference" href="./integral-constant.html">Integral Constant</a>.</td>
</tr>
<tr class="field"><th class="field-name">Semantics:</th><td class="field-body"><p class="first">Equivalent to</p>
<pre class="last literal-block">
typedef <a href="./integral-c.html" class="identifier">integral_c</a>&lt;
typeof(c1::value | c2::value)
, ( c1::value | c2::value )
&gt; c;
typedef <a href="./bitor.html" class="identifier">bitor_</a>&lt;c,c3,<em>...</em>c<em>n</em>&gt;::type r;
</pre>
</td>
</tr>
</tbody>
</table>
<!-- .......................................................................... -->
<pre class="literal-block">
typedef <a href="./bitor.html" class="identifier">bitor_</a>&lt;c1,<em>...</em>c<em>n</em>&gt; r;
</pre>
<table class="field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Return type:</th><td class="field-body"><a class="reference" href="./integral-constant.html">Integral Constant</a>.</td>
</tr>
<tr class="field"><th class="field-name">Semantics:</th><td class="field-body"><p class="first">Equivalent to</p>
<pre class="last literal-block">
struct r : <a href="./bitor.html" class="identifier">bitor_</a>&lt;c1,<em>...</em>c<em>n</em>&gt;::type {};
</pre>
</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="bitor-complexity">
<h3><a class="subsection-title" href="#complexity" name="complexity">Complexity</a></h3>
<p>Amortized constant time.</p>
</div>
<div class="section" id="bitor-example">
<h3><a class="subsection-title" href="#example" name="example">Example</a></h3>
<pre class="literal-block">
typedef <a href="./integral-c.html" class="identifier">integral_c</a>&lt;unsigned,0&gt; u0;
typedef <a href="./integral-c.html" class="identifier">integral_c</a>&lt;unsigned,1&gt; u1;
typedef <a href="./integral-c.html" class="identifier">integral_c</a>&lt;unsigned,2&gt; u2;
typedef <a href="./integral-c.html" class="identifier">integral_c</a>&lt;unsigned,8&gt; u8;
typedef <a href="./integral-c.html" class="identifier">integral_c</a>&lt;unsigned,0xffffffff&gt; uffffffff;
<a href="./assert-relation.html" class="identifier">BOOST_MPL_ASSERT_RELATION</a>( (<a href="./bitor.html" class="identifier">bitor_</a>&lt;u0,u0&gt;::value), ==, 0 );
<a href="./assert-relation.html" class="identifier">BOOST_MPL_ASSERT_RELATION</a>( (<a href="./bitor.html" class="identifier">bitor_</a>&lt;u1,u0&gt;::value), ==, 1 );
<a href="./assert-relation.html" class="identifier">BOOST_MPL_ASSERT_RELATION</a>( (<a href="./bitor.html" class="identifier">bitor_</a>&lt;u0,u1&gt;::value), ==, 1 );
<a href="./assert-relation.html" class="identifier">BOOST_MPL_ASSERT_RELATION</a>( (<a href="./bitor.html" class="identifier">bitor_</a>&lt;u0,uffffffff&gt;::value), ==, 0xffffffff );
<a href="./assert-relation.html" class="identifier">BOOST_MPL_ASSERT_RELATION</a>( (<a href="./bitor.html" class="identifier">bitor_</a>&lt;u1,uffffffff&gt;::value), ==, 0xffffffff );
<a href="./assert-relation.html" class="identifier">BOOST_MPL_ASSERT_RELATION</a>( (<a href="./bitor.html" class="identifier">bitor_</a>&lt;u8,uffffffff&gt;::value), ==, 0xffffffff );
</pre>
</div>
<div class="section" id="bitor-see-also">
<h3><a class="subsection-title" href="#see-also" name="see-also">See also</a></h3>
<p><a class="reference" href="./bitwise-operations.html">Bitwise Operations</a>, <a class="reference" href="./numeric-metafunction.html">Numeric Metafunction</a>, <a class="refentry reference" href="./numeric-cast.html"><tt class="refentry literal"><span class="pre">numeric_cast</span></tt></a>, <a class="refentry reference" href="./bitand.html"><tt class="refentry literal"><span class="pre">bitand_</span></tt></a>, <a class="refentry reference" href="./bitxor.html"><tt class="refentry literal"><span class="pre">bitxor_</span></tt></a>, <a class="refentry reference" href="./shift-left.html"><tt class="refentry literal"><span class="pre">shift_left</span></tt></a></p>
<!-- modtime: November 10, 2004 05:04:32 +0000 -->
<!-- Metafunctions/Bitwise Operations//bitxor_ -->
</div>
</div>
<div class="footer-separator"></div>
<table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./bitand.html" class="navigation-link">Prev</a>&nbsp;<a href="./bitxor.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./bitand.html" class="navigation-link">Back</a>&nbsp;<a href="./bitxor.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./bitwise-operations.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>
</tr></table></body>
</html>
+30
View File
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.3.6: http://docutils.sourceforge.net/" />
<title>The MPL Reference Manual: Bitwise Operations</title>
<link rel="stylesheet" href="../style.css" type="text/css" />
</head>
<body class="docframe refmanual">
<table class="header"><tr class="header"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./not.html" class="navigation-link">Prev</a>&nbsp;<a href="./bitand.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./logical-operations.html" class="navigation-link">Back</a>&nbsp;<a href="./trivial.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./metafunctions.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>
<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="./bitwise-operations.html" class="navigation-link">Bitwise Operations</a></td>
</tr></table><div class="header-separator"></div>
<div class="section" id="bitwise-operations">
<h1><a class="toc-backref" href="./metafunctions.html#id479" name="bitwise-operations">Bitwise Operations</a></h1>
<a class="target" id="id248" name="id248"></a><!-- modtime: November 08, 2004 08:24:29 +0000 -->
<!-- Metafunctions/Bitwise Operations//bitand_ -->
<ul class="toc simple" id="outline">
<li><a class="reference" href="./bitand.html" id="id480" name="id480">bitand_</a></li>
<li><a class="reference" href="./bitor.html" id="id481" name="id481">bitor_</a></li>
<li><a class="reference" href="./bitxor.html" id="id482" name="id482">bitxor_</a></li>
<li><a class="reference" href="./shift-left.html" id="id483" name="id483">shift_left</a></li>
<li><a class="reference" href="./shift-right.html" id="id484" name="id484">shift_right</a></li>
</ul>
</div>
<div class="footer-separator"></div>
<table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./not.html" class="navigation-link">Prev</a>&nbsp;<a href="./bitand.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./logical-operations.html" class="navigation-link">Back</a>&nbsp;<a href="./trivial.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./metafunctions.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>
</tr></table></body>
</html>
+150
View File
@@ -0,0 +1,150 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.3.6: http://docutils.sourceforge.net/" />
<title>The MPL Reference Manual: bitxor_</title>
<link rel="stylesheet" href="../style.css" type="text/css" />
</head>
<body class="docframe refmanual">
<table class="header"><tr class="header"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./bitor.html" class="navigation-link">Prev</a>&nbsp;<a href="./shift-left.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./bitor.html" class="navigation-link">Back</a>&nbsp;<a href="./shift-left.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./bitwise-operations.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>
<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="./bitwise-operations.html" class="navigation-link">Bitwise Operations</a> / <a href="./bitxor.html" class="navigation-link">bitxor_</a></td>
</tr></table><div class="header-separator"></div>
<div class="section" id="bitxor">
<h1><a class="toc-backref" href="./bitwise-operations.html#id482" name="bitxor">bitxor_</a></h1>
<div class="section" id="bitxor-synopsis">
<h3><a class="subsection-title" href="#synopsis" name="synopsis">Synopsis</a></h3>
<pre class="literal-block">
template&lt;
typename T1
, typename T2
, typename T3 = <em>unspecified</em>
<em>...</em>
, typename T<em>n</em> = <em>unspecified</em>
&gt;
struct <a href="./bitxor.html" class="identifier">bitxor_</a>
{
typedef <em>unspecified</em> type;
};
</pre>
</div>
<div class="section" id="bitxor-description">
<h3><a class="subsection-title" href="#description" name="description">Description</a></h3>
<p>Returns the result of <em>bitwise xor</em> (<tt class="literal"><span class="pre">^</span></tt>) operation of its arguments.</p>
</div>
<div class="section" id="bitxor-header">
<h3><a class="subsection-title" href="#header" name="header">Header</a></h3>
<pre class="literal-block">
#include &lt;<a href="../../../../boost/mpl/bitxor.hpp" class="header">boost/mpl/bitxor.hpp</a>&gt;
#include &lt;<a href="../../../../boost/mpl/bitwise.hpp" class="header">boost/mpl/bitwise.hpp</a>&gt;
</pre>
</div>
<div class="section" id="bitxor-model-of">
<h3><a class="subsection-title" href="#model-of" name="model-of">Model of</a></h3>
<p><a class="reference" href="./numeric-metafunction.html">Numeric Metafunction</a></p>
</div>
<div class="section" id="bitxor-parameters">
<h3><a class="subsection-title" href="#parameters" name="parameters">Parameters</a></h3>
<table border="1" class="table">
<colgroup>
<col width="17%" />
<col width="30%" />
<col width="53%" />
</colgroup>
<thead valign="bottom">
<tr><th>Parameter</th>
<th>Requirement</th>
<th>Description</th>
</tr>
</thead>
<tbody valign="top">
<tr><td><tt class="literal"><span class="pre">T1</span></tt>, <tt class="literal"><span class="pre">T2</span></tt>,... <tt class="literal"><span class="pre">Tn</span></tt></td>
<td><a class="reference" href="./integral-constant.html">Integral Constant</a></td>
<td>Operation's arguments.</td>
</tr>
</tbody>
</table>
<p>[<em>Note:</em> The requirements listed in this specification
are the ones imposed by the default implementation. See <a class="reference" href="./numeric-metafunction.html">Numeric Metafunction</a> concept
for the details on how to provide an implementation for a user-defined numeric type
that does not satisfy the <a class="reference" href="./integral-constant.html">Integral Constant</a> requirements. — <em>end note</em>]</p>
</div>
<div class="section" id="bitxor-expression-semantics">
<h3><a class="subsection-title" href="#expression-semantics" name="expression-semantics">Expression semantics</a></h3>
<p>For any <a class="reference" href="./integral-constant.html">Integral Constant</a>s <em>c</em><sub>1</sub>,<em>c</em><sub>2</sub>,... <em>c</em><sub>n</sub>:</p>
<pre class="literal-block">
typedef <a href="./bitxor.html" class="identifier">bitxor_</a>&lt;c1,<em>...</em>c<em>n</em>&gt;::type r;
</pre>
<table class="field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Return type:</th><td class="field-body"><a class="reference" href="./integral-constant.html">Integral Constant</a>.</td>
</tr>
<tr class="field"><th class="field-name">Semantics:</th><td class="field-body"><p class="first">Equivalent to</p>
<pre class="last literal-block">
typedef <a href="./integral-c.html" class="identifier">integral_c</a>&lt;
typeof(c1::value ^ c2::value)
, ( c1::value ^ c2::value )
&gt; c;
typedef <a href="./bitxor.html" class="identifier">bitxor_</a>&lt;c,c3,<em>...</em>c<em>n</em>&gt;::type r;
</pre>
</td>
</tr>
</tbody>
</table>
<!-- .......................................................................... -->
<pre class="literal-block">
typedef <a href="./bitxor.html" class="identifier">bitxor_</a>&lt;c1,<em>...</em>c<em>n</em>&gt; r;
</pre>
<table class="field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Return type:</th><td class="field-body"><a class="reference" href="./integral-constant.html">Integral Constant</a>.</td>
</tr>
<tr class="field"><th class="field-name">Semantics:</th><td class="field-body"><p class="first">Equivalent to</p>
<pre class="last literal-block">
struct r : <a href="./bitxor.html" class="identifier">bitxor_</a>&lt;c1,<em>...</em>c<em>n</em>&gt;::type {};
</pre>
</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="bitxor-complexity">
<h3><a class="subsection-title" href="#complexity" name="complexity">Complexity</a></h3>
<p>Amortized constant time.</p>
</div>
<div class="section" id="bitxor-example">
<h3><a class="subsection-title" href="#example" name="example">Example</a></h3>
<pre class="literal-block">
typedef <a href="./integral-c.html" class="identifier">integral_c</a>&lt;unsigned,0&gt; u0;
typedef <a href="./integral-c.html" class="identifier">integral_c</a>&lt;unsigned,1&gt; u1;
typedef <a href="./integral-c.html" class="identifier">integral_c</a>&lt;unsigned,2&gt; u2;
typedef <a href="./integral-c.html" class="identifier">integral_c</a>&lt;unsigned,8&gt; u8;
typedef <a href="./integral-c.html" class="identifier">integral_c</a>&lt;unsigned,0xffffffff&gt; uffffffff;
<a href="./assert-relation.html" class="identifier">BOOST_MPL_ASSERT_RELATION</a>( (<a href="./bitxor.html" class="identifier">bitxor_</a>&lt;u0,u0&gt;::value), ==, 0 );
<a href="./assert-relation.html" class="identifier">BOOST_MPL_ASSERT_RELATION</a>( (<a href="./bitxor.html" class="identifier">bitxor_</a>&lt;u1,u0&gt;::value), ==, 1 );
<a href="./assert-relation.html" class="identifier">BOOST_MPL_ASSERT_RELATION</a>( (<a href="./bitxor.html" class="identifier">bitxor_</a>&lt;u0,u1&gt;::value), ==, 1 );
<a href="./assert-relation.html" class="identifier">BOOST_MPL_ASSERT_RELATION</a>( (<a href="./bitxor.html" class="identifier">bitxor_</a>&lt;u0,uffffffff&gt;::value), ==, 0xffffffff ^ 0 );
<a href="./assert-relation.html" class="identifier">BOOST_MPL_ASSERT_RELATION</a>( (<a href="./bitxor.html" class="identifier">bitxor_</a>&lt;u1,uffffffff&gt;::value), ==, 0xffffffff ^ 1 );
<a href="./assert-relation.html" class="identifier">BOOST_MPL_ASSERT_RELATION</a>( (<a href="./bitxor.html" class="identifier">bitxor_</a>&lt;u8,uffffffff&gt;::value), ==, 0xffffffff ^ 8 );
</pre>
</div>
<div class="section" id="bitxor-see-also">
<h3><a class="subsection-title" href="#see-also" name="see-also">See also</a></h3>
<p><a class="reference" href="./bitwise-operations.html">Bitwise Operations</a>, <a class="reference" href="./numeric-metafunction.html">Numeric Metafunction</a>, <a class="refentry reference" href="./numeric-cast.html"><tt class="refentry literal"><span class="pre">numeric_cast</span></tt></a>, <a class="refentry reference" href="./bitand.html"><tt class="refentry literal"><span class="pre">bitand_</span></tt></a>, <a class="refentry reference" href="./bitor.html"><tt class="refentry literal"><span class="pre">bitor_</span></tt></a>, <a class="refentry reference" href="./shift-left.html"><tt class="refentry literal"><span class="pre">shift_left</span></tt></a></p>
<!-- modtime: November 13, 2004 02:03:30 +0000 -->
<!-- Metafunctions/Bitwise Operations//shift_left -->
</div>
</div>
<div class="footer-separator"></div>
<table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./bitor.html" class="navigation-link">Prev</a>&nbsp;<a href="./shift-left.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./bitor.html" class="navigation-link">Back</a>&nbsp;<a href="./shift-left.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./bitwise-operations.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>
</tr></table></body>
</html>
+112
View File
@@ -0,0 +1,112 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.3.6: http://docutils.sourceforge.net/" />
<title>The MPL Reference Manual: bool_</title>
<link rel="stylesheet" href="../style.css" type="text/css" />
</head>
<body class="docframe refmanual">
<table class="header"><tr class="header"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./numeric.html" class="navigation-link">Prev</a>&nbsp;<a href="./int.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group">Back&nbsp;<a href="./int.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./numeric.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>
<td class="header-group page-location"><a href="../refmanual.html" class="navigation-link">Front Page</a> / <a href="./data-types.html" class="navigation-link">Data Types</a> / <a href="./numeric.html" class="navigation-link">Numeric</a> / <a href="./bool.html" class="navigation-link">bool_</a></td>
</tr></table><div class="header-separator"></div>
<div class="section" id="bool">
<h1><a class="toc-backref" href="./numeric.html#id500" name="bool">bool_</a></h1>
<div class="section" id="bool-synopsis">
<h3><a class="subsection-title" href="#synopsis" name="synopsis">Synopsis</a></h3>
<pre class="literal-block">
template&lt;
bool C
&gt;
struct <a href="./bool.html" class="identifier">bool_</a>
{
// <em>unspecified</em>
// ...
};
typedef <a href="./bool.html" class="identifier">bool_</a>&lt;true&gt; true_;
typedef <a href="./bool.html" class="identifier">bool_</a>&lt;false&gt; false_;
</pre>
</div>
<div class="section" id="bool-description">
<h3><a class="subsection-title" href="#description" name="description">Description</a></h3>
<p>A boolean <a class="reference" href="./integral-constant.html">Integral Constant</a> wrapper.</p>
</div>
<div class="section" id="bool-header">
<h3><a class="subsection-title" href="#header" name="header">Header</a></h3>
<pre class="literal-block">
#include &lt;<a href="../../../../boost/mpl/bool.hpp" class="header">boost/mpl/bool.hpp</a>&gt;
</pre>
</div>
<div class="section" id="bool-model-of">
<h3><a class="subsection-title" href="#model-of" name="model-of">Model of</a></h3>
<p><a class="reference" href="./integral-constant.html">Integral Constant</a></p>
</div>
<div class="section" id="bool-parameters">
<h3><a class="subsection-title" href="#parameters" name="parameters">Parameters</a></h3>
<table border="1" class="table">
<colgroup>
<col width="21%" />
<col width="42%" />
<col width="37%" />
</colgroup>
<thead valign="bottom">
<tr><th>Parameter</th>
<th>Requirement</th>
<th>Description</th>
</tr>
</thead>
<tbody valign="top">
<tr><td><tt class="literal"><span class="pre">C</span></tt></td>
<td>A boolean integral constant</td>
<td>A value to wrap.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="bool-expression-semantics">
<h3><a class="subsection-title" href="#expression-semantics" name="expression-semantics">Expression semantics</a></h3>
<p>The semantics of an expression are defined only
where they differ from, or are not defined in <a class="reference" href="./integral-constant.html">Integral Constant</a>.</p>
<p>For arbitrary integral constant <tt class="literal"><span class="pre">c</span></tt>:</p>
<table border="1" class="table">
<colgroup>
<col width="24%" />
<col width="76%" />
</colgroup>
<thead valign="bottom">
<tr><th>Expression</th>
<th>Semantics</th>
</tr>
</thead>
<tbody valign="top">
<tr><td><tt class="literal"><span class="pre"><a href="./bool.html" class="identifier">bool_</a>&lt;c&gt;</span></tt></td>
<td>An <a class="reference" href="./integral-constant.html">Integral Constant</a> <tt class="literal"><span class="pre">x</span></tt> such that <tt class="literal"><span class="pre">x::value</span> <span class="pre">==</span> <span class="pre">c</span></tt>
and <tt class="literal"><span class="pre">x::<a href="./value-type.html" class="identifier">value_type</a></span></tt> is identical to <tt class="literal"><span class="pre">bool</span></tt>.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="bool-example">
<h3><a class="subsection-title" href="#example" name="example">Example</a></h3>
<pre class="literal-block">
<a href="./assert.html" class="identifier">BOOST_MPL_ASSERT</a>(( is_same&lt; <a href="./bool.html" class="identifier">bool_</a>&lt;true&gt;::<a href="./value-type.html" class="identifier">value_type</a>, bool &gt; ));
<a href="./assert.html" class="identifier">BOOST_MPL_ASSERT</a>(( is_same&lt; <a href="./bool.html" class="identifier">bool_</a>&lt;true&gt;, <a class="reference" href="./bool.html"><tt class="literal"><span class="pre">true_</span></tt></a> &gt; )); }
<a href="./assert.html" class="identifier">BOOST_MPL_ASSERT</a>(( is_same&lt; <a href="./bool.html" class="identifier">bool_</a>&lt;true&gt;::type, <a href="./bool.html" class="identifier">bool_</a>&lt;true&gt; &gt; ));
<a href="./assert-relation.html" class="identifier">BOOST_MPL_ASSERT_RELATION</a>( <a href="./bool.html" class="identifier">bool_</a>&lt;true&gt;::value, ==, true );
assert( <a href="./bool.html" class="identifier">bool_</a>&lt;true&gt;() == true );
</pre>
</div>
<div class="section" id="bool-see-also">
<h3><a class="subsection-title" href="#see-also" name="see-also">See also</a></h3>
<p><a class="reference" href="./data-types.html">Data Types</a>, <a class="reference" href="./integral-constant.html">Integral Constant</a>, <a class="refentry reference" href="./int.html"><tt class="refentry literal"><span class="pre">int_</span></tt></a>, <a class="refentry reference" href="./long.html"><tt class="refentry literal"><span class="pre">long_</span></tt></a>, <a class="refentry reference" href="./integral-c.html"><tt class="refentry literal"><span class="pre">integral_c</span></tt></a></p>
<!-- modtime: November 10, 2004 04:44:19 +0000 -->
<!-- Data Types/Numeric//int_ |20 -->
</div>
</div>
<div class="footer-separator"></div>
<table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./numeric.html" class="navigation-link">Prev</a>&nbsp;<a href="./int.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group">Back&nbsp;<a href="./int.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./numeric.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>
</tr></table></body>
</html>
+25
View File
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.3.6: http://docutils.sourceforge.net/" />
<title>The MPL Reference Manual: Broken Compiler Workarounds</title>
<link rel="stylesheet" href="../style.css" type="text/css" />
</head>
<body class="docframe refmanual">
<table class="header"><tr class="header"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./limit-unrolling.html" class="navigation-link">Prev</a>&nbsp;<a href="./aux-lambda-support.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./configuration.html" class="navigation-link">Back</a>&nbsp;Along</span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./macros.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>
<td class="header-group page-location"><a href="../refmanual.html" class="navigation-link">Front Page</a> / <a href="./macros.html" class="navigation-link">Macros</a> / <a href="./broken-compiler.html" class="navigation-link">Broken Compiler Workarounds</a></td>
</tr></table><div class="header-separator"></div>
<div class="section" id="broken-compiler">
<h1><a class="toc-backref" href="./macros.html#id527" name="broken-compiler">Broken Compiler Workarounds</a></h1>
<a class="target" id="label-macros-broken" name="label-macros-broken"></a><!-- Macros/Broken Compiler Workarounds//BOOST_MPL_AUX_LAMBDA_SUPPORT -->
<ul class="toc simple" id="outline">
<li><a class="reference" href="./aux-lambda-support.html" id="id528" name="id528">BOOST_MPL_AUX_LAMBDA_SUPPORT</a></li>
</ul>
</div>
<div class="footer-separator"></div>
<table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./limit-unrolling.html" class="navigation-link">Prev</a>&nbsp;<a href="./aux-lambda-support.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./configuration.html" class="navigation-link">Back</a>&nbsp;Along</span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./macros.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>
</tr></table></body>
</html>
+46
View File
@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.3.6: http://docutils.sourceforge.net/" />
<title>The MPL Reference Manual: Concepts</title>
<link rel="stylesheet" href="../style.css" type="text/css" />
</head>
<body class="docframe refmanual">
<table class="header"><tr class="header"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./categorized-index.html" class="navigation-link">Prev</a>&nbsp;<a href="./components.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group">Back&nbsp;<a href="./components.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./categorized-index.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>
<td class="header-group page-location"><a href="../refmanual.html" class="navigation-link">Front Page</a> / <a href="./categorized-index.html" class="navigation-link">Categorized Index</a> / <a href="./categorized-concepts.html" class="navigation-link">Concepts</a></td>
</tr></table><div class="header-separator"></div>
<div class="section" id="categorized-concepts">
<h1><a class="toc-backref" href="./categorized-index.html#id531" name="categorized-concepts">Concepts</a></h1>
<ul class="simple">
<li><a class="reference" href="./associative-sequence.html">Associative Sequence</a></li>
<li><a class="reference" href="./back-extensible-sequence.html">Back Extensible Sequence</a></li>
<li><a class="reference" href="./bidirectional-iterator.html">Bidirectional Iterator</a></li>
<li><a class="reference" href="./bidirectional-sequence.html">Bidirectional Sequence</a></li>
<li><a class="reference" href="./extensible-associative.html">Extensible Associative Sequence</a></li>
<li><a class="reference" href="./extensible-sequence.html">Extensible Sequence</a></li>
<li><a class="reference" href="./forward-iterator.html">Forward Iterator</a></li>
<li><a class="reference" href="./forward-sequence.html">Forward Sequence</a></li>
<li><a class="reference" href="./front-extensible-sequence.html">Front Extensible Sequence</a></li>
<li><a class="reference" href="./inserter.html">Inserter</a></li>
<li><a class="reference" href="./integral-constant.html">Integral Constant</a></li>
<li><a class="reference" href="./integral-sequence-wrapper.html">Integral Sequence Wrapper</a></li>
<li><a class="reference" href="./lambda-expression.html">Lambda Expression</a></li>
<li><a class="reference" href="./metafunction.html">Metafunction</a></li>
<li><a class="reference" href="./metafunction-class.html">Metafunction Class</a></li>
<li><a class="reference" href="./numeric-metafunction.html">Numeric Metafunction</a></li>
<li><a class="reference" href="./placeholder-expression.html">Placeholder Expression</a></li>
<li><a class="reference" href="./random-access-iterator.html">Random Access Iterator</a></li>
<li><a class="reference" href="./random-access-sequence.html">Random Access Sequence</a></li>
<li><a class="reference" href="./reversible-algorithm.html">Reversible Algorithm</a></li>
<li><a class="reference" href="./tag-dispatched.html">Tag Dispatched Metafunction</a></li>
<li><a class="reference" href="./trivial-metafunction.html">Trivial Metafunction</a></li>
<li><a class="reference" href="./variadic-sequence.html">Variadic Sequence</a></li>
</ul>
</div>
<div class="footer-separator"></div>
<table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./categorized-index.html" class="navigation-link">Prev</a>&nbsp;<a href="./components.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group">Back&nbsp;<a href="./components.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./categorized-index.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>
</tr></table></body>
</html>
+25
View File
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.3.6: http://docutils.sourceforge.net/" />
<title>The MPL Reference Manual: Categorized Index</title>
<link rel="stylesheet" href="../style.css" type="text/css" />
</head>
<body class="docframe refmanual">
<table class="header"><tr class="header"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./terminology.html" class="navigation-link">Prev</a>&nbsp;<a href="./categorized-concepts.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./terminology.html" class="navigation-link">Back</a>&nbsp;<a href="./acknowledgements.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="../refmanual.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>
<td class="header-group page-location"><a href="../refmanual.html" class="navigation-link">Front Page</a> / <a href="./categorized-index.html" class="navigation-link">Categorized Index</a></td>
</tr></table><div class="header-separator"></div>
<div class="section" id="categorized-index">
<h1><a class="toc-backref" href="../refmanual.html#id530" name="categorized-index">Categorized Index</a></h1>
<a class="target" id="label-categorized-index" name="label-categorized-index"></a><a class="target" id="categorized" name="categorized"></a><ul class="toc simple" id="outline">
<li><a class="reference" href="./categorized-concepts.html" id="id531" name="id531">Concepts</a></li>
<li><a class="reference" href="./components.html" id="id532" name="id532">Components</a></li>
</ul>
</div>
<div class="footer-separator"></div>
<table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./terminology.html" class="navigation-link">Prev</a>&nbsp;<a href="./categorized-concepts.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./terminology.html" class="navigation-link">Back</a>&nbsp;<a href="./acknowledgements.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="../refmanual.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>
</tr></table></body>
</html>
+40
View File
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.3.6: http://docutils.sourceforge.net/" />
<title>The MPL Reference Manual: BOOST_MPL_CFG_NO_HAS_XXX</title>
<link rel="stylesheet" href="../style.css" type="text/css" />
</head>
<body class="docframe refmanual">
<table class="header"><tr class="header"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./cfg-no-preprocessed.html" class="navigation-link">Prev</a>&nbsp;<a href="./limit-metafunction-arity.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./cfg-no-preprocessed.html" class="navigation-link">Back</a>&nbsp;<a href="./limit-metafunction-arity.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./configuration.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>
<td class="header-group page-location"><a href="../refmanual.html" class="navigation-link">Front Page</a> / <a href="./macros.html" class="navigation-link">Macros</a> / <a href="./configuration.html" class="navigation-link">Configuration</a> / <a href="./cfg-no-has-xxx.html" class="navigation-link">BOOST_MPL_CFG_NO_HAS_XXX</a></td>
</tr></table><div class="header-separator"></div>
<div class="section" id="cfg-no-has-xxx">
<h1><a class="toc-backref" href="./configuration.html#id520" name="cfg-no-has-xxx">BOOST_MPL_CFG_NO_HAS_XXX</a></h1>
<div class="section" id="configuration-cfg-synopsis">
<h3><a class="subsection-title" href="#synopsis" name="synopsis">Synopsis</a></h3>
<pre class="literal-block">
// #define <a href="./cfg-no-has-xxx.html" class="identifier">BOOST_MPL_CFG_NO_HAS_XXX</a>
</pre>
</div>
<div class="section" id="configuration-cfg-description">
<h3><a class="subsection-title" href="#description" name="description">Description</a></h3>
<p><tt class="literal"><span class="pre"><a href="./cfg-no-has-xxx.html" class="identifier">BOOST_MPL_CFG_NO_HAS_XXX</a></span></tt> is an boolean configuration macro
signaling availability of the <a class="refentry reference" href="./has-xxx-trait-def.html"><tt class="refentry literal"><span class="pre">BOOST_MPL_HAS_XXX_TRAIT_DEF</span></tt></a> /
<a class="refentry reference" href="./has-xxx-trait-named-def.html"><tt class="refentry literal"><span class="pre">BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF</span></tt></a> introspection macros' functionality
on a particular compiler.</p>
</div>
<div class="section" id="configuration-cfg-see-also">
<h3><a class="subsection-title" href="#see-also" name="see-also">See also</a></h3>
<p><a class="reference" href="./macros.html">Macros</a>, <a class="reference" href="./configuration.html">Configuration</a>, <a class="refentry reference" href="./has-xxx-trait-def.html"><tt class="refentry literal"><span class="pre">BOOST_MPL_HAS_XXX_TRAIT_DEF</span></tt></a>, <a class="refentry reference" href="./has-xxx-trait-named-def.html"><tt class="refentry literal"><span class="pre">BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF</span></tt></a></p>
<!-- modtime: November 10, 2004 04:44:13 +0000 -->
<!-- Macros/Configuration//BOOST_MPL_LIMIT_METAFUNCTION_ARITY |20 -->
</div>
</div>
<div class="footer-separator"></div>
<table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./cfg-no-preprocessed.html" class="navigation-link">Prev</a>&nbsp;<a href="./limit-metafunction-arity.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./cfg-no-preprocessed.html" class="navigation-link">Back</a>&nbsp;<a href="./limit-metafunction-arity.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./configuration.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>
</tr></table></body>
</html>
+46
View File
@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.3.6: http://docutils.sourceforge.net/" />
<title>The MPL Reference Manual: BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS</title>
<link rel="stylesheet" href="../style.css" type="text/css" />
</head>
<body class="docframe refmanual">
<table class="header"><tr class="header"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./configuration.html" class="navigation-link">Prev</a>&nbsp;<a href="./cfg-no-has-xxx.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group">Back&nbsp;<a href="./cfg-no-has-xxx.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./configuration.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>
<td class="header-group page-location"><a href="../refmanual.html" class="navigation-link">Front Page</a> / <a href="./macros.html" class="navigation-link">Macros</a> / <a href="./configuration.html" class="navigation-link">Configuration</a> / <a href="./cfg-no-preprocessed.html" class="navigation-link">BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS</a></td>
</tr></table><div class="header-separator"></div>
<div class="section" id="cfg-no-preprocessed">
<h1><a class="toc-backref" href="./configuration.html#id519" name="cfg-no-preprocessed">BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS</a></h1>
<a class="target" id="id294" name="id294"></a><div class="section" id="cfg-synopsis">
<h3><a class="subsection-title" href="#synopsis" name="synopsis">Synopsis</a></h3>
<pre class="literal-block">
// #define <a href="./cfg-no-preprocessed.html" class="identifier">BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS</a>
</pre>
</div>
<div class="section" id="cfg-description">
<h3><a class="subsection-title" href="#description" name="description">Description</a></h3>
<p><tt class="literal"><span class="pre"><a href="./cfg-no-preprocessed.html" class="identifier">BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS</a></span></tt> is an boolean configuration macro
regulating library's internal use of preprocessed headers. When defined, it
instructs the MPL to discard the pre-generated headers found in
<tt class="literal"><span class="pre">boost/mpl/aux_/preprocessed</span></tt> directory and use <a class="reference" href="http://boost-consulting.com/tmpbook/preprocessor.html" target="_top">preprocessor
metaprogramming</a> techniques to generate the necessary versions of the
library components on the fly.</p>
<p>In this implementation of the library, the macro is not defined by default.
To change the default configuration, define
<tt class="literal"><span class="pre"><a href="./cfg-no-preprocessed.html" class="identifier">BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS</a></span></tt> before including any library
header.</p>
</div>
<div class="section" id="cfg-see-also">
<h3><a class="subsection-title" href="#see-also" name="see-also">See also</a></h3>
<p><a class="reference" href="./macros.html">Macros</a>, <a class="reference" href="./configuration.html">Configuration</a></p>
<!-- modtime: November 15, 2004 01:55:35 +0000 -->
<!-- Macros/Configuration//BOOST_MPL_CFG_NO_HAS_XXX |20 -->
</div>
</div>
<div class="footer-separator"></div>
<table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./configuration.html" class="navigation-link">Prev</a>&nbsp;<a href="./cfg-no-has-xxx.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group">Back&nbsp;<a href="./cfg-no-has-xxx.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./configuration.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>
</tr></table></body>
</html>
+38
View File
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.3.6: http://docutils.sourceforge.net/" />
<title>The MPL Reference Manual: Classes</title>
<link rel="stylesheet" href="../style.css" type="text/css" />
</head>
<body class="docframe refmanual">
<table class="header"><tr class="header"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./variadic-sequence.html" class="navigation-link">Prev</a>&nbsp;<a href="./vector.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./concepts.html" class="navigation-link">Back</a>&nbsp;<a href="./views.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./sequences.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>
<td class="header-group page-location"><a href="../refmanual.html" class="navigation-link">Front Page</a> / <a href="./sequences.html" class="navigation-link">Sequences</a> / <a href="./classes.html" class="navigation-link">Classes</a></td>
</tr></table><div class="header-separator"></div>
<div class="section" id="classes">
<h1><a class="toc-backref" href="./sequences.html#id334" name="classes">Classes</a></h1>
<a class="target" id="label-sequences-classes" name="label-sequences-classes"></a><p>The MPL provides a large number of predefined general-purpose sequence
classes covering most of the typical metaprogramming needs out-of-box.</p>
<!-- For all library-supplied sequences a publicly-derived class with no additional
members is equivalent except for type identity. -->
<!-- modtime: October 25, 2004 06:16:07 +0000 -->
<!-- Sequences/Classes//vector |10 -->
<ul class="toc simple" id="outline">
<li><a class="reference" href="./vector.html" id="id335" name="id335">vector</a></li>
<li><a class="reference" href="./list.html" id="id336" name="id336">list</a></li>
<li><a class="reference" href="./deque.html" id="id337" name="id337">deque</a></li>
<li><a class="reference" href="./set.html" id="id338" name="id338">set</a></li>
<li><a class="reference" href="./map.html" id="id339" name="id339">map</a></li>
<li><a class="reference" href="./range-c.html" id="id340" name="id340">range_c</a></li>
<li><a class="reference" href="./vector-c.html" id="id341" name="id341">vector_c</a></li>
<li><a class="reference" href="./list-c.html" id="id342" name="id342">list_c</a></li>
<li><a class="reference" href="./set-c.html" id="id343" name="id343">set_c</a></li>
</ul>
</div>
<div class="footer-separator"></div>
<table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./variadic-sequence.html" class="navigation-link">Prev</a>&nbsp;<a href="./vector.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./concepts.html" class="navigation-link">Back</a>&nbsp;<a href="./views.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./sequences.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>
</tr></table></body>
</html>
+112
View File
@@ -0,0 +1,112 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.3.6: http://docutils.sourceforge.net/" />
<title>The MPL Reference Manual: clear</title>
<link rel="stylesheet" href="../style.css" type="text/css" />
</head>
<body class="docframe refmanual">
<table class="header"><tr class="header"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./begin.html" class="navigation-link">Prev</a>&nbsp;<a href="./empty.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./begin.html" class="navigation-link">Back</a>&nbsp;<a href="./empty.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./intrinsic-metafunctions.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>
<td class="header-group page-location"><a href="../refmanual.html" class="navigation-link">Front Page</a> / <a href="./sequences.html" class="navigation-link">Sequences</a> / <a href="./intrinsic-metafunctions.html" class="navigation-link">Intrinsic Metafunctions</a> / <a href="./clear.html" class="navigation-link">clear</a></td>
</tr></table><div class="header-separator"></div>
<div class="section" id="clear">
<h1><a class="toc-backref" href="./intrinsic-metafunctions.html#id357" name="clear">clear</a></h1>
<div class="section" id="clear-synopsis">
<h3><a class="subsection-title" href="#synopsis" name="synopsis">Synopsis</a></h3>
<pre class="literal-block">
template&lt;
typename Sequence
&gt;
struct <a href="./clear.html" class="identifier">clear</a>
{
typedef <em>unspecified</em> type;
};
</pre>
</div>
<div class="section" id="clear-description">
<h3><a class="subsection-title" href="#description" name="description">Description</a></h3>
<p>Returns an empty sequence <a class="reference" href="./terminology.html#concept-identical">concept-identical</a> to <tt class="literal"><span class="pre">Sequence</span></tt>.</p>
</div>
<div class="section" id="clear-header">
<h3><a class="subsection-title" href="#header" name="header">Header</a></h3>
<pre class="literal-block">
#include &lt;<a href="../../../../boost/mpl/clear.hpp" class="header">boost/mpl/clear.hpp</a>&gt;
</pre>
</div>
<div class="section" id="clear-model-of">
<h3><a class="subsection-title" href="#model-of" name="model-of">Model of</a></h3>
<p><a class="reference" href="./tag-dispatched.html">Tag Dispatched Metafunction</a></p>
</div>
<div class="section" id="clear-parameters">
<h3><a class="subsection-title" href="#parameters" name="parameters">Parameters</a></h3>
<table border="1" class="table">
<colgroup>
<col width="17%" />
<col width="39%" />
<col width="44%" />
</colgroup>
<thead valign="bottom">
<tr><th>Parameter</th>
<th>Requirement</th>
<th>Description</th>
</tr>
</thead>
<tbody valign="top">
<tr><td><tt class="literal"><span class="pre">Sequence</span></tt></td>
<td><a class="reference" href="./extensible-sequence.html">Extensible Sequence</a> or
<a class="reference" href="./extensible-associative.html">Extensible Associative Sequence</a></td>
<td>A sequence to get an empty &quot;copy&quot; of.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="clear-expression-semantics">
<h3><a class="subsection-title" href="#expression-semantics" name="expression-semantics">Expression semantics</a></h3>
<p>For any <a class="reference" href="./extensible-sequence.html">Extensible Sequence</a> or <a class="reference" href="./extensible-associative.html">Extensible Associative Sequence</a> <tt class="literal"><span class="pre">s</span></tt>:</p>
<pre class="literal-block">
typedef <a href="./clear.html" class="identifier">clear</a>&lt;s&gt;::type t;
</pre>
<table class="field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Return type:</th><td class="field-body"><a class="reference" href="./extensible-sequence.html">Extensible Sequence</a> or <a class="reference" href="./extensible-associative.html">Extensible Associative Sequence</a>.</td>
</tr>
<tr class="field"><th class="field-name">Semantics:</th><td class="field-body"><p class="first">Equivalent to</p>
<pre class="last literal-block">
typedef <a href="./erase.html" class="identifier">erase</a>&lt; s, <a href="./begin.html" class="identifier">begin</a>&lt;s&gt;::type, <a href="./end.html" class="identifier">end</a>&lt;s&gt;::type &gt;::type t;
</pre>
</td>
</tr>
<tr class="field"><th class="field-name">Postcondition:</th><td class="field-body"><tt class="literal"><span class="pre"><a href="./empty.html" class="identifier">empty</a>&lt;s&gt;::value</span> <span class="pre">==</span> <span class="pre">true</span></tt>.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="clear-complexity">
<h3><a class="subsection-title" href="#complexity" name="complexity">Complexity</a></h3>
<p>Amortized constant time.</p>
</div>
<div class="section" id="clear-example">
<h3><a class="subsection-title" href="#example" name="example">Example</a></h3>
<pre class="literal-block">
typedef <a href="./vector-c.html" class="identifier">vector_c</a>&lt;int,1,3,5,7,9,11&gt; odds;
typedef <a href="./clear.html" class="identifier">clear</a>&lt;odds&gt;::type nothing;
<a href="./assert.html" class="identifier">BOOST_MPL_ASSERT</a>(( <a href="./empty.html" class="identifier">empty</a>&lt;nothing&gt; ));
</pre>
</div>
<div class="section" id="clear-see-also">
<h3><a class="subsection-title" href="#see-also" name="see-also">See also</a></h3>
<p><a class="reference" href="./extensible-sequence.html">Extensible Sequence</a>, <a class="reference" href="./extensible-associative.html">Extensible Associative Sequence</a>, <a class="refentry reference" href="./erase.html"><tt class="refentry literal"><span class="pre">erase</span></tt></a>, <a class="refentry reference" href="./empty.html"><tt class="refentry literal"><span class="pre">empty</span></tt></a>, <a class="refentry reference" href="./begin.html"><tt class="refentry literal"><span class="pre">begin</span></tt></a>, <a class="refentry reference" href="./end.html"><tt class="refentry literal"><span class="pre">end</span></tt></a></p>
<!-- modtime: November 13, 2004 01:25:47 +0000 -->
<!-- Sequences/Intrinsic Metafunctions//empty -->
</div>
</div>
<div class="footer-separator"></div>
<table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./begin.html" class="navigation-link">Prev</a>&nbsp;<a href="./empty.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./begin.html" class="navigation-link">Back</a>&nbsp;<a href="./empty.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./intrinsic-metafunctions.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>
</tr></table></body>
</html>
+31
View File
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.3.6: http://docutils.sourceforge.net/" />
<title>The MPL Reference Manual: Comparisons</title>
<link rel="stylesheet" href="../style.css" type="text/css" />
</head>
<body class="docframe refmanual">
<table class="header"><tr class="header"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./negate.html" class="navigation-link">Prev</a>&nbsp;<a href="./less.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./arithmetic-operations.html" class="navigation-link">Back</a>&nbsp;<a href="./logical-operations.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./metafunctions.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>
<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="./comparisons.html" class="navigation-link">Comparisons</a></td>
</tr></table><div class="header-separator"></div>
<div class="section" id="comparisons">
<h1><a class="toc-backref" href="./metafunctions.html#id468" name="comparisons">Comparisons</a></h1>
<a class="target" id="id235" name="id235"></a><!-- modtime: November 08, 2004 06:50:08 +0000 -->
<!-- Metafunctions/Comparisons//less |10 -->
<ul class="toc simple" id="outline">
<li><a class="reference" href="./less.html" id="id469" name="id469">less</a></li>
<li><a class="reference" href="./less-equal.html" id="id470" name="id470">less_equal</a></li>
<li><a class="reference" href="./greater.html" id="id471" name="id471">greater</a></li>
<li><a class="reference" href="./greater-equal.html" id="id472" name="id472">greater_equal</a></li>
<li><a class="reference" href="./equal-to.html" id="id473" name="id473">equal_to</a></li>
<li><a class="reference" href="./not-equal-to.html" id="id474" name="id474">not_equal_to</a></li>
</ul>
</div>
<div class="footer-separator"></div>
<table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./negate.html" class="navigation-link">Prev</a>&nbsp;<a href="./less.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./arithmetic-operations.html" class="navigation-link">Back</a>&nbsp;<a href="./logical-operations.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./metafunctions.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>
</tr></table></body>
</html>
+173
View File
@@ -0,0 +1,173 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.3.6: http://docutils.sourceforge.net/" />
<title>The MPL Reference Manual: Components</title>
<link rel="stylesheet" href="../style.css" type="text/css" />
</head>
<body class="docframe refmanual">
<table class="header"><tr class="header"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./categorized-concepts.html" class="navigation-link">Prev</a>&nbsp;<a href="./acknowledgements.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./categorized-concepts.html" class="navigation-link">Back</a>&nbsp;Along</span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./categorized-index.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>
<td class="header-group page-location"><a href="../refmanual.html" class="navigation-link">Front Page</a> / <a href="./categorized-index.html" class="navigation-link">Categorized Index</a> / <a href="./components.html" class="navigation-link">Components</a></td>
</tr></table><div class="header-separator"></div>
<div class="section" id="components">
<h1><a class="toc-backref" href="./categorized-index.html#id532" name="components">Components</a></h1>
<ul class="simple">
<li><a class="refentry reference" href="./assert.html"><tt class="refentry literal"><span class="pre">BOOST_MPL_ASSERT</span></tt></a></li>
<li><a class="refentry reference" href="./assert-msg.html"><tt class="refentry literal"><span class="pre">BOOST_MPL_ASSERT_MSG</span></tt></a></li>
<li><a class="refentry reference" href="./assert-not.html"><tt class="refentry literal"><span class="pre">BOOST_MPL_ASSERT_NOT</span></tt></a></li>
<li><a class="refentry reference" href="./assert-relation.html"><tt class="refentry literal"><span class="pre">BOOST_MPL_ASSERT_RELATION</span></tt></a></li>
<li><a class="refentry reference" href="./aux-lambda-support.html"><tt class="refentry literal"><span class="pre">BOOST_MPL_AUX_LAMBDA_SUPPORT</span></tt></a></li>
<li><a class="refentry reference" href="./cfg-no-has-xxx.html"><tt class="refentry literal"><span class="pre">BOOST_MPL_CFG_NO_HAS_XXX</span></tt></a></li>
<li><a class="refentry reference" href="./cfg-no-preprocessed.html"><tt class="refentry literal"><span class="pre">BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS</span></tt></a></li>
<li><a class="refentry reference" href="./has-xxx-trait-def.html"><tt class="refentry literal"><span class="pre">BOOST_MPL_HAS_XXX_TRAIT_DEF</span></tt></a></li>
<li><a class="refentry reference" href="./has-xxx-trait-named-def.html"><tt class="refentry literal"><span class="pre">BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF</span></tt></a></li>
<li><a class="refentry reference" href="./limit-list-size.html"><tt class="refentry literal"><span class="pre">BOOST_MPL_LIMIT_LIST_SIZE</span></tt></a></li>
<li><a class="refentry reference" href="./limit-map-size.html"><tt class="refentry literal"><span class="pre">BOOST_MPL_LIMIT_MAP_SIZE</span></tt></a></li>
<li><a class="refentry reference" href="./limit-metafunction-arity.html"><tt class="refentry literal"><span class="pre">BOOST_MPL_LIMIT_METAFUNCTION_ARITY</span></tt></a></li>
<li><a class="refentry reference" href="./limit-set-size.html"><tt class="refentry literal"><span class="pre">BOOST_MPL_LIMIT_SET_SIZE</span></tt></a></li>
<li><a class="refentry reference" href="./limit-unrolling.html"><tt class="refentry literal"><span class="pre">BOOST_MPL_LIMIT_UNROLLING</span></tt></a></li>
<li><a class="refentry reference" href="./limit-vector-size.html"><tt class="refentry literal"><span class="pre">BOOST_MPL_LIMIT_VECTOR_SIZE</span></tt></a></li>
<li><a class="refentry reference" href="./placeholders.html"><tt class="refentry literal"><span class="pre">_1</span></tt></a>, <a class="refentry reference" href="./placeholders.html"><tt class="refentry literal"><span class="pre">_2</span></tt></a>, <a class="refentry reference" href="./placeholders.html"><tt class="refentry literal"><span class="pre">_3</span></tt></a>,<em>...</em></li>
<li><a class="refentry reference" href="./accumulate.html"><tt class="refentry literal"><span class="pre">accumulate</span></tt></a></li>
<li><a class="refentry reference" href="./advance.html"><tt class="refentry literal"><span class="pre">advance</span></tt></a></li>
<li><a class="refentry reference" href="./always.html"><tt class="refentry literal"><span class="pre">always</span></tt></a></li>
<li><a class="refentry reference" href="./and.html"><tt class="refentry literal"><span class="pre">and_</span></tt></a></li>
<li><a class="refentry reference" href="./apply.html"><tt class="refentry literal"><span class="pre">apply</span></tt></a></li>
<li><a class="refentry reference" href="./apply-wrap.html"><tt class="refentry literal"><span class="pre">apply_wrap</span></tt></a></li>
<li><a class="refentry reference" href="./arg.html"><tt class="refentry literal"><span class="pre">arg</span></tt></a></li>
<li><a class="refentry reference" href="./at.html"><tt class="refentry literal"><span class="pre">at</span></tt></a></li>
<li><a class="refentry reference" href="./at-c.html"><tt class="refentry literal"><span class="pre">at_c</span></tt></a></li>
<li><a class="refentry reference" href="./back.html"><tt class="refentry literal"><span class="pre">back</span></tt></a></li>
<li><a class="refentry reference" href="./back-inserter.html"><tt class="refentry literal"><span class="pre">back_inserter</span></tt></a></li>
<li><a class="refentry reference" href="./begin.html"><tt class="refentry literal"><span class="pre">begin</span></tt></a></li>
<li><a class="refentry reference" href="./bind.html"><tt class="refentry literal"><span class="pre">bind</span></tt></a></li>
<li><a class="refentry reference" href="./bitand.html"><tt class="refentry literal"><span class="pre">bitand_</span></tt></a></li>
<li><a class="refentry reference" href="./bitor.html"><tt class="refentry literal"><span class="pre">bitor_</span></tt></a></li>
<li><a class="refentry reference" href="./bitxor.html"><tt class="refentry literal"><span class="pre">bitxor_</span></tt></a></li>
<li><a class="refentry reference" href="./bool.html"><tt class="refentry literal"><span class="pre">bool_</span></tt></a></li>
<li><a class="refentry reference" href="./clear.html"><tt class="refentry literal"><span class="pre">clear</span></tt></a></li>
<li><a class="refentry reference" href="./contains.html"><tt class="refentry literal"><span class="pre">contains</span></tt></a></li>
<li><a class="refentry reference" href="./copy.html"><tt class="refentry literal"><span class="pre">copy</span></tt></a></li>
<li><a class="refentry reference" href="./copy-if.html"><tt class="refentry literal"><span class="pre">copy_if</span></tt></a></li>
<li><a class="refentry reference" href="./count.html"><tt class="refentry literal"><span class="pre">count</span></tt></a></li>
<li><a class="refentry reference" href="./count-if.html"><tt class="refentry literal"><span class="pre">count_if</span></tt></a></li>
<li><a class="refentry reference" href="./deque.html"><tt class="refentry literal"><span class="pre">deque</span></tt></a></li>
<li><a class="refentry reference" href="./deref.html"><tt class="refentry literal"><span class="pre">deref</span></tt></a></li>
<li><a class="refentry reference" href="./distance.html"><tt class="refentry literal"><span class="pre">distance</span></tt></a></li>
<li><a class="refentry reference" href="./divides.html"><tt class="refentry literal"><span class="pre">divides</span></tt></a></li>
<li><a class="refentry reference" href="./empty.html"><tt class="refentry literal"><span class="pre">empty</span></tt></a></li>
<li><a class="refentry reference" href="./empty-base.html"><tt class="refentry literal"><span class="pre">empty_base</span></tt></a></li>
<li><a class="refentry reference" href="./empty-sequence.html"><tt class="refentry literal"><span class="pre">empty_sequence</span></tt></a></li>
<li><a class="refentry reference" href="./end.html"><tt class="refentry literal"><span class="pre">end</span></tt></a></li>
<li><a class="refentry reference" href="./equal.html"><tt class="refentry literal"><span class="pre">equal</span></tt></a></li>
<li><a class="refentry reference" href="./equal-to.html"><tt class="refentry literal"><span class="pre">equal_to</span></tt></a></li>
<li><a class="refentry reference" href="./erase.html"><tt class="refentry literal"><span class="pre">erase</span></tt></a></li>
<li><a class="refentry reference" href="./erase-key.html"><tt class="refentry literal"><span class="pre">erase_key</span></tt></a></li>
<li><a class="refentry reference" href="./eval-if.html"><tt class="refentry literal"><span class="pre">eval_if</span></tt></a></li>
<li><a class="refentry reference" href="./eval-if-c.html"><tt class="refentry literal"><span class="pre">eval_if_c</span></tt></a></li>
<li><a class="refentry reference" href="./filter-view.html"><tt class="refentry literal"><span class="pre">filter_view</span></tt></a></li>
<li><a class="refentry reference" href="./find.html"><tt class="refentry literal"><span class="pre">find</span></tt></a></li>
<li><a class="refentry reference" href="./find-if.html"><tt class="refentry literal"><span class="pre">find_if</span></tt></a></li>
<li><a class="refentry reference" href="./fold.html"><tt class="refentry literal"><span class="pre">fold</span></tt></a></li>
<li><a class="refentry reference" href="./front.html"><tt class="refentry literal"><span class="pre">front</span></tt></a></li>
<li><a class="refentry reference" href="./front-inserter.html"><tt class="refentry literal"><span class="pre">front_inserter</span></tt></a></li>
<li><a class="refentry reference" href="./greater.html"><tt class="refentry literal"><span class="pre">greater</span></tt></a></li>
<li><a class="refentry reference" href="./greater-equal.html"><tt class="refentry literal"><span class="pre">greater_equal</span></tt></a></li>
<li><a class="refentry reference" href="./has-key.html"><tt class="refentry literal"><span class="pre">has_key</span></tt></a></li>
<li><a class="refentry reference" href="./identity.html"><tt class="refentry literal"><span class="pre">identity</span></tt></a></li>
<li><a class="refentry reference" href="./if.html"><tt class="refentry literal"><span class="pre">if_</span></tt></a></li>
<li><a class="refentry reference" href="./if-c.html"><tt class="refentry literal"><span class="pre">if_c</span></tt></a></li>
<li><a class="refentry reference" href="./inherit.html"><tt class="refentry literal"><span class="pre">inherit</span></tt></a></li>
<li><a class="refentry reference" href="./inherit-linearly.html"><tt class="refentry literal"><span class="pre">inherit_linearly</span></tt></a></li>
<li><a class="refentry reference" href="./insert.html"><tt class="refentry literal"><span class="pre">insert</span></tt></a></li>
<li><a class="refentry reference" href="./insert-range.html"><tt class="refentry literal"><span class="pre">insert_range</span></tt></a></li>
<li><a class="refentry reference" href="./inserters-inserter.html"><tt class="refentry literal"><span class="pre">inserter</span></tt></a></li>
<li><a class="refentry reference" href="./int.html"><tt class="refentry literal"><span class="pre">int_</span></tt></a></li>
<li><a class="refentry reference" href="./integral-c.html"><tt class="refentry literal"><span class="pre">integral_c</span></tt></a></li>
<li><a class="refentry reference" href="./is-sequence.html"><tt class="refentry literal"><span class="pre">is_sequence</span></tt></a></li>
<li><a class="refentry reference" href="./iter-fold.html"><tt class="refentry literal"><span class="pre">iter_fold</span></tt></a></li>
<li><a class="refentry reference" href="./iterator-category.html"><tt class="refentry literal"><span class="pre">iterator_category</span></tt></a></li>
<li><a class="refentry reference" href="./iterator-range.html"><tt class="refentry literal"><span class="pre">iterator_range</span></tt></a></li>
<li><a class="refentry reference" href="./joint-view.html"><tt class="refentry literal"><span class="pre">joint_view</span></tt></a></li>
<li><a class="refentry reference" href="./key-type.html"><tt class="refentry literal"><span class="pre">key_type</span></tt></a></li>
<li><a class="refentry reference" href="./lambda.html"><tt class="refentry literal"><span class="pre">lambda</span></tt></a></li>
<li><a class="refentry reference" href="./less.html"><tt class="refentry literal"><span class="pre">less</span></tt></a></li>
<li><a class="refentry reference" href="./less-equal.html"><tt class="refentry literal"><span class="pre">less_equal</span></tt></a></li>
<li><a class="refentry reference" href="./list.html"><tt class="refentry literal"><span class="pre">list</span></tt></a></li>
<li><a class="refentry reference" href="./list-c.html"><tt class="refentry literal"><span class="pre">list_c</span></tt></a></li>
<li><a class="refentry reference" href="./long.html"><tt class="refentry literal"><span class="pre">long_</span></tt></a></li>
<li><a class="refentry reference" href="./lower-bound.html"><tt class="refentry literal"><span class="pre">lower_bound</span></tt></a></li>
<li><a class="refentry reference" href="./map.html"><tt class="refentry literal"><span class="pre">map</span></tt></a></li>
<li><a class="refentry reference" href="./max.html"><tt class="refentry literal"><span class="pre">max</span></tt></a></li>
<li><a class="refentry reference" href="./max-element.html"><tt class="refentry literal"><span class="pre">max_element</span></tt></a></li>
<li><a class="refentry reference" href="./min.html"><tt class="refentry literal"><span class="pre">min</span></tt></a></li>
<li><a class="refentry reference" href="./min-element.html"><tt class="refentry literal"><span class="pre">min_element</span></tt></a></li>
<li><a class="refentry reference" href="./minus.html"><tt class="refentry literal"><span class="pre">minus</span></tt></a></li>
<li><a class="refentry reference" href="./modulus.html"><tt class="refentry literal"><span class="pre">modulus</span></tt></a></li>
<li><a class="refentry reference" href="./negate.html"><tt class="refentry literal"><span class="pre">negate</span></tt></a></li>
<li><a class="refentry reference" href="./next.html"><tt class="refentry literal"><span class="pre">next</span></tt></a></li>
<li><a class="refentry reference" href="./not.html"><tt class="refentry literal"><span class="pre">not_</span></tt></a></li>
<li><a class="refentry reference" href="./not-equal-to.html"><tt class="refentry literal"><span class="pre">not_equal_to</span></tt></a></li>
<li><a class="refentry reference" href="./numeric-cast.html"><tt class="refentry literal"><span class="pre">numeric_cast</span></tt></a></li>
<li><a class="refentry reference" href="./or.html"><tt class="refentry literal"><span class="pre">or_</span></tt></a></li>
<li><a class="refentry reference" href="./order.html"><tt class="refentry literal"><span class="pre">order</span></tt></a></li>
<li><a class="refentry reference" href="./pair.html"><tt class="refentry literal"><span class="pre">pair</span></tt></a></li>
<li><a class="refentry reference" href="./partition.html"><tt class="refentry literal"><span class="pre">partition</span></tt></a></li>
<li><a class="refentry reference" href="./plus.html"><tt class="refentry literal"><span class="pre">plus</span></tt></a></li>
<li><a class="refentry reference" href="./pop-back.html"><tt class="refentry literal"><span class="pre">pop_back</span></tt></a></li>
<li><a class="refentry reference" href="./pop-front.html"><tt class="refentry literal"><span class="pre">pop_front</span></tt></a></li>
<li><a class="refentry reference" href="./prior.html"><tt class="refentry literal"><span class="pre">prior</span></tt></a></li>
<li><a class="refentry reference" href="./protect.html"><tt class="refentry literal"><span class="pre">protect</span></tt></a></li>
<li><a class="refentry reference" href="./push-back.html"><tt class="refentry literal"><span class="pre">push_back</span></tt></a></li>
<li><a class="refentry reference" href="./push-front.html"><tt class="refentry literal"><span class="pre">push_front</span></tt></a></li>
<li><a class="refentry reference" href="./quote.html"><tt class="refentry literal"><span class="pre">quote</span></tt></a></li>
<li><a class="refentry reference" href="./range-c.html"><tt class="refentry literal"><span class="pre">range_c</span></tt></a></li>
<li><a class="refentry reference" href="./remove.html"><tt class="refentry literal"><span class="pre">remove</span></tt></a></li>
<li><a class="refentry reference" href="./remove-if.html"><tt class="refentry literal"><span class="pre">remove_if</span></tt></a></li>
<li><a class="refentry reference" href="./replace.html"><tt class="refentry literal"><span class="pre">replace</span></tt></a></li>
<li><a class="refentry reference" href="./replace-if.html"><tt class="refentry literal"><span class="pre">replace_if</span></tt></a></li>
<li><a class="refentry reference" href="./reverse.html"><tt class="refentry literal"><span class="pre">reverse</span></tt></a></li>
<li><a class="refentry reference" href="./reverse-copy.html"><tt class="refentry literal"><span class="pre">reverse_copy</span></tt></a></li>
<li><a class="refentry reference" href="./reverse-copy-if.html"><tt class="refentry literal"><span class="pre">reverse_copy_if</span></tt></a></li>
<li><a class="refentry reference" href="./reverse-fold.html"><tt class="refentry literal"><span class="pre">reverse_fold</span></tt></a></li>
<li><a class="refentry reference" href="./reverse-iter-fold.html"><tt class="refentry literal"><span class="pre">reverse_iter_fold</span></tt></a></li>
<li><a class="refentry reference" href="./reverse-partition.html"><tt class="refentry literal"><span class="pre">reverse_partition</span></tt></a></li>
<li><a class="refentry reference" href="./reverse-remove.html"><tt class="refentry literal"><span class="pre">reverse_remove</span></tt></a></li>
<li><a class="refentry reference" href="./reverse-remove-if.html"><tt class="refentry literal"><span class="pre">reverse_remove_if</span></tt></a></li>
<li><a class="refentry reference" href="./reverse-replace.html"><tt class="refentry literal"><span class="pre">reverse_replace</span></tt></a></li>
<li><a class="refentry reference" href="./reverse-replace-if.html"><tt class="refentry literal"><span class="pre">reverse_replace_if</span></tt></a></li>
<li><a class="refentry reference" href="./reverse-stable-partition.html"><tt class="refentry literal"><span class="pre">reverse_stable_partition</span></tt></a></li>
<li><a class="refentry reference" href="./reverse-transform.html"><tt class="refentry literal"><span class="pre">reverse_transform</span></tt></a></li>
<li><a class="refentry reference" href="./reverse-unique.html"><tt class="refentry literal"><span class="pre">reverse_unique</span></tt></a></li>
<li><a class="refentry reference" href="./sequence-tag.html"><tt class="refentry literal"><span class="pre">sequence_tag</span></tt></a></li>
<li><a class="refentry reference" href="./set.html"><tt class="refentry literal"><span class="pre">set</span></tt></a></li>
<li><a class="refentry reference" href="./set-c.html"><tt class="refentry literal"><span class="pre">set_c</span></tt></a></li>
<li><a class="refentry reference" href="./shift-left.html"><tt class="refentry literal"><span class="pre">shift_left</span></tt></a></li>
<li><a class="refentry reference" href="./shift-right.html"><tt class="refentry literal"><span class="pre">shift_right</span></tt></a></li>
<li><a class="refentry reference" href="./single-view.html"><tt class="refentry literal"><span class="pre">single_view</span></tt></a></li>
<li><a class="refentry reference" href="./size.html"><tt class="refentry literal"><span class="pre">size</span></tt></a></li>
<li><a class="refentry reference" href="./size-t.html"><tt class="refentry literal"><span class="pre">size_t</span></tt></a></li>
<li><a class="refentry reference" href="./sizeof.html"><tt class="refentry literal"><span class="pre">sizeof_</span></tt></a></li>
<li><a class="refentry reference" href="./sort.html"><tt class="refentry literal"><span class="pre">sort</span></tt></a></li>
<li><a class="refentry reference" href="./stable-partition.html"><tt class="refentry literal"><span class="pre">stable_partition</span></tt></a></li>
<li><a class="refentry reference" href="./times.html"><tt class="refentry literal"><span class="pre">times</span></tt></a></li>
<li><a class="refentry reference" href="./transform.html"><tt class="refentry literal"><span class="pre">transform</span></tt></a></li>
<li><a class="refentry reference" href="./transform-view.html"><tt class="refentry literal"><span class="pre">transform_view</span></tt></a></li>
<li><a class="refentry reference" href="./unique.html"><tt class="refentry literal"><span class="pre">unique</span></tt></a></li>
<li><a class="refentry reference" href="./unpack-args.html"><tt class="refentry literal"><span class="pre">unpack_args</span></tt></a></li>
<li><a class="refentry reference" href="./upper-bound.html"><tt class="refentry literal"><span class="pre">upper_bound</span></tt></a></li>
<li><a class="refentry reference" href="./value-type.html"><tt class="refentry literal"><span class="pre">value_type</span></tt></a></li>
<li><a class="refentry reference" href="./vector.html"><tt class="refentry literal"><span class="pre">vector</span></tt></a></li>
<li><a class="refentry reference" href="./vector-c.html"><tt class="refentry literal"><span class="pre">vector_c</span></tt></a></li>
<li><a class="refentry reference" href="./void.html"><tt class="refentry literal"><span class="pre">void_</span></tt></a></li>
<li><a class="refentry reference" href="./zip-view.html"><tt class="refentry literal"><span class="pre">zip_view</span></tt></a></li>
</ul>
<!-- modtime: November 10, 2004 05:07:51 +0000 -->
</div>
<div class="footer-separator"></div>
<table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./categorized-concepts.html" class="navigation-link">Prev</a>&nbsp;<a href="./acknowledgements.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./categorized-concepts.html" class="navigation-link">Back</a>&nbsp;Along</span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./categorized-index.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>
</tr></table></body>
</html>
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.3.6: http://docutils.sourceforge.net/" />
<title>The MPL Reference Manual: Composition and Argument Binding</title>
<link rel="stylesheet" href="../style.css" type="text/css" />
</head>
<body class="docframe refmanual">
<table class="header"><tr class="header"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./unpack-args.html" class="navigation-link">Prev</a>&nbsp;<a href="./placeholders.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./invocation.html" class="navigation-link">Back</a>&nbsp;<a href="./arithmetic-operations.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./metafunctions.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>
<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="./composition-and-argument.html" class="navigation-link">Composition and Argument Binding</a></td>
</tr></table><div class="header-separator"></div>
<div class="section" id="composition-and-argument">
<h1><a class="toc-backref" href="./metafunctions.html#id454" name="composition-and-argument">Composition and Argument Binding</a></h1>
<a class="target" id="id217" name="id217"></a><!-- modtime: November 07, 2004 18:47:40 +0000 -->
<!-- Metafunctions/Composition and Argument Binding//_1,_2,..._n |10 -->
<ul class="toc simple" id="outline">
<li><a class="reference" href="./placeholders.html" id="id455" name="id455">Placeholders</a></li>
<li><a class="reference" href="./lambda.html" id="id456" name="id456">lambda</a></li>
<li><a class="reference" href="./bind.html" id="id457" name="id457">bind</a></li>
<li><a class="reference" href="./quote.html" id="id458" name="id458">quote</a></li>
<li><a class="reference" href="./arg.html" id="id459" name="id459">arg</a></li>
<li><a class="reference" href="./protect.html" id="id460" name="id460">protect</a></li>
</ul>
</div>
<div class="footer-separator"></div>
<table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./unpack-args.html" class="navigation-link">Prev</a>&nbsp;<a href="./placeholders.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./invocation.html" class="navigation-link">Back</a>&nbsp;<a href="./arithmetic-operations.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./metafunctions.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>
</tr></table></body>
</html>
+57
View File
@@ -0,0 +1,57 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.3.6: http://docutils.sourceforge.net/" />
<title>The MPL Reference Manual: Concepts</title>
<link rel="stylesheet" href="../style.css" type="text/css" />
</head>
<body class="docframe refmanual">
<table class="header"><tr class="header"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./sequences.html" class="navigation-link">Prev</a>&nbsp;<a href="./forward-sequence.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group">Back&nbsp;<a href="./classes.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./sequences.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>
<td class="header-group page-location"><a href="../refmanual.html" class="navigation-link">Front Page</a> / <a href="./sequences.html" class="navigation-link">Sequences</a> / <a href="./concepts.html" class="navigation-link">Concepts</a></td>
</tr></table><div class="header-separator"></div>
<div class="section" id="concepts">
<h1><a class="toc-backref" href="./sequences.html#id323" name="concepts">Concepts</a></h1>
<a class="target" id="label-sequences-concepts" name="label-sequences-concepts"></a><p>The taxonomy of sequence concepts in MPL parallels the taxonomy of the MPL
<a class="reference" href="./iterators.html">Iterators</a>, with two additional classification dimensions:
<cite>extensibility</cite> and <cite>associativeness</cite>.</p>
<!-- The latter two are orthogonal to
sequence traversal characteristics, but not to each other, meaning that
a sequence can be characterized as both `Bidirectional`__
and `Back Extensible`__, or `Bidirectional`__ and
`Extensible Associative`__, but not as `Bidirectional`__,
`Back Extensible`__ *and* `Extensible Associative`__.
__ `Bidirectional Sequence`_
__ `Back Extensible Sequence`_
__ `Bidirectional Sequence`_
__ `Extensible Associative Sequence`_
__ `Bidirectional Sequence`_
__ `Back Extensible Sequence`_
__ `Extensible Associative Sequence`_
Two utility concepts, |Variadic Sequence| and |Integral Sequence Wrapper|,
are not applicable in generic contexts, but are used to group together
the common parts of different sequence classes' specifications. -->
<!-- modtime: November 05, 2004 05:11:22 +0000 -->
<!-- Sequences/Concepts//Forward Sequence |10 -->
<ul class="toc simple" id="outline">
<li><a class="reference" href="./forward-sequence.html" id="id324" name="id324">Forward Sequence</a></li>
<li><a class="reference" href="./bidirectional-sequence.html" id="id325" name="id325">Bidirectional Sequence</a></li>
<li><a class="reference" href="./random-access-sequence.html" id="id326" name="id326">Random Access Sequence</a></li>
<li><a class="reference" href="./extensible-sequence.html" id="id327" name="id327">Extensible Sequence</a></li>
<li><a class="reference" href="./front-extensible-sequence.html" id="id328" name="id328">Front Extensible Sequence</a></li>
<li><a class="reference" href="./back-extensible-sequence.html" id="id329" name="id329">Back Extensible Sequence</a></li>
<li><a class="reference" href="./associative-sequence.html" id="id330" name="id330">Associative Sequence</a></li>
<li><a class="reference" href="./extensible-associative.html" id="id331" name="id331">Extensible Associative Sequence</a></li>
<li><a class="reference" href="./integral-sequence-wrapper.html" id="id332" name="id332">Integral Sequence Wrapper</a></li>
<li><a class="reference" href="./variadic-sequence.html" id="id333" name="id333">Variadic Sequence</a></li>
</ul>
</div>
<div class="footer-separator"></div>
<table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./sequences.html" class="navigation-link">Prev</a>&nbsp;<a href="./forward-sequence.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group">Back&nbsp;<a href="./classes.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./sequences.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>
</tr></table></body>
</html>
+33
View File
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.3.6: http://docutils.sourceforge.net/" />
<title>The MPL Reference Manual: Configuration</title>
<link rel="stylesheet" href="../style.css" type="text/css" />
</head>
<body class="docframe refmanual">
<table class="header"><tr class="header"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./has-xxx-trait-named-def.html" class="navigation-link">Prev</a>&nbsp;<a href="./cfg-no-preprocessed.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./introspection.html" class="navigation-link">Back</a>&nbsp;<a href="./broken-compiler.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./macros.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>
<td class="header-group page-location"><a href="../refmanual.html" class="navigation-link">Front Page</a> / <a href="./macros.html" class="navigation-link">Macros</a> / <a href="./configuration.html" class="navigation-link">Configuration</a></td>
</tr></table><div class="header-separator"></div>
<div class="section" id="configuration">
<h1><a class="toc-backref" href="./macros.html#id518" name="configuration">Configuration</a></h1>
<a class="target" id="id293" name="id293"></a><!-- modtime: November 04, 2004 12:12:12 +0000 -->
<!-- Macros/Configuration//BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS |10 -->
<ul class="toc simple" id="outline">
<li><a class="reference" href="./cfg-no-preprocessed.html" id="id519" name="id519">BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS</a></li>
<li><a class="reference" href="./cfg-no-has-xxx.html" id="id520" name="id520">BOOST_MPL_CFG_NO_HAS_XXX</a></li>
<li><a class="reference" href="./limit-metafunction-arity.html" id="id521" name="id521">BOOST_MPL_LIMIT_METAFUNCTION_ARITY</a></li>
<li><a class="reference" href="./limit-vector-size.html" id="id522" name="id522">BOOST_MPL_LIMIT_VECTOR_SIZE</a></li>
<li><a class="reference" href="./limit-list-size.html" id="id523" name="id523">BOOST_MPL_LIMIT_LIST_SIZE</a></li>
<li><a class="reference" href="./limit-set-size.html" id="id524" name="id524">BOOST_MPL_LIMIT_SET_SIZE</a></li>
<li><a class="reference" href="./limit-map-size.html" id="id525" name="id525">BOOST_MPL_LIMIT_MAP_SIZE</a></li>
<li><a class="reference" href="./limit-unrolling.html" id="id526" name="id526">BOOST_MPL_LIMIT_UNROLLING</a></li>
</ul>
</div>
<div class="footer-separator"></div>
<table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./has-xxx-trait-named-def.html" class="navigation-link">Prev</a>&nbsp;<a href="./cfg-no-preprocessed.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./introspection.html" class="navigation-link">Back</a>&nbsp;<a href="./broken-compiler.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./macros.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>
</tr></table></body>
</html>
+112
View File
@@ -0,0 +1,112 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.3.6: http://docutils.sourceforge.net/" />
<title>The MPL Reference Manual: contains</title>
<link rel="stylesheet" href="../style.css" type="text/css" />
</head>
<body class="docframe refmanual">
<table class="header"><tr class="header"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./find-if.html" class="navigation-link">Prev</a>&nbsp;<a href="./count.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./find-if.html" class="navigation-link">Back</a>&nbsp;<a href="./count.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./querying-algorithms.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>
<td class="header-group page-location"><a href="../refmanual.html" class="navigation-link">Front Page</a> / <a href="./algorithms.html" class="navigation-link">Algorithms</a> / <a href="./querying-algorithms.html" class="navigation-link">Querying Algorithms</a> / <a href="./contains.html" class="navigation-link">contains</a></td>
</tr></table><div class="header-separator"></div>
<div class="section" id="contains">
<h1><a class="toc-backref" href="./querying-algorithms.html#id405" name="contains">contains</a></h1>
<div class="section" id="contains-synopsis">
<h3><a class="subsection-title" href="#synopsis" name="synopsis">Synopsis</a></h3>
<pre class="literal-block">
template&lt;
typename Sequence
, typename T
&gt;
struct <a href="./contains.html" class="identifier">contains</a>
{
typedef <em>unspecified</em> type;
};
</pre>
</div>
<div class="section" id="contains-description">
<h3><a class="subsection-title" href="#description" name="description">Description</a></h3>
<p>Returns a true-valued <a class="reference" href="./integral-constant.html">Integral Constant</a> if one or more elements in <tt class="literal"><span class="pre">Sequence</span></tt>
are identical to <tt class="literal"><span class="pre">T</span></tt>.</p>
</div>
<div class="section" id="contains-header">
<h3><a class="subsection-title" href="#header" name="header">Header</a></h3>
<pre class="literal-block">
#include &lt;<a href="../../../../boost/mpl/contains.hpp" class="header">boost/mpl/contains.hpp</a>&gt;
</pre>
</div>
<div class="section" id="contains-parameters">
<h3><a class="subsection-title" href="#parameters" name="parameters">Parameters</a></h3>
<table border="1" class="table">
<colgroup>
<col width="19%" />
<col width="35%" />
<col width="45%" />
</colgroup>
<thead valign="bottom">
<tr><th>Parameter</th>
<th>Requirement</th>
<th>Description</th>
</tr>
</thead>
<tbody valign="top">
<tr><td><tt class="literal"><span class="pre">Sequence</span></tt></td>
<td><a class="reference" href="./forward-sequence.html">Forward Sequence</a></td>
<td>A sequence to be examined.</td>
</tr>
<tr><td><tt class="literal"><span class="pre">T</span></tt></td>
<td>Any type</td>
<td>A type to search for.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="contains-expression-semantics">
<h3><a class="subsection-title" href="#expression-semantics" name="expression-semantics">Expression semantics</a></h3>
<p>For any <a class="reference" href="./forward-sequence.html">Forward Sequence</a> <tt class="literal"><span class="pre">s</span></tt> and arbitrary type <tt class="literal"><span class="pre">t</span></tt>:</p>
<pre class="literal-block">
typedef <a href="./contains.html" class="identifier">contains</a>&lt;s,t&gt;::type r;
</pre>
<table class="field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Return type:</th><td class="field-body"><a class="reference" href="./integral-constant.html">Integral Constant</a>.</td>
</tr>
<tr class="field"><th class="field-name">Semantics:</th><td class="field-body"><p class="first">Equivalent to</p>
<pre class="last literal-block">
typedef <a href="./not.html" class="identifier">not_</a>&lt; is_same&lt;
<a href="./find.html" class="identifier">find</a>&lt;s,t&gt;::type
, <a href="./end.html" class="identifier">end</a>&lt;s&gt;::type
&gt; &gt;::type r;
</pre>
</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="contains-complexity">
<h3><a class="subsection-title" href="#complexity" name="complexity">Complexity</a></h3>
<p>Linear. At most <tt class="literal"><span class="pre"><a href="./size.html" class="identifier">size</a>&lt;s&gt;::value</span></tt> comparisons for identity.</p>
</div>
<div class="section" id="contains-example">
<h3><a class="subsection-title" href="#example" name="example">Example</a></h3>
<pre class="literal-block">
typedef <a href="./vector.html" class="identifier">vector</a>&lt;char,int,unsigned,long,unsigned long&gt; types;
<a href="./assert-not.html" class="identifier">BOOST_MPL_ASSERT_NOT</a>(( <a href="./contains.html" class="identifier">contains</a>&lt;types,bool&gt; ));
</pre>
</div>
<div class="section" id="contains-see-also">
<h3><a class="subsection-title" href="#see-also" name="see-also">See also</a></h3>
<p><a class="reference" href="./querying-algorithms.html">Querying Algorithms</a>, <a class="refentry reference" href="./find.html"><tt class="refentry literal"><span class="pre">find</span></tt></a>, <a class="refentry reference" href="./find-if.html"><tt class="refentry literal"><span class="pre">find_if</span></tt></a>, <a class="refentry reference" href="./count.html"><tt class="refentry literal"><span class="pre">count</span></tt></a>, <a class="refentry reference" href="./lower-bound.html"><tt class="refentry literal"><span class="pre">lower_bound</span></tt></a></p>
<!-- modtime: November 13, 2004 01:52:38 +0000 -->
<!-- Algorithms/Querying Algorithms//count |40 -->
</div>
</div>
<div class="footer-separator"></div>
<table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./find-if.html" class="navigation-link">Prev</a>&nbsp;<a href="./count.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./find-if.html" class="navigation-link">Back</a>&nbsp;<a href="./count.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./querying-algorithms.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>
</tr></table></body>
</html>
+142
View File
@@ -0,0 +1,142 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.3.6: http://docutils.sourceforge.net/" />
<title>The MPL Reference Manual: copy_if</title>
<link rel="stylesheet" href="../style.css" type="text/css" />
</head>
<body class="docframe refmanual">
<table class="header"><tr class="header"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./copy.html" class="navigation-link">Prev</a>&nbsp;<a href="./transform.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./copy.html" class="navigation-link">Back</a>&nbsp;<a href="./transform.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./transformation-algorithms.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>
<td class="header-group page-location"><a href="../refmanual.html" class="navigation-link">Front Page</a> / <a href="./algorithms.html" class="navigation-link">Algorithms</a> / <a href="./transformation-algorithms.html" class="navigation-link">Transformation Algorithms</a> / <a href="./copy-if.html" class="navigation-link">copy_if</a></td>
</tr></table><div class="header-separator"></div>
<div class="section" id="copy-if">
<h1><a class="toc-backref" href="./transformation-algorithms.html#id415" name="copy-if">copy_if</a></h1>
<div class="section" id="transformation-copy-synopsis">
<h3><a class="subsection-title" href="#synopsis" name="synopsis">Synopsis</a></h3>
<pre class="literal-block">
template&lt;
typename Sequence
, typename Pred
, typename In = <em>unspecified</em>
&gt;
struct <a href="./copy-if.html" class="identifier">copy_if</a>
{
typedef <em>unspecified</em> type;
};
</pre>
</div>
<div class="section" id="transformation-copy-description">
<h3><a class="subsection-title" href="#description" name="description">Description</a></h3>
<p>Returns a filtered copy of the original sequence containing the elements that satisfy
the predicate <tt class="literal"><span class="pre">Pred</span></tt>.</p>
<p>[<em>Note:</em> This wording applies to a no-inserter version(s) of the algorithm. See the
<cite>Expression semantics</cite> subsection for a precise specification of the algorithm's
details in all cases — <em>end note</em>]</p>
</div>
<div class="section" id="transformation-copy-header">
<h3><a class="subsection-title" href="#header" name="header">Header</a></h3>
<pre class="literal-block">
#include &lt;<a href="../../../../boost/mpl/copy_if.hpp" class="header">boost/mpl/copy_if.hpp</a>&gt;
</pre>
</div>
<div class="section" id="transformation-copy-model-of">
<h3><a class="subsection-title" href="#model-of" name="model-of">Model of</a></h3>
<p><a class="reference" href="./reversible-algorithm.html">Reversible Algorithm</a></p>
</div>
<div class="section" id="transformation-copy-parameters">
<h3><a class="subsection-title" href="#parameters" name="parameters">Parameters</a></h3>
<table border="1" class="table">
<colgroup>
<col width="19%" />
<col width="40%" />
<col width="40%" />
</colgroup>
<thead valign="bottom">
<tr><th>Parameter</th>
<th>Requirement</th>
<th>Description</th>
</tr>
</thead>
<tbody valign="top">
<tr><td><tt class="literal"><span class="pre">Sequence</span></tt></td>
<td><a class="reference" href="./forward-sequence.html">Forward Sequence</a></td>
<td>A sequence to copy.</td>
</tr>
<tr><td><tt class="literal"><span class="pre">Pred</span></tt></td>
<td>Unary <a class="reference" href="./lambda-expression.html">Lambda Expression</a></td>
<td>A copying condition.</td>
</tr>
<tr><td><tt class="literal"><span class="pre">In</span></tt></td>
<td><a class="reference" href="./inserter.html">Inserter</a></td>
<td>An inserter.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="transformation-copy-expression-semantics">
<h3><a class="subsection-title" href="#expression-semantics" name="expression-semantics">Expression semantics</a></h3>
<p>The semantics of an expression are defined only
where they differ from, or are not defined in <a class="reference" href="./reversible-algorithm.html">Reversible Algorithm</a>.</p>
<p>For any <a class="reference" href="./forward-sequence.html">Forward Sequence</a> <tt class="literal"><span class="pre">s</span></tt>, an unary <a class="reference" href="./lambda-expression.html">Lambda Expression</a> <tt class="literal"><span class="pre">pred</span></tt>, and
an <a class="reference" href="./inserter.html">Inserter</a> <tt class="literal"><span class="pre">in</span></tt>:</p>
<pre class="literal-block">
typedef <a href="./copy-if.html" class="identifier">copy_if</a>&lt;s,pred,in&gt;::type r;
</pre>
<table class="field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Return type:</th><td class="field-body">A type.</td>
</tr>
<tr class="field"><th class="field-name">Semantics:</th><td class="field-body"><p class="first">Equivalent to</p>
<pre class="last literal-block">
typedef <a href="./lambda.html" class="identifier">lambda</a>&lt;pred&gt;::type p;
typedef <a href="./lambda.html" class="identifier">lambda</a>&lt;in::operation&gt;::type op;
typedef <a href="./fold.html" class="identifier">fold</a>&lt;
s
, in::state
, <a href="./eval-if.html" class="identifier">eval_if</a>&lt;
<a href="./apply-wrap.html" class="identifier">apply_wrap</a><tt class="literal"><span class="pre">1</span></tt>&lt;p,_2&gt;
, <a href="./apply-wrap.html" class="identifier">apply_wrap</a><tt class="literal"><span class="pre">2</span></tt>&lt;op,_1,_2&gt;
, <a href="./identity.html" class="identifier">identity</a>&lt;_1&gt;
&gt;
&gt;::type r;
</pre>
</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="transformation-copy-complexity">
<h3><a class="subsection-title" href="#complexity" name="complexity">Complexity</a></h3>
<p>Linear. Exactly <tt class="literal"><span class="pre"><a href="./size.html" class="identifier">size</a>&lt;s&gt;::value</span></tt> applications of <tt class="literal"><span class="pre">pred</span></tt>, and at
most <tt class="literal"><span class="pre"><a href="./size.html" class="identifier">size</a>&lt;s&gt;::value</span></tt> applications of <tt class="literal"><span class="pre">in::operation</span></tt>.</p>
</div>
<div class="section" id="transformation-copy-example">
<h3><a class="subsection-title" href="#example" name="example">Example</a></h3>
<pre class="literal-block">
typedef <a href="./copy-if.html" class="identifier">copy_if</a>&lt;
<a href="./range-c.html" class="identifier">range_c</a>&lt;int,0,10&gt;
, <a href="./less.html" class="identifier">less</a>&lt; _1, <a href="./int.html" class="identifier">int_</a>&lt;5&gt; &gt;
, <a href="./back-inserter.html" class="identifier">back_inserter</a>&lt; <a href="./vector.html" class="identifier">vector</a>&lt;&gt; &gt;
&gt;::type result;
<a href="./assert-relation.html" class="identifier">BOOST_MPL_ASSERT_RELATION</a>( <a href="./size.html" class="identifier">size</a>&lt;result&gt;::value, ==, 5 );
<a href="./assert.html" class="identifier">BOOST_MPL_ASSERT</a>(( <a href="./equal.html" class="identifier">equal</a>&lt;result,<a href="./range-c.html" class="identifier">range_c</a>&lt;int,0,5&gt; > ));
</pre>
</div>
<div class="section" id="transformation-copy-see-also">
<h3><a class="subsection-title" href="#see-also" name="see-also">See also</a></h3>
<p><a class="reference" href="./transformation-algorithms.html">Transformation Algorithms</a>, <a class="reference" href="./reversible-algorithm.html">Reversible Algorithm</a>, <a class="refentry reference" href="./reverse-copy-if.html"><tt class="refentry literal"><span class="pre">reverse_copy_if</span></tt></a>, <a class="refentry reference" href="./copy.html"><tt class="refentry literal"><span class="pre">copy</span></tt></a>, <a class="refentry reference" href="./remove-if.html"><tt class="refentry literal"><span class="pre">remove_if</span></tt></a>, <a class="refentry reference" href="./replace-if.html"><tt class="refentry literal"><span class="pre">replace_if</span></tt></a></p>
<!-- modtime: November 13, 2004 01:54:56 +0000 -->
<!-- Algorithms/Transformation Algorithms//transform |30 -->
</div>
</div>
<div class="footer-separator"></div>
<table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./copy.html" class="navigation-link">Prev</a>&nbsp;<a href="./transform.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./copy.html" class="navigation-link">Back</a>&nbsp;<a href="./transform.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./transformation-algorithms.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>
</tr></table></body>
</html>
+123
View File
@@ -0,0 +1,123 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.3.6: http://docutils.sourceforge.net/" />
<title>The MPL Reference Manual: copy</title>
<link rel="stylesheet" href="../style.css" type="text/css" />
</head>
<body class="docframe refmanual">
<table class="header"><tr class="header"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./transformation-algorithms.html" class="navigation-link">Prev</a>&nbsp;<a href="./copy-if.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group">Back&nbsp;<a href="./copy-if.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./transformation-algorithms.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>
<td class="header-group page-location"><a href="../refmanual.html" class="navigation-link">Front Page</a> / <a href="./algorithms.html" class="navigation-link">Algorithms</a> / <a href="./transformation-algorithms.html" class="navigation-link">Transformation Algorithms</a> / <a href="./copy.html" class="navigation-link">copy</a></td>
</tr></table><div class="header-separator"></div>
<div class="section" id="copy">
<h1><a class="toc-backref" href="./transformation-algorithms.html#id414" name="copy">copy</a></h1>
<div class="section" id="copy-synopsis">
<h3><a class="subsection-title" href="#synopsis" name="synopsis">Synopsis</a></h3>
<pre class="literal-block">
template&lt;
typename Sequence
, typename In = <em>unspecified</em>
&gt;
struct <a href="./copy.html" class="identifier">copy</a>
{
typedef <em>unspecified</em> type;
};
</pre>
</div>
<div class="section" id="copy-description">
<h3><a class="subsection-title" href="#description" name="description">Description</a></h3>
<p>Returns a copy of the original sequence.</p>
<p>[<em>Note:</em> This wording applies to a no-inserter version(s) of the algorithm. See the
<cite>Expression semantics</cite> subsection for a precise specification of the algorithm's
details in all cases — <em>end note</em>]</p>
</div>
<div class="section" id="copy-header">
<h3><a class="subsection-title" href="#header" name="header">Header</a></h3>
<pre class="literal-block">
#include &lt;<a href="../../../../boost/mpl/copy.hpp" class="header">boost/mpl/copy.hpp</a>&gt;
</pre>
</div>
<div class="section" id="copy-model-of">
<h3><a class="subsection-title" href="#model-of" name="model-of">Model of</a></h3>
<p><a class="reference" href="./reversible-algorithm.html">Reversible Algorithm</a></p>
</div>
<div class="section" id="copy-parameters">
<h3><a class="subsection-title" href="#parameters" name="parameters">Parameters</a></h3>
<table border="1" class="table">
<colgroup>
<col width="21%" />
<col width="37%" />
<col width="42%" />
</colgroup>
<thead valign="bottom">
<tr><th>Parameter</th>
<th>Requirement</th>
<th>Description</th>
</tr>
</thead>
<tbody valign="top">
<tr><td><tt class="literal"><span class="pre">Sequence</span></tt></td>
<td><a class="reference" href="./forward-sequence.html">Forward Sequence</a></td>
<td>A sequence to copy.</td>
</tr>
<tr><td><tt class="literal"><span class="pre">In</span></tt></td>
<td><a class="reference" href="./inserter.html">Inserter</a></td>
<td>An inserter.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="copy-expression-semantics">
<h3><a class="subsection-title" href="#expression-semantics" name="expression-semantics">Expression semantics</a></h3>
<p>The semantics of an expression are defined only
where they differ from, or are not defined in <a class="reference" href="./reversible-algorithm.html">Reversible Algorithm</a>.</p>
<p>For any <a class="reference" href="./forward-sequence.html">Forward Sequence</a> <tt class="literal"><span class="pre">s</span></tt>, and an <a class="reference" href="./inserter.html">Inserter</a> <tt class="literal"><span class="pre">in</span></tt>:</p>
<pre class="literal-block">
typedef <a href="./copy.html" class="identifier">copy</a>&lt;s,in&gt;::type r;
</pre>
<table class="field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Return type:</th><td class="field-body">A type.</td>
</tr>
<tr class="field"><th class="field-name">Semantics:</th><td class="field-body"><p class="first">Equivalent to</p>
<pre class="last literal-block">
typedef <a href="./fold.html" class="identifier">fold</a>&lt; s,in::state,in::operation &gt;::type r;
</pre>
</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="copy-complexity">
<h3><a class="subsection-title" href="#complexity" name="complexity">Complexity</a></h3>
<p>Linear. Exactly <tt class="literal"><span class="pre"><a href="./size.html" class="identifier">size</a>&lt;s&gt;::value</span></tt> applications of <tt class="literal"><span class="pre">in::operation</span></tt>.</p>
</div>
<div class="section" id="copy-example">
<h3><a class="subsection-title" href="#example" name="example">Example</a></h3>
<pre class="literal-block">
typedef <a href="./vector-c.html" class="identifier">vector_c</a>&lt;int,0,1,2,3,4,5,6,7,8,9&gt; numbers;
typedef <a href="./copy.html" class="identifier">copy</a>&lt;
<a href="./range-c.html" class="identifier">range_c</a>&lt;int,10,20&gt;
, <a href="./back-inserter.html" class="identifier">back_inserter</a>&lt; numbers &gt;
&gt;::type result;
<a href="./assert-relation.html" class="identifier">BOOST_MPL_ASSERT_RELATION</a>( <a href="./size.html" class="identifier">size</a>&lt;result&gt;::value, ==, 20 );
<a href="./assert.html" class="identifier">BOOST_MPL_ASSERT</a>(( <a href="./equal.html" class="identifier">equal</a>&lt; result,<a href="./range-c.html" class="identifier">range_c</a>&lt;int,0,20&gt; > ));
</pre>
</div>
<div class="section" id="copy-see-also">
<h3><a class="subsection-title" href="#see-also" name="see-also">See also</a></h3>
<p><a class="reference" href="./transformation-algorithms.html">Transformation Algorithms</a>, <a class="reference" href="./reversible-algorithm.html">Reversible Algorithm</a>, <a class="refentry reference" href="./reverse-copy.html"><tt class="refentry literal"><span class="pre">reverse_copy</span></tt></a>, <a class="refentry reference" href="./copy-if.html"><tt class="refentry literal"><span class="pre">copy_if</span></tt></a>, <a class="refentry reference" href="./transform.html"><tt class="refentry literal"><span class="pre">transform</span></tt></a></p>
<!-- modtime: November 13, 2004 01:54:21 +0000 -->
<!-- Algorithms/Transformation Algorithms//copy_if |20 -->
</div>
</div>
<div class="footer-separator"></div>
<table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./transformation-algorithms.html" class="navigation-link">Prev</a>&nbsp;<a href="./copy-if.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group">Back&nbsp;<a href="./copy-if.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./transformation-algorithms.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>
</tr></table></body>
</html>
+116
View File
@@ -0,0 +1,116 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.3.6: http://docutils.sourceforge.net/" />
<title>The MPL Reference Manual: count_if</title>
<link rel="stylesheet" href="../style.css" type="text/css" />
</head>
<body class="docframe refmanual">
<table class="header"><tr class="header"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./count.html" class="navigation-link">Prev</a>&nbsp;<a href="./lower-bound.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./count.html" class="navigation-link">Back</a>&nbsp;<a href="./lower-bound.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./querying-algorithms.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>
<td class="header-group page-location"><a href="../refmanual.html" class="navigation-link">Front Page</a> / <a href="./algorithms.html" class="navigation-link">Algorithms</a> / <a href="./querying-algorithms.html" class="navigation-link">Querying Algorithms</a> / <a href="./count-if.html" class="navigation-link">count_if</a></td>
</tr></table><div class="header-separator"></div>
<div class="section" id="count-if">
<h1><a class="toc-backref" href="./querying-algorithms.html#id407" name="count-if">count_if</a></h1>
<div class="section" id="querying-count-synopsis">
<h3><a class="subsection-title" href="#synopsis" name="synopsis">Synopsis</a></h3>
<pre class="literal-block">
template&lt;
typename Sequence
, typename Pred
&gt;
struct <a href="./count-if.html" class="identifier">count_if</a>
{
typedef <em>unspecified</em> type;
};
</pre>
</div>
<div class="section" id="querying-count-description">
<h3><a class="subsection-title" href="#description" name="description">Description</a></h3>
<p>Returns the number of elements in <tt class="literal"><span class="pre">Sequence</span></tt> that satisfy the predicate <tt class="literal"><span class="pre">Pred</span></tt>.</p>
</div>
<div class="section" id="querying-count-header">
<h3><a class="subsection-title" href="#header" name="header">Header</a></h3>
<pre class="literal-block">
#include &lt;<a href="../../../../boost/mpl/count_if.hpp" class="header">boost/mpl/count_if.hpp</a>&gt;
</pre>
</div>
<div class="section" id="querying-count-parameters">
<h3><a class="subsection-title" href="#parameters" name="parameters">Parameters</a></h3>
<table border="1" class="table">
<colgroup>
<col width="19%" />
<col width="38%" />
<col width="43%" />
</colgroup>
<thead valign="bottom">
<tr><th>Parameter</th>
<th>Requirement</th>
<th>Description</th>
</tr>
</thead>
<tbody valign="top">
<tr><td><tt class="literal"><span class="pre">Sequence</span></tt></td>
<td><a class="reference" href="./forward-sequence.html">Forward Sequence</a></td>
<td>A sequence to be examined.</td>
</tr>
<tr><td><tt class="literal"><span class="pre">Pred</span></tt></td>
<td>Unary <a class="reference" href="./lambda-expression.html">Lambda Expression</a></td>
<td>A count condition.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="querying-count-expression-semantics">
<h3><a class="subsection-title" href="#expression-semantics" name="expression-semantics">Expression semantics</a></h3>
<p>For any <a class="reference" href="./forward-sequence.html">Forward Sequence</a> <tt class="literal"><span class="pre">s</span></tt> and unary <a class="reference" href="./lambda-expression.html">Lambda Expression</a> <tt class="literal"><span class="pre">pred</span></tt>:</p>
<pre class="literal-block">
typedef <a href="./count-if.html" class="identifier">count_if</a>&lt;s,pred&gt;::type n;
</pre>
<table class="field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Return type:</th><td class="field-body"><a class="reference" href="./integral-constant.html">Integral Constant</a>.</td>
</tr>
<tr class="field"><th class="field-name">Semantics:</th><td class="field-body"><p class="first">Equivalent to</p>
<pre class="last literal-block">
typedef <a href="./lambda.html" class="identifier">lambda</a>&lt;pred&gt;::type p;
typedef <a href="./fold.html" class="identifier">fold</a>&lt;
s
, <a href="./long.html" class="identifier">long_</a>&lt;0&gt;
, <a href="./if.html" class="identifier">if_</a>&lt; <a href="./apply-wrap.html" class="identifier">apply_wrap</a><tt class="literal"><span class="pre">1</span></tt>&lt;p,_2&gt;, <a href="./next.html" class="identifier">next</a>&lt;_1&gt;, _1 &gt;
&gt;::type n;
</pre>
</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="querying-count-complexity">
<h3><a class="subsection-title" href="#complexity" name="complexity">Complexity</a></h3>
<p>Linear. Exactly <tt class="literal"><span class="pre"><a href="./size.html" class="identifier">size</a>&lt;s&gt;::value</span></tt> applications of <tt class="literal"><span class="pre">pred</span></tt>.</p>
</div>
<div class="section" id="querying-count-example">
<h3><a class="subsection-title" href="#example" name="example">Example</a></h3>
<pre class="literal-block">
typedef <a href="./vector.html" class="identifier">vector</a>&lt;int,char,long,short,char,long,double,long&gt; types;
<a href="./assert-relation.html" class="identifier">BOOST_MPL_ASSERT_RELATION</a>( (<a href="./count-if.html" class="identifier">count_if</a>&lt; types, is_float&lt;_&gt; &gt;::value), ==, 1 );
<a href="./assert-relation.html" class="identifier">BOOST_MPL_ASSERT_RELATION</a>( (<a href="./count-if.html" class="identifier">count_if</a>&lt; types, is_same&lt;_,char&gt; &gt;::value), ==, 2 );
<a href="./assert-relation.html" class="identifier">BOOST_MPL_ASSERT_RELATION</a>( (<a href="./count-if.html" class="identifier">count_if</a>&lt; types, is_same&lt;_,void&gt; &gt;::value), ==, 0 );
</pre>
</div>
<div class="section" id="querying-count-see-also">
<h3><a class="subsection-title" href="#see-also" name="see-also">See also</a></h3>
<p><a class="reference" href="./querying-algorithms.html">Querying Algorithms</a>, <a class="refentry reference" href="./count.html"><tt class="refentry literal"><span class="pre">count</span></tt></a>, <a class="refentry reference" href="./find.html"><tt class="refentry literal"><span class="pre">find</span></tt></a>, <a class="refentry reference" href="./find-if.html"><tt class="refentry literal"><span class="pre">find_if</span></tt></a>, <a class="refentry reference" href="./contains.html"><tt class="refentry literal"><span class="pre">contains</span></tt></a></p>
<!-- modtime: November 10, 2004 04:43:18 +0000 -->
<!-- Algorithms/Querying Algorithms//lower_bound |60 -->
</div>
</div>
<div class="footer-separator"></div>
<table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./count.html" class="navigation-link">Prev</a>&nbsp;<a href="./lower-bound.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./count.html" class="navigation-link">Back</a>&nbsp;<a href="./lower-bound.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./querying-algorithms.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>
</tr></table></body>
</html>
+110
View File
@@ -0,0 +1,110 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.3.6: http://docutils.sourceforge.net/" />
<title>The MPL Reference Manual: count</title>
<link rel="stylesheet" href="../style.css" type="text/css" />
</head>
<body class="docframe refmanual">
<table class="header"><tr class="header"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./contains.html" class="navigation-link">Prev</a>&nbsp;<a href="./count-if.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./contains.html" class="navigation-link">Back</a>&nbsp;<a href="./count-if.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./querying-algorithms.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>
<td class="header-group page-location"><a href="../refmanual.html" class="navigation-link">Front Page</a> / <a href="./algorithms.html" class="navigation-link">Algorithms</a> / <a href="./querying-algorithms.html" class="navigation-link">Querying Algorithms</a> / <a href="./count.html" class="navigation-link">count</a></td>
</tr></table><div class="header-separator"></div>
<div class="section" id="count">
<h1><a class="toc-backref" href="./querying-algorithms.html#id406" name="count">count</a></h1>
<div class="section" id="count-synopsis">
<h3><a class="subsection-title" href="#synopsis" name="synopsis">Synopsis</a></h3>
<pre class="literal-block">
template&lt;
typename Sequence
, typename T
&gt;
struct <a href="./count.html" class="identifier">count</a>
{
typedef <em>unspecified</em> type;
};
</pre>
</div>
<div class="section" id="count-description">
<h3><a class="subsection-title" href="#description" name="description">Description</a></h3>
<p>Returns the number of elements in a <tt class="literal"><span class="pre">Sequence</span></tt> that are identical to <tt class="literal"><span class="pre">T</span></tt>.</p>
</div>
<div class="section" id="count-header">
<h3><a class="subsection-title" href="#header" name="header">Header</a></h3>
<pre class="literal-block">
#include &lt;<a href="../../../../boost/mpl/count.hpp" class="header">boost/mpl/count.hpp</a>&gt;
</pre>
</div>
<div class="section" id="count-parameters">
<h3><a class="subsection-title" href="#parameters" name="parameters">Parameters</a></h3>
<table border="1" class="table">
<colgroup>
<col width="19%" />
<col width="35%" />
<col width="45%" />
</colgroup>
<thead valign="bottom">
<tr><th>Parameter</th>
<th>Requirement</th>
<th>Description</th>
</tr>
</thead>
<tbody valign="top">
<tr><td><tt class="literal"><span class="pre">Sequence</span></tt></td>
<td><a class="reference" href="./forward-sequence.html">Forward Sequence</a></td>
<td>A sequence to be examined.</td>
</tr>
<tr><td><tt class="literal"><span class="pre">T</span></tt></td>
<td>Any type</td>
<td>A type to search for.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="count-expression-semantics">
<h3><a class="subsection-title" href="#expression-semantics" name="expression-semantics">Expression semantics</a></h3>
<p>For any <a class="reference" href="./forward-sequence.html">Forward Sequence</a> <tt class="literal"><span class="pre">s</span></tt> and arbitrary type <tt class="literal"><span class="pre">t</span></tt>:</p>
<pre class="literal-block">
typedef <a href="./count.html" class="identifier">count</a>&lt;s,t&gt;::type n;
</pre>
<table class="field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Return type:</th><td class="field-body"><a class="reference" href="./integral-constant.html">Integral Constant</a>.</td>
</tr>
<tr class="field"><th class="field-name">Semantics:</th><td class="field-body"><p class="first">Equivalent to</p>
<pre class="last literal-block">
typedef <a href="./count-if.html" class="identifier">count_if</a>&lt; s,is_same&lt;_,T&gt; &gt;::type n;
</pre>
</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="count-complexity">
<h3><a class="subsection-title" href="#complexity" name="complexity">Complexity</a></h3>
<p>Linear. Exactly <tt class="literal"><span class="pre"><a href="./size.html" class="identifier">size</a>&lt;s&gt;::value</span></tt> comparisons for identity.</p>
</div>
<div class="section" id="count-example">
<h3><a class="subsection-title" href="#example" name="example">Example</a></h3>
<pre class="literal-block">
typedef <a href="./vector.html" class="identifier">vector</a>&lt;int,char,long,short,char,short,double,long&gt; types;
typedef <a href="./count.html" class="identifier">count</a>&lt;types, short&gt;::type n;
<a href="./assert-relation.html" class="identifier">BOOST_MPL_ASSERT_RELATION</a>( n::value, ==, 2 );
</pre>
</div>
<div class="section" id="count-see-also">
<h3><a class="subsection-title" href="#see-also" name="see-also">See also</a></h3>
<p><a class="reference" href="./querying-algorithms.html">Querying Algorithms</a>, <a class="refentry reference" href="./count-if.html"><tt class="refentry literal"><span class="pre">count_if</span></tt></a>, <a class="refentry reference" href="./find.html"><tt class="refentry literal"><span class="pre">find</span></tt></a>, <a class="refentry reference" href="./find-if.html"><tt class="refentry literal"><span class="pre">find_if</span></tt></a>, <a class="refentry reference" href="./contains.html"><tt class="refentry literal"><span class="pre">contains</span></tt></a>, <a class="refentry reference" href="./lower-bound.html"><tt class="refentry literal"><span class="pre">lower_bound</span></tt></a></p>
<!-- modtime: November 13, 2004 01:52:16 +0000 -->
<!-- Algorithms/Querying Algorithms//count_if |50 -->
</div>
</div>
<div class="footer-separator"></div>
<table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./contains.html" class="navigation-link">Prev</a>&nbsp;<a href="./count-if.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./contains.html" class="navigation-link">Back</a>&nbsp;<a href="./count-if.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./querying-algorithms.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>
</tr></table></body>
</html>
+25
View File
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.3.6: http://docutils.sourceforge.net/" />
<title>The MPL Reference Manual: Concepts</title>
<link rel="stylesheet" href="../style.css" type="text/css" />
</head>
<body class="docframe refmanual">
<table class="header"><tr class="header"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./data-types.html" class="navigation-link">Prev</a>&nbsp;<a href="./integral-constant.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group">Back&nbsp;<a href="./numeric.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./data-types.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>
<td class="header-group page-location"><a href="../refmanual.html" class="navigation-link">Front Page</a> / <a href="./data-types.html" class="navigation-link">Data Types</a> / <a href="./data-concepts.html" class="navigation-link">Concepts</a></td>
</tr></table><div class="header-separator"></div>
<div class="section" id="data-concepts">
<h1><a class="toc-backref" href="./data-types.html#id497" name="data-concepts">Concepts</a></h1>
<a class="target" id="label-data-types-concepts" name="label-data-types-concepts"></a><!-- Data Types/Concepts//Integral Constant -->
<ul class="toc simple" id="outline">
<li><a class="reference" href="./integral-constant.html" id="id498" name="id498">Integral Constant</a></li>
</ul>
</div>
<div class="footer-separator"></div>
<table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./data-types.html" class="navigation-link">Prev</a>&nbsp;<a href="./integral-constant.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group">Back&nbsp;<a href="./numeric.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./data-types.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>
</tr></table></body>
</html>
+27
View File
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.3.6: http://docutils.sourceforge.net/" />
<title>The MPL Reference Manual: Miscellaneous</title>
<link rel="stylesheet" href="../style.css" type="text/css" />
</head>
<body class="docframe refmanual">
<table class="header"><tr class="header"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./integral-c.html" class="navigation-link">Prev</a>&nbsp;<a href="./pair.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./numeric.html" class="navigation-link">Back</a>&nbsp;Along</span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./data-types.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>
<td class="header-group page-location"><a href="../refmanual.html" class="navigation-link">Front Page</a> / <a href="./data-types.html" class="navigation-link">Data Types</a> / <a href="./data-miscellaneous.html" class="navigation-link">Miscellaneous</a></td>
</tr></table><div class="header-separator"></div>
<div class="section" id="data-miscellaneous">
<h1><a class="toc-backref" href="./data-types.html#id505" name="data-miscellaneous">Miscellaneous</a></h1>
<a class="target" id="id279" name="id279"></a><!-- Data Types/Miscellaneous//pair |10 -->
<ul class="toc simple" id="outline">
<li><a class="reference" href="./pair.html" id="id506" name="id506">pair</a></li>
<li><a class="reference" href="./empty-base.html" id="id507" name="id507">empty_base</a></li>
<li><a class="reference" href="./void.html" id="id508" name="id508">void_</a></li>
</ul>
</div>
<div class="footer-separator"></div>
<table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./integral-c.html" class="navigation-link">Prev</a>&nbsp;<a href="./pair.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./numeric.html" class="navigation-link">Back</a>&nbsp;Along</span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./data-types.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>
</tr></table></body>
</html>
+27
View File
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.3.6: http://docutils.sourceforge.net/" />
<title>The MPL Reference Manual: Data Types</title>
<link rel="stylesheet" href="../style.css" type="text/css" />
</head>
<body class="docframe refmanual">
<table class="header"><tr class="header"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./sizeof.html" class="navigation-link">Prev</a>&nbsp;<a href="./data-concepts.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./metafunctions.html" class="navigation-link">Back</a>&nbsp;<a href="./macros.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="../refmanual.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>
<td class="header-group page-location"><a href="../refmanual.html" class="navigation-link">Front Page</a> / <a href="./data-types.html" class="navigation-link">Data Types</a></td>
</tr></table><div class="header-separator"></div>
<div class="section" id="data-types">
<h1><a class="toc-backref" href="../refmanual.html#id496" name="data-types">Data Types</a></h1>
<a class="target" id="label-data-types" name="label-data-types"></a><a class="target" id="data" name="data"></a><!-- modtime: November 08, 2004 09:39:06 +0000 -->
<ul class="toc simple" id="outline">
<li><a class="reference" href="./data-concepts.html" id="id497" name="id497">Concepts</a></li>
<li><a class="reference" href="./numeric.html" id="id499" name="id499">Numeric</a></li>
<li><a class="reference" href="./data-miscellaneous.html" id="id505" name="id505">Miscellaneous</a></li>
</ul>
</div>
<div class="footer-separator"></div>
<table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./sizeof.html" class="navigation-link">Prev</a>&nbsp;<a href="./data-concepts.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./metafunctions.html" class="navigation-link">Back</a>&nbsp;<a href="./macros.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="../refmanual.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>
</tr></table></body>
</html>
+63
View File
@@ -0,0 +1,63 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.3.6: http://docutils.sourceforge.net/" />
<title>The MPL Reference Manual: deque</title>
<link rel="stylesheet" href="../style.css" type="text/css" />
</head>
<body class="docframe refmanual">
<table class="header"><tr class="header"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./list.html" class="navigation-link">Prev</a>&nbsp;<a href="./set.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./list.html" class="navigation-link">Back</a>&nbsp;<a href="./set.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./classes.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>
<td class="header-group page-location"><a href="../refmanual.html" class="navigation-link">Front Page</a> / <a href="./sequences.html" class="navigation-link">Sequences</a> / <a href="./classes.html" class="navigation-link">Classes</a> / <a href="./deque.html" class="navigation-link">deque</a></td>
</tr></table><div class="header-separator"></div>
<div class="section" id="deque">
<h1><a class="toc-backref" href="./classes.html#id337" name="deque">deque</a></h1>
<div class="section" id="deque-description">
<h3><a class="subsection-title" href="#description" name="description">Description</a></h3>
<p><tt class="literal"><span class="pre"><a href="./deque.html" class="identifier">deque</a></span></tt> is a <a class="reference" href="./variadic-sequence.html">variadic</a>, <a class="reference" href="./random-access-sequence.html">random access</a>, <a class="reference" href="./extensible-sequence.html">extensible</a> sequence of types that
supports constant-time insertion and removal of elements at both ends, and
linear-time insertion and removal of elements in the middle. In this implementation
of the library, <tt class="literal"><span class="pre"><a href="./deque.html" class="identifier">deque</a></span></tt> is a synonym for <a class="refentry reference" href="./vector.html"><tt class="refentry literal"><span class="pre">vector</span></tt></a>.</p>
</div>
<div class="section" id="deque-header">
<h3><a class="subsection-title" href="#header" name="header">Header</a></h3>
<pre class="literal-block">
#include &lt;<a href="../../../../boost/mpl/deque.hpp" class="header">boost/mpl/deque.hpp</a>&gt;
</pre>
</div>
<div class="section" id="deque-model-of">
<h3><a class="subsection-title" href="#model-of" name="model-of">Model of</a></h3>
<ul class="simple">
<li><a class="reference" href="./variadic-sequence.html">Variadic Sequence</a></li>
<li><a class="reference" href="./random-access-sequence.html">Random Access Sequence</a></li>
<li><a class="reference" href="./extensible-sequence.html">Extensible Sequence</a></li>
<li><a class="reference" href="./back-extensible-sequence.html">Back Extensible Sequence</a></li>
<li><a class="reference" href="./front-extensible-sequence.html">Front Extensible Sequence</a></li>
</ul>
</div>
<div class="section" id="deque-expression-semantics">
<h3><a class="subsection-title" href="#expression-semantics" name="expression-semantics">Expression semantics</a></h3>
<p>See <a class="refentry reference" href="./vector.html"><tt class="refentry literal"><span class="pre">vector</span></tt></a> specification.</p>
</div>
<div class="section" id="deque-example">
<h3><a class="subsection-title" href="#example" name="example">Example</a></h3>
<pre class="literal-block">
typedef <a href="./deque.html" class="identifier">deque</a>&lt;float,double,long double&gt; floats;
typedef <a href="./push-back.html" class="identifier">push_back</a>&lt;floats,int&gt;::type types;
<a href="./assert.html" class="identifier">BOOST_MPL_ASSERT</a>(( is_same&lt; <a href="./at-c.html" class="identifier">at_c</a>&lt;types,3&gt;::type, int > ));
</pre>
</div>
<div class="section" id="deque-see-also">
<h3><a class="subsection-title" href="#see-also" name="see-also">See also</a></h3>
<p><a class="reference" href="./sequences.html">Sequences</a>, <a class="refentry reference" href="./vector.html"><tt class="refentry literal"><span class="pre">vector</span></tt></a>, <a class="refentry reference" href="./list.html"><tt class="refentry literal"><span class="pre">list</span></tt></a>, <a class="refentry reference" href="./set.html"><tt class="refentry literal"><span class="pre">set</span></tt></a></p>
<!-- modtime: November 15, 2004 01:17:18 +0000 -->
<!-- Sequences/Classes//set |40 -->
</div>
</div>
<div class="footer-separator"></div>
<table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./list.html" class="navigation-link">Prev</a>&nbsp;<a href="./set.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./list.html" class="navigation-link">Back</a>&nbsp;<a href="./set.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./classes.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>
</tr></table></body>
</html>
+109
View File
@@ -0,0 +1,109 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.3.6: http://docutils.sourceforge.net/" />
<title>The MPL Reference Manual: deref</title>
<link rel="stylesheet" href="../style.css" type="text/css" />
</head>
<body class="docframe refmanual">
<table class="header"><tr class="header"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./prior.html" class="navigation-link">Prev</a>&nbsp;<a href="./iterator-category.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./prior.html" class="navigation-link">Back</a>&nbsp;<a href="./iterator-category.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./iterator-metafunctions.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>
<td class="header-group page-location"><a href="../refmanual.html" class="navigation-link">Front Page</a> / <a href="./iterators.html" class="navigation-link">Iterators</a> / <a href="./iterator-metafunctions.html" class="navigation-link">Iterator Metafunctions</a> / <a href="./deref.html" class="navigation-link">deref</a></td>
</tr></table><div class="header-separator"></div>
<div class="section" id="deref">
<h1><a class="toc-backref" href="./iterator-metafunctions.html#id386" name="deref">deref</a></h1>
<div class="section" id="deref-synopsis">
<h3><a class="subsection-title" href="#synopsis" name="synopsis">Synopsis</a></h3>
<pre class="literal-block">
template&lt;
typename Iterator
&gt;
struct <a href="./deref.html" class="identifier">deref</a>
{
typedef <em>unspecified</em> type;
};
</pre>
</div>
<div class="section" id="deref-description">
<h3><a class="subsection-title" href="#description" name="description">Description</a></h3>
<p>Dereferences an iterator.</p>
</div>
<div class="section" id="deref-header">
<h3><a class="subsection-title" href="#header" name="header">Header</a></h3>
<pre class="literal-block">
#include &lt;<a href="../../../../boost/mpl/deref.hpp" class="header">boost/mpl/deref.hpp</a>&gt;
</pre>
</div>
<div class="section" id="deref-parameters">
<h3><a class="subsection-title" href="#parameters" name="parameters">Parameters</a></h3>
<table border="1" class="table">
<colgroup>
<col width="19%" />
<col width="35%" />
<col width="45%" />
</colgroup>
<thead valign="bottom">
<tr><th>Parameter</th>
<th>Requirement</th>
<th>Description</th>
</tr>
</thead>
<tbody valign="top">
<tr><td><tt class="literal"><span class="pre">Iterator</span></tt></td>
<td><a class="reference" href="./forward-iterator.html">Forward Iterator</a></td>
<td>The iterator to dereference.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="deref-expression-semantics">
<h3><a class="subsection-title" href="#expression-semantics" name="expression-semantics">Expression semantics</a></h3>
<p>For any <a class="reference" href="./forward-iterator.html">Forward Iterator</a>s <tt class="literal"><span class="pre">iter</span></tt>:</p>
<pre class="literal-block">
typedef <a href="./deref.html" class="identifier">deref</a>&lt;iter&gt;::type t;
</pre>
<table class="field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Return type:</th><td class="field-body">A type.</td>
</tr>
<tr class="field"><th class="field-name">Precondition:</th><td class="field-body"><tt class="literal"><span class="pre">iter</span></tt> is dereferenceable.</td>
</tr>
<tr class="field"><th class="field-name">Semantics:</th><td class="field-body"><p class="first"><tt class="literal"><span class="pre">t</span></tt> is identical to the element referenced by <tt class="literal"><span class="pre">iter</span></tt>. If <tt class="literal"><span class="pre">iter</span></tt> is
a user-defined iterator, the library-provided default implementation is
equivalent to</p>
<pre class="last literal-block">
typedef iter::type t;
</pre>
</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="deref-complexity">
<h3><a class="subsection-title" href="#complexity" name="complexity">Complexity</a></h3>
<p>Amortized constant time.</p>
</div>
<div class="section" id="deref-example">
<h3><a class="subsection-title" href="#example" name="example">Example</a></h3>
<pre class="literal-block">
typedef <a href="./vector.html" class="identifier">vector</a>&lt;char,short,int,long&gt; types;
typedef <a href="./begin.html" class="identifier">begin</a>&lt;types&gt;::type iter;
<a href="./assert.html" class="identifier">BOOST_MPL_ASSERT</a>(( is_same&lt; <a href="./deref.html" class="identifier">deref</a>&lt;iter&gt;::type, char > ));
</pre>
</div>
<div class="section" id="deref-see-also">
<h3><a class="subsection-title" href="#see-also" name="see-also">See also</a></h3>
<p><a class="reference" href="./iterators.html">Iterators</a>, <a class="refentry reference" href="./begin.html"><tt class="refentry literal"><span class="pre">begin</span></tt></a> / <a class="refentry reference" href="./end.html"><tt class="refentry literal"><span class="pre">end</span></tt></a>, <a class="refentry reference" href="./next.html"><tt class="refentry literal"><span class="pre">next</span></tt></a></p>
<!-- modtime: November 11, 2004 11:17:11 +0000 -->
<!-- Iterators/Iterator Metafunctions//iterator_category |60 -->
</div>
</div>
<div class="footer-separator"></div>
<table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./prior.html" class="navigation-link">Prev</a>&nbsp;<a href="./iterator-category.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./prior.html" class="navigation-link">Back</a>&nbsp;<a href="./iterator-category.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./iterator-metafunctions.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>
</tr></table></body>
</html>
+124
View File
@@ -0,0 +1,124 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.3.6: http://docutils.sourceforge.net/" />
<title>The MPL Reference Manual: distance</title>
<link rel="stylesheet" href="../style.css" type="text/css" />
</head>
<body class="docframe refmanual">
<table class="header"><tr class="header"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./advance.html" class="navigation-link">Prev</a>&nbsp;<a href="./next.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./advance.html" class="navigation-link">Back</a>&nbsp;<a href="./next.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./iterator-metafunctions.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>
<td class="header-group page-location"><a href="../refmanual.html" class="navigation-link">Front Page</a> / <a href="./iterators.html" class="navigation-link">Iterators</a> / <a href="./iterator-metafunctions.html" class="navigation-link">Iterator Metafunctions</a> / <a href="./distance.html" class="navigation-link">distance</a></td>
</tr></table><div class="header-separator"></div>
<div class="section" id="distance">
<h1><a class="toc-backref" href="./iterator-metafunctions.html#id383" name="distance">distance</a></h1>
<div class="section" id="distance-synopsis">
<h3><a class="subsection-title" href="#synopsis" name="synopsis">Synopsis</a></h3>
<pre class="literal-block">
template&lt;
typename First
, typename Last
&gt;
struct <a href="./distance.html" class="identifier">distance</a>
{
typedef <em>unspecified</em> type;
};
</pre>
</div>
<div class="section" id="distance-description">
<h3><a class="subsection-title" href="#description" name="description">Description</a></h3>
<p>Returns the distance between <tt class="literal"><span class="pre">First</span></tt> and <tt class="literal"><span class="pre">Last</span></tt> iterators, that is, an
<a class="reference" href="./integral-constant.html">Integral Constant</a> <tt class="literal"><span class="pre">n</span></tt> such that <tt class="literal"><span class="pre"><a href="./advance.html" class="identifier">advance</a>&lt;First,n&gt;::type</span></tt> is
identical to <tt class="literal"><span class="pre">Last</span></tt>.</p>
</div>
<div class="section" id="distance-header">
<h3><a class="subsection-title" href="#header" name="header">Header</a></h3>
<pre class="literal-block">
#include &lt;<a href="../../../../boost/mpl/distance.hpp" class="header">boost/mpl/distance.hpp</a>&gt;
</pre>
</div>
<div class="section" id="distance-parameters">
<h3><a class="subsection-title" href="#parameters" name="parameters">Parameters</a></h3>
<table border="1" class="table">
<colgroup>
<col width="19%" />
<col width="35%" />
<col width="45%" />
</colgroup>
<thead valign="bottom">
<tr><th>Parameter</th>
<th>Requirement</th>
<th>Description</th>
</tr>
</thead>
<tbody valign="top">
<tr><td><tt class="literal"><span class="pre">First</span></tt>,
<tt class="literal"><span class="pre">Last</span></tt></td>
<td><a class="reference" href="./forward-iterator.html">Forward Iterator</a></td>
<td>Iterators to compute a
distance between.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="distance-model-of">
<h3><a class="subsection-title" href="#model-of" name="model-of">Model Of</a></h3>
<p><a class="reference" href="./tag-dispatched.html">Tag Dispatched Metafunction</a></p>
</div>
<div class="section" id="distance-expression-semantics">
<h3><a class="subsection-title" href="#expression-semantics" name="expression-semantics">Expression semantics</a></h3>
<p>For any <a class="reference" href="./forward-iterator.html">Forward Iterator</a>s <tt class="literal"><span class="pre">first</span></tt> and <tt class="literal"><span class="pre">last</span></tt>:</p>
<pre class="literal-block">
typedef <a href="./distance.html" class="identifier">distance</a>&lt;first,last&gt;::type n;
</pre>
<table class="field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Return type:</th><td class="field-body"><a class="reference" href="./integral-constant.html">Integral Constant</a>.</td>
</tr>
<tr class="field"><th class="field-name">Precondition:</th><td class="field-body">[<tt class="literal"><span class="pre">first</span></tt>, <tt class="literal"><span class="pre">last</span></tt>) is a valid range.</td>
</tr>
<tr class="field"><th class="field-name">Semantics:</th><td class="field-body"><p class="first">Equivalent to</p>
<pre class="last literal-block">
typedef <a href="./iter-fold.html" class="identifier">iter_fold</a>&lt;
<a href="./iterator-range.html" class="identifier">iterator_range</a>&lt;first,last&gt;
, <a href="./long.html" class="identifier">long_</a>&lt;0&gt;
, <a href="./next.html" class="identifier">next</a>&lt;_1&gt;
&gt;::type n;
</pre>
</td>
</tr>
<tr class="field"><th class="field-name">Postcondition:</th><td class="field-body"><tt class="literal"><span class="pre">is_same&lt;</span> <span class="pre"><a href="./advance.html" class="identifier">advance</a>&lt;first,n&gt;::type,</span> <span class="pre">last</span> <span class="pre">&gt;::value</span> <span class="pre">==</span> <span class="pre">true</span></tt>.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="distance-complexity">
<h3><a class="subsection-title" href="#complexity" name="complexity">Complexity</a></h3>
<p>Amortized constant time if <tt class="literal"><span class="pre">first</span></tt> and <tt class="literal"><span class="pre">last</span></tt> are <a class="reference" href="./random-access-iterator.html">Random Access Iterator</a>s,
otherwise linear time.</p>
</div>
<div class="section" id="distance-example">
<h3><a class="subsection-title" href="#example" name="example">Example</a></h3>
<pre class="literal-block">
typedef <a href="./range-c.html" class="identifier">range_c</a>&lt;int,0,10&gt;::type range;
typedef <a href="./begin.html" class="identifier">begin</a>&lt;range&gt;::type first;
typedef <a href="./end.html" class="identifier">end</a>&lt;range&gt;::type last;
<a href="./assert-relation.html" class="identifier">BOOST_MPL_ASSERT_RELATION</a>( (<a href="./distance.html" class="identifier">distance</a>&lt;first,last&gt;::value), ==, 10);
</pre>
</div>
<div class="section" id="distance-see-also">
<h3><a class="subsection-title" href="#see-also" name="see-also">See also</a></h3>
<p><a class="reference" href="./iterators.html">Iterators</a>, <a class="reference" href="./tag-dispatched.html">Tag Dispatched Metafunction</a>, <a class="refentry reference" href="./advance.html"><tt class="refentry literal"><span class="pre">advance</span></tt></a>, <a class="refentry reference" href="./next.html"><tt class="refentry literal"><span class="pre">next</span></tt></a>, <a class="refentry reference" href="./prior.html"><tt class="refentry literal"><span class="pre">prior</span></tt></a></p>
<!-- modtime: November 11, 2004 11:16:46 +0000 -->
<!-- Iterators/Iterator Metafunctions//next |30 -->
</div>
</div>
<div class="footer-separator"></div>
<table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./advance.html" class="navigation-link">Prev</a>&nbsp;<a href="./next.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./advance.html" class="navigation-link">Back</a>&nbsp;<a href="./next.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./iterator-metafunctions.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>
</tr></table></body>
</html>
+144
View File
@@ -0,0 +1,144 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.3.6: http://docutils.sourceforge.net/" />
<title>The MPL Reference Manual: divides</title>
<link rel="stylesheet" href="../style.css" type="text/css" />
</head>
<body class="docframe refmanual">
<table class="header"><tr class="header"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./times.html" class="navigation-link">Prev</a>&nbsp;<a href="./modulus.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./times.html" class="navigation-link">Back</a>&nbsp;<a href="./modulus.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./arithmetic-operations.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>
<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="./arithmetic-operations.html" class="navigation-link">Arithmetic Operations</a> / <a href="./divides.html" class="navigation-link">divides</a></td>
</tr></table><div class="header-separator"></div>
<div class="section" id="divides">
<h1><a class="toc-backref" href="./arithmetic-operations.html#id465" name="divides">divides</a></h1>
<div class="section" id="divides-synopsis">
<h3><a class="subsection-title" href="#synopsis" name="synopsis">Synopsis</a></h3>
<pre class="literal-block">
template&lt;
typename T1
, typename T2
, typename T3 = <em>unspecified</em>
<em>...</em>
, typename T<em>n</em> = <em>unspecified</em>
&gt;
struct <a href="./divides.html" class="identifier">divides</a>
{
typedef <em>unspecified</em> type;
};
</pre>
</div>
<div class="section" id="divides-description">
<h3><a class="subsection-title" href="#description" name="description">Description</a></h3>
<p>Returns the quotient of its arguments.</p>
</div>
<div class="section" id="divides-header">
<h3><a class="subsection-title" href="#header" name="header">Header</a></h3>
<pre class="literal-block">
#include &lt;<a href="../../../../boost/mpl/divides.hpp" class="header">boost/mpl/divides.hpp</a>&gt;
#include &lt;<a href="../../../../boost/mpl/arithmetic.hpp" class="header">boost/mpl/arithmetic.hpp</a>&gt;
</pre>
</div>
<div class="section" id="divides-model-of">
<h3><a class="subsection-title" href="#model-of" name="model-of">Model of</a></h3>
<p><a class="reference" href="./numeric-metafunction.html">Numeric Metafunction</a></p>
</div>
<div class="section" id="divides-parameters">
<h3><a class="subsection-title" href="#parameters" name="parameters">Parameters</a></h3>
<table border="1" class="table">
<colgroup>
<col width="17%" />
<col width="30%" />
<col width="53%" />
</colgroup>
<thead valign="bottom">
<tr><th>Parameter</th>
<th>Requirement</th>
<th>Description</th>
</tr>
</thead>
<tbody valign="top">
<tr><td><tt class="literal"><span class="pre">T1</span></tt>, <tt class="literal"><span class="pre">T2</span></tt>,... <tt class="literal"><span class="pre">Tn</span></tt></td>
<td><a class="reference" href="./integral-constant.html">Integral Constant</a></td>
<td>Operation's arguments.</td>
</tr>
</tbody>
</table>
<p>[<em>Note:</em> The requirements listed in this specification
are the ones imposed by the default implementation. See <a class="reference" href="./numeric-metafunction.html">Numeric Metafunction</a> concept
for the details on how to provide an implementation for a user-defined numeric type
that does not satisfy the <a class="reference" href="./integral-constant.html">Integral Constant</a> requirements. — <em>end note</em>]</p>
</div>
<div class="section" id="divides-expression-semantics">
<h3><a class="subsection-title" href="#expression-semantics" name="expression-semantics">Expression semantics</a></h3>
<p>For any <a class="reference" href="./integral-constant.html">Integral Constant</a>s <em>c</em><sub>1</sub>,<em>c</em><sub>2</sub>,... <em>c</em><sub>n</sub>:</p>
<pre class="literal-block">
typedef <a href="./divides.html" class="identifier">divides</a>&lt;c1,<em>...</em>c<em>n</em>&gt;::type r;
</pre>
<table class="field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Return type:</th><td class="field-body"><a class="reference" href="./integral-constant.html">Integral Constant</a>.</td>
</tr>
<tr class="field"><th class="field-name">Precondition:</th><td class="field-body"><tt class="literal"><span class="pre">c2::value</span> <span class="pre">!=</span> <span class="pre">0</span></tt>, <em>...</em> <tt class="literal"><span class="pre">cn::value</span> <span class="pre">!=</span> <span class="pre">0</span></tt>.</td>
</tr>
<tr class="field"><th class="field-name">Semantics:</th><td class="field-body"><p class="first">Equivalent to</p>
<pre class="last literal-block">
typedef <a href="./integral-c.html" class="identifier">integral_c</a>&lt;
typeof(c1::value / c2::value)
, ( c1::value / c2::value )
&gt; c;
typedef <a href="./divides.html" class="identifier">divides</a>&lt;c,c3,<em>...</em>c<em>n</em>&gt;::type r;
</pre>
</td>
</tr>
</tbody>
</table>
<!-- .......................................................................... -->
<pre class="literal-block">
typedef <a href="./divides.html" class="identifier">divides</a>&lt;c1,<em>...</em>c<em>n</em>&gt; r;
</pre>
<table class="field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Return type:</th><td class="field-body"><a class="reference" href="./integral-constant.html">Integral Constant</a>.</td>
</tr>
<tr class="field"><th class="field-name">Precondition:</th><td class="field-body"><tt class="literal"><span class="pre">c2::value</span> <span class="pre">!=</span> <span class="pre">0</span></tt>, <em>...</em> <tt class="literal"><span class="pre">cn::value</span> <span class="pre">!=</span> <span class="pre">0</span></tt>.</td>
</tr>
<tr class="field"><th class="field-name">Semantics:</th><td class="field-body"><p class="first">Equivalent to</p>
<pre class="last literal-block">
struct r : <a href="./divides.html" class="identifier">divides</a>&lt;c1,<em>...</em>c<em>n</em>&gt;::type {};
</pre>
</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="divides-complexity">
<h3><a class="subsection-title" href="#complexity" name="complexity">Complexity</a></h3>
<p>Amortized constant time.</p>
</div>
<div class="section" id="divides-example">
<h3><a class="subsection-title" href="#example" name="example">Example</a></h3>
<pre class="literal-block">
typedef <a href="./divides.html" class="identifier">divides</a>&lt; <a href="./int.html" class="identifier">int_</a>&lt;-10&gt;, <a href="./int.html" class="identifier">int_</a>&lt;3&gt;, <a href="./long.html" class="identifier">long_</a>&lt;1&gt; &gt;::type r;
<a href="./assert-relation.html" class="identifier">BOOST_MPL_ASSERT_RELATION</a>( r::value, ==, -3 );
<a href="./assert.html" class="identifier">BOOST_MPL_ASSERT</a>(( is_same&lt; r::<a href="./value-type.html" class="identifier">value_type</a>, long > ));
</pre>
</div>
<div class="section" id="divides-see-also">
<h3><a class="subsection-title" href="#see-also" name="see-also">See also</a></h3>
<p><a class="reference" href="./arithmetic-operations.html">Arithmetic Operations</a>, <a class="reference" href="./numeric-metafunction.html">Numeric Metafunction</a>, <a class="refentry reference" href="./numeric-cast.html"><tt class="refentry literal"><span class="pre">numeric_cast</span></tt></a>, <a class="refentry reference" href="./times.html"><tt class="refentry literal"><span class="pre">times</span></tt></a>, <a class="refentry reference" href="./modulus.html"><tt class="refentry literal"><span class="pre">modulus</span></tt></a>, <a class="refentry reference" href="./plus.html"><tt class="refentry literal"><span class="pre">plus</span></tt></a></p>
<!-- modtime: November 10, 2004 04:43:02 +0000 -->
<!-- Metafunctions/Arithmetic Operations//modulus |50 -->
</div>
</div>
<div class="footer-separator"></div>
<table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./times.html" class="navigation-link">Prev</a>&nbsp;<a href="./modulus.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./times.html" class="navigation-link">Back</a>&nbsp;<a href="./modulus.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./arithmetic-operations.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>
</tr></table></body>
</html>
+44
View File
@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.3.6: http://docutils.sourceforge.net/" />
<title>The MPL Reference Manual: empty_base</title>
<link rel="stylesheet" href="../style.css" type="text/css" />
</head>
<body class="docframe refmanual">
<table class="header"><tr class="header"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./pair.html" class="navigation-link">Prev</a>&nbsp;<a href="./void.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./pair.html" class="navigation-link">Back</a>&nbsp;<a href="./void.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./data-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>
<td class="header-group page-location"><a href="../refmanual.html" class="navigation-link">Front Page</a> / <a href="./data-types.html" class="navigation-link">Data Types</a> / <a href="./data-miscellaneous.html" class="navigation-link">Miscellaneous</a> / <a href="./empty-base.html" class="navigation-link">empty_base</a></td>
</tr></table><div class="header-separator"></div>
<div class="section" id="empty-base">
<h1><a class="toc-backref" href="./data-miscellaneous.html#id507" name="empty-base">empty_base</a></h1>
<div class="section" id="data-empty-synopsis">
<h3><a class="subsection-title" href="#synopsis" name="synopsis">Synopsis</a></h3>
<pre class="literal-block">
struct <a href="./empty-base.html" class="identifier">empty_base</a> {};
</pre>
</div>
<div class="section" id="data-empty-description">
<h3><a class="subsection-title" href="#description" name="description">Description</a></h3>
<p>An empty base class. Inheritance from <a class="refentry reference" href="./empty-base.html"><tt class="refentry literal"><span class="pre">empty_base</span></tt></a> through the <a class="refentry reference" href="./inherit.html"><tt class="refentry literal"><span class="pre">inherit</span></tt></a>
metafunction is a no-op.</p>
</div>
<div class="section" id="data-empty-header">
<h3><a class="subsection-title" href="#header" name="header">Header</a></h3>
<pre class="literal-block">
#include &lt;<a href="../../../../boost/mpl/empty_base.hpp" class="header">boost/mpl/empty_base.hpp</a>&gt;
</pre>
</div>
<div class="section" id="data-empty-see-also">
<h3><a class="subsection-title" href="#see-also" name="see-also">See also</a></h3>
<p><a class="reference" href="./data-types.html">Data Types</a>, <a class="refentry reference" href="./inherit.html"><tt class="refentry literal"><span class="pre">inherit</span></tt></a>, <a class="refentry reference" href="./inherit-linearly.html"><tt class="refentry literal"><span class="pre">inherit_linearly</span></tt></a>, <a class="refentry reference" href="./void.html"><tt class="refentry literal"><span class="pre">void_</span></tt></a></p>
<!-- modtime: November 10, 2004 04:42:54 +0000 -->
<!-- Data Types/Miscellaneous//void_ |100 -->
</div>
</div>
<div class="footer-separator"></div>
<table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./pair.html" class="navigation-link">Prev</a>&nbsp;<a href="./void.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./pair.html" class="navigation-link">Back</a>&nbsp;<a href="./void.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./data-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>
</tr></table></body>
</html>
+89
View File
@@ -0,0 +1,89 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.3.6: http://docutils.sourceforge.net/" />
<title>The MPL Reference Manual: empty_sequence</title>
<link rel="stylesheet" href="../style.css" type="text/css" />
</head>
<body class="docframe refmanual">
<table class="header"><tr class="header"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./views.html" class="navigation-link">Prev</a>&nbsp;<a href="./filter-view.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group">Back&nbsp;<a href="./filter-view.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./views.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>
<td class="header-group page-location"><a href="../refmanual.html" class="navigation-link">Front Page</a> / <a href="./sequences.html" class="navigation-link">Sequences</a> / <a href="./views.html" class="navigation-link">Views</a> / <a href="./empty-sequence.html" class="navigation-link">empty_sequence</a></td>
</tr></table><div class="header-separator"></div>
<div class="section" id="empty-sequence">
<h1><a class="toc-backref" href="./views.html#id345" name="empty-sequence">empty_sequence</a></h1>
<div class="section" id="empty-synopsis">
<h3><a class="subsection-title" href="#synopsis" name="synopsis">Synopsis</a></h3>
<pre class="literal-block">
struct <a href="./empty-sequence.html" class="identifier">empty_sequence</a>
{
// <em>unspecified</em>
// <em>...</em>
};
</pre>
</div>
<div class="section" id="empty-description">
<h3><a class="subsection-title" href="#description" name="description">Description</a></h3>
<p>Represents a sequence containing no elements.</p>
</div>
<div class="section" id="empty-header">
<h3><a class="subsection-title" href="#header" name="header">Header</a></h3>
<pre class="literal-block">
#include &lt;<a href="../../../../boost/mpl/empty_sequence.hpp" class="header">boost/mpl/empty_sequence.hpp</a>&gt;
</pre>
</div>
<div class="section" id="empty-expression-semantics">
<h3><a class="subsection-title" href="#expression-semantics" name="expression-semantics">Expression semantics</a></h3>
<p>The semantics of an expression are defined only
where they differ from, or are not defined in <a class="reference" href="./random-access-sequence.html">Random Access Sequence</a>.</p>
<p>In the following table, <tt class="literal"><span class="pre">s</span></tt> is an instance of <tt class="literal"><span class="pre"><a href="./empty-sequence.html" class="identifier">empty_sequence</a></span></tt>.</p>
<table border="1" class="table">
<colgroup>
<col width="34%" />
<col width="66%" />
</colgroup>
<thead valign="bottom">
<tr><th>Expression</th>
<th>Semantics</th>
</tr>
</thead>
<tbody valign="top">
<tr><td><tt class="literal"><span class="pre"><a href="./empty-sequence.html" class="identifier">empty_sequence</a></span></tt></td>
<td>An empty <a class="reference" href="./random-access-sequence.html">Random Access Sequence</a>.</td>
</tr>
<tr><td><tt class="literal"><span class="pre"><a href="./size.html" class="identifier">size</a>&lt;s&gt;::type</span></tt></td>
<td><tt class="literal"><span class="pre"><a href="./size.html" class="identifier">size</a>&lt;s&gt;::value</span> <span class="pre">==</span> <span class="pre">0</span></tt>; see <a class="reference" href="./random-access-sequence.html">Random Access Sequence</a>.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="empty-example">
<h3><a class="subsection-title" href="#example" name="example">Example</a></h3>
<pre class="literal-block">
typedef <a href="./begin.html" class="identifier">begin</a>&lt;<a href="./empty-sequence.html" class="identifier">empty_sequence</a>&gt;::type first;
typedef <a href="./end.html" class="identifier">end</a>&lt;<a href="./empty-sequence.html" class="identifier">empty_sequence</a>&gt;::type last;
<a href="./assert.html" class="identifier">BOOST_MPL_ASSERT</a>(( is_same&lt;first,last&gt; ));
<a href="./assert-relation.html" class="identifier">BOOST_MPL_ASSERT_RELATION</a>( <a href="./size.html" class="identifier">size</a>&lt;<a href="./empty-sequence.html" class="identifier">empty_sequence</a>&gt;::value, ==, 0 );
typedef <a href="./transform-view.html" class="identifier">transform_view</a>&lt;
<a href="./empty-sequence.html" class="identifier">empty_sequence</a>
, add_pointer&lt;_&gt;
&gt; empty_view;
<a href="./assert-relation.html" class="identifier">BOOST_MPL_ASSERT_RELATION</a>( <a href="./size.html" class="identifier">size</a>&lt;<a href="./empty-sequence.html" class="identifier">empty_sequence</a>&gt;::value, ==, 0 );
</pre>
</div>
<div class="section" id="empty-see-also">
<h3><a class="subsection-title" href="#see-also" name="see-also">See also</a></h3>
<p><a class="reference" href="./sequences.html">Sequences</a>, <a class="reference" href="./views.html">Views</a>, <a class="refentry reference" href="./vector.html"><tt class="refentry literal"><span class="pre">vector</span></tt></a>, <a class="refentry reference" href="./list.html"><tt class="refentry literal"><span class="pre">list</span></tt></a>, <a class="refentry reference" href="./single-view.html"><tt class="refentry literal"><span class="pre">single_view</span></tt></a></p>
<!-- modtime: November 13, 2004 20:20:53 +0000 -->
<!-- Sequences/Views//filter_view -->
</div>
</div>
<div class="footer-separator"></div>
<table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./views.html" class="navigation-link">Prev</a>&nbsp;<a href="./filter-view.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group">Back&nbsp;<a href="./filter-view.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./views.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>
</tr></table></body>
</html>
+109
View File
@@ -0,0 +1,109 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.3.6: http://docutils.sourceforge.net/" />
<title>The MPL Reference Manual: empty</title>
<link rel="stylesheet" href="../style.css" type="text/css" />
</head>
<body class="docframe refmanual">
<table class="header"><tr class="header"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./clear.html" class="navigation-link">Prev</a>&nbsp;<a href="./end.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./clear.html" class="navigation-link">Back</a>&nbsp;<a href="./end.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./intrinsic-metafunctions.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>
<td class="header-group page-location"><a href="../refmanual.html" class="navigation-link">Front Page</a> / <a href="./sequences.html" class="navigation-link">Sequences</a> / <a href="./intrinsic-metafunctions.html" class="navigation-link">Intrinsic Metafunctions</a> / <a href="./empty.html" class="navigation-link">empty</a></td>
</tr></table><div class="header-separator"></div>
<div class="section" id="empty">
<h1><a class="toc-backref" href="./intrinsic-metafunctions.html#id358" name="empty">empty</a></h1>
<div class="section" id="intrinsic-empty-synopsis">
<h3><a class="subsection-title" href="#synopsis" name="synopsis">Synopsis</a></h3>
<pre class="literal-block">
template&lt;
typename Sequence
&gt;
struct <a href="./empty.html" class="identifier">empty</a>
{
typedef <em>unspecified</em> type;
};
</pre>
</div>
<div class="section" id="intrinsic-empty-description">
<h3><a class="subsection-title" href="#description" name="description">Description</a></h3>
<p>Returns an <a class="reference" href="./integral-constant.html">Integral Constant</a> <tt class="literal"><span class="pre">c</span></tt> such that <tt class="literal"><span class="pre">c::value</span> <span class="pre">==</span> <span class="pre">true</span></tt> if
and only if the sequence is empty.</p>
</div>
<div class="section" id="intrinsic-empty-header">
<h3><a class="subsection-title" href="#header" name="header">Header</a></h3>
<pre class="literal-block">
#include &lt;<a href="../../../../boost/mpl/empty.hpp" class="header">boost/mpl/empty.hpp</a>&gt;
</pre>
</div>
<div class="section" id="empty-model-of">
<h3><a class="subsection-title" href="#model-of" name="model-of">Model of</a></h3>
<p><a class="reference" href="./tag-dispatched.html">Tag Dispatched Metafunction</a></p>
</div>
<div class="section" id="empty-parameters">
<h3><a class="subsection-title" href="#parameters" name="parameters">Parameters</a></h3>
<table border="1" class="table">
<colgroup>
<col width="21%" />
<col width="32%" />
<col width="48%" />
</colgroup>
<thead valign="bottom">
<tr><th>Parameter</th>
<th>Requirement</th>
<th>Description</th>
</tr>
</thead>
<tbody valign="top">
<tr><td><tt class="literal"><span class="pre">Sequence</span></tt></td>
<td><a class="reference" href="./forward-sequence.html">Forward Sequence</a></td>
<td>A sequence to test.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="intrinsic-empty-expression-semantics">
<h3><a class="subsection-title" href="#expression-semantics" name="expression-semantics">Expression semantics</a></h3>
<p>For any <a class="reference" href="./forward-sequence.html">Forward Sequence</a> <tt class="literal"><span class="pre">s</span></tt>:</p>
<pre class="literal-block">
typedef <a href="./empty.html" class="identifier">empty</a>&lt;s&gt;::type c;
</pre>
<table class="field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Return type:</th><td class="field-body">Boolean <a class="reference" href="./integral-constant.html">Integral Constant</a>.</td>
</tr>
<tr class="field"><th class="field-name">Semantics:</th><td class="field-body">Equivalent to <tt class="literal"><span class="pre">typedef</span> <span class="pre">is_same&lt;</span> <span class="pre"><a href="./begin.html" class="identifier">begin</a>&lt;s&gt;::type,<a href="./end.html" class="identifier">end</a>&lt;s&gt;::type</span> <span class="pre">&gt;::type</span> <span class="pre">c;</span></tt>.</td>
</tr>
<tr class="field"><th class="field-name">Postcondition:</th><td class="field-body"><tt class="literal"><span class="pre"><a href="./empty.html" class="identifier">empty</a>&lt;s&gt;::value</span> <span class="pre">==</span> <span class="pre">(</span> <span class="pre"><a href="./size.html" class="identifier">size</a>&lt;s&gt;::value</span> <span class="pre">==</span> <span class="pre">0</span> <span class="pre">)</span></tt>.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="empty-complexity">
<h3><a class="subsection-title" href="#complexity" name="complexity">Complexity</a></h3>
<p>Amortized constant time.</p>
</div>
<div class="section" id="intrinsic-empty-example">
<h3><a class="subsection-title" href="#example" name="example">Example</a></h3>
<pre class="literal-block">
typedef <a href="./range-c.html" class="identifier">range_c</a>&lt;int,0,0&gt; empty_range;
typedef <a href="./vector.html" class="identifier">vector</a>&lt;long,float,double&gt; types;
<a href="./assert.html" class="identifier">BOOST_MPL_ASSERT</a>( <a href="./empty.html" class="identifier">empty</a>&lt;empty_range&gt; );
<a href="./assert-not.html" class="identifier">BOOST_MPL_ASSERT_NOT</a>( <a href="./empty.html" class="identifier">empty</a>&lt;types&gt; );
</pre>
</div>
<div class="section" id="intrinsic-empty-see-also">
<h3><a class="subsection-title" href="#see-also" name="see-also">See also</a></h3>
<p><a class="reference" href="./forward-sequence.html">Forward Sequence</a>, <a class="reference" href="./integral-constant.html">Integral Constant</a>, <a class="refentry reference" href="./size.html"><tt class="refentry literal"><span class="pre">size</span></tt></a>, <a class="refentry reference" href="./begin.html"><tt class="refentry literal"><span class="pre">begin</span></tt></a> / <a class="refentry reference" href="./end.html"><tt class="refentry literal"><span class="pre">end</span></tt></a></p>
<!-- modtime: November 15, 2004 02:43:18 +0000 -->
<!-- Sequences/Intrinsic Metafunctions//end -->
</div>
</div>
<div class="footer-separator"></div>
<table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./clear.html" class="navigation-link">Prev</a>&nbsp;<a href="./end.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./clear.html" class="navigation-link">Back</a>&nbsp;<a href="./end.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./intrinsic-metafunctions.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>
</tr></table></body>
</html>
+111
View File
@@ -0,0 +1,111 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.3.6: http://docutils.sourceforge.net/" />
<title>The MPL Reference Manual: end</title>
<link rel="stylesheet" href="../style.css" type="text/css" />
</head>
<body class="docframe refmanual">
<table class="header"><tr class="header"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./empty.html" class="navigation-link">Prev</a>&nbsp;<a href="./erase.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./empty.html" class="navigation-link">Back</a>&nbsp;<a href="./erase.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./intrinsic-metafunctions.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>
<td class="header-group page-location"><a href="../refmanual.html" class="navigation-link">Front Page</a> / <a href="./sequences.html" class="navigation-link">Sequences</a> / <a href="./intrinsic-metafunctions.html" class="navigation-link">Intrinsic Metafunctions</a> / <a href="./end.html" class="navigation-link">end</a></td>
</tr></table><div class="header-separator"></div>
<div class="section" id="end">
<h1><a class="toc-backref" href="./intrinsic-metafunctions.html#id359" name="end">end</a></h1>
<div class="section" id="end-synopsis">
<h3><a class="subsection-title" href="#synopsis" name="synopsis">Synopsis</a></h3>
<pre class="literal-block">
template&lt;
typename X
&gt;
struct <a href="./end.html" class="identifier">end</a>
{
typedef <em>unspecified</em> type;
};
</pre>
</div>
<div class="section" id="end-description">
<h3><a class="subsection-title" href="#description" name="description">Description</a></h3>
<p>Returns the sequence's past-the-end iterator. If the argument is not a
<a class="reference" href="./forward-sequence.html">Forward Sequence</a>, returns <a class="refentry reference" href="./void.html"><tt class="refentry literal"><span class="pre">void_</span></tt></a>.</p>
</div>
<div class="section" id="end-header">
<h3><a class="subsection-title" href="#header" name="header">Header</a></h3>
<pre class="literal-block">
#include &lt;<a href="../../../../boost/mpl/begin_end.hpp" class="header">boost/mpl/begin_end.hpp</a>&gt;
</pre>
</div>
<div class="section" id="end-model-of">
<h3><a class="subsection-title" href="#model-of" name="model-of">Model of</a></h3>
<p><a class="reference" href="./tag-dispatched.html">Tag Dispatched Metafunction</a></p>
</div>
<div class="section" id="end-parameters">
<h3><a class="subsection-title" href="#parameters" name="parameters">Parameters</a></h3>
<table border="1" class="table">
<colgroup>
<col width="19%" />
<col width="23%" />
<col width="58%" />
</colgroup>
<thead valign="bottom">
<tr><th>Parameter</th>
<th>Requirement</th>
<th>Description</th>
</tr>
</thead>
<tbody valign="top">
<tr><td><tt class="literal"><span class="pre">X</span></tt></td>
<td>Any type</td>
<td>A type whose end iterator, if any, will be
returned.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="end-expression-semantics">
<h3><a class="subsection-title" href="#expression-semantics" name="expression-semantics">Expression semantics</a></h3>
<p>For any arbitrary type <tt class="literal"><span class="pre">x</span></tt>:</p>
<pre class="literal-block">
typedef <a href="./end.html" class="identifier">end</a>&lt;x&gt;::type last;
</pre>
<table class="field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Return type:</th><td class="field-body"><a class="reference" href="./forward-iterator.html">Forward Iterator</a> or <a class="refentry reference" href="./void.html"><tt class="refentry literal"><span class="pre">void_</span></tt></a>.</td>
</tr>
<tr class="field"><th class="field-name">Semantics:</th><td class="field-body">If <tt class="literal"><span class="pre">x</span></tt> is <a class="reference" href="./forward-sequence.html">Forward Sequence</a>, <tt class="literal"><span class="pre">last</span></tt> is an iterator pointing one past the
last element in <tt class="literal"><span class="pre">s</span></tt>; otherwise <tt class="literal"><span class="pre">last</span></tt> is <a class="refentry reference" href="./void.html"><tt class="refentry literal"><span class="pre">void_</span></tt></a>.</td>
</tr>
<tr class="field"><th class="field-name">Postcondition:</th><td class="field-body">If <tt class="literal"><span class="pre">last</span></tt> is an iterator, it is past-the-end.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="end-complexity">
<h3><a class="subsection-title" href="#complexity" name="complexity">Complexity</a></h3>
<p>Amortized constant time.</p>
</div>
<div class="section" id="end-example">
<h3><a class="subsection-title" href="#example" name="example">Example</a></h3>
<pre class="literal-block">
typedef <a href="./vector.html" class="identifier">vector</a>&lt;long&gt; v;
typedef <a href="./begin.html" class="identifier">begin</a>&lt;v&gt;::type first;
typedef <a href="./end.html" class="identifier">end</a>&lt;v&gt;::type last;
<a href="./assert.html" class="identifier">BOOST_MPL_ASSERT</a>(( is_same&lt; <a href="./next.html" class="identifier">next</a>&lt;first&gt;::type, last > ));
</pre>
</div>
<div class="section" id="end-see-also">
<h3><a class="subsection-title" href="#see-also" name="see-also">See also</a></h3>
<p><a class="reference" href="./iterators.html">Iterators</a>, <a class="reference" href="./forward-sequence.html">Forward Sequence</a>, <a class="refentry reference" href="./begin.html"><tt class="refentry literal"><span class="pre">begin</span></tt></a>, <a class="refentry reference" href="./end.html"><tt class="refentry literal"><span class="pre">end</span></tt></a>, <a class="refentry reference" href="./next.html"><tt class="refentry literal"><span class="pre">next</span></tt></a></p>
<!-- modtime: November 13, 2004 01:26:54 +0000 -->
<!-- Sequences/Intrinsic Metafunctions//erase -->
</div>
</div>
<div class="footer-separator"></div>
<table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./empty.html" class="navigation-link">Prev</a>&nbsp;<a href="./erase.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./empty.html" class="navigation-link">Back</a>&nbsp;<a href="./erase.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./intrinsic-metafunctions.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>
</tr></table></body>
</html>
+132
View File
@@ -0,0 +1,132 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.3.6: http://docutils.sourceforge.net/" />
<title>The MPL Reference Manual: equal_to</title>
<link rel="stylesheet" href="../style.css" type="text/css" />
</head>
<body class="docframe refmanual">
<table class="header"><tr class="header"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./greater-equal.html" class="navigation-link">Prev</a>&nbsp;<a href="./not-equal-to.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./greater-equal.html" class="navigation-link">Back</a>&nbsp;<a href="./not-equal-to.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./comparisons.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>
<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="./comparisons.html" class="navigation-link">Comparisons</a> / <a href="./equal-to.html" class="navigation-link">equal_to</a></td>
</tr></table><div class="header-separator"></div>
<div class="section" id="equal-to">
<h1><a class="toc-backref" href="./comparisons.html#id473" name="equal-to">equal_to</a></h1>
<div class="section" id="comparisons-equal-synopsis">
<h3><a class="subsection-title" href="#synopsis" name="synopsis">Synopsis</a></h3>
<pre class="literal-block">
template&lt;
typename T1
, typename T2
&gt;
struct <a href="./equal-to.html" class="identifier">equal_to</a>
{
typedef <em>unspecified</em> type;
};
</pre>
</div>
<div class="section" id="comparisons-equal-description">
<h3><a class="subsection-title" href="#description" name="description">Description</a></h3>
<p>Returns a true-valued <a class="reference" href="./integral-constant.html">Integral Constant</a> if <tt class="literal"><span class="pre">T1</span></tt> and <tt class="literal"><span class="pre">T2</span></tt> are equal.</p>
</div>
<div class="section" id="comparisons-equal-header">
<h3><a class="subsection-title" href="#header" name="header">Header</a></h3>
<pre class="literal-block">
#include &lt;<a href="../../../../boost/mpl/equal_to.hpp" class="header">boost/mpl/equal_to.hpp</a>&gt;
#include &lt;<a href="../../../../boost/mpl/comparison.hpp" class="header">boost/mpl/comparison.hpp</a>&gt;
</pre>
</div>
<div class="section" id="equal-model-of">
<h3><a class="subsection-title" href="#model-of" name="model-of">Model of</a></h3>
<p><a class="reference" href="./numeric-metafunction.html">Numeric Metafunction</a></p>
</div>
<div class="section" id="comparisons-equal-parameters">
<h3><a class="subsection-title" href="#parameters" name="parameters">Parameters</a></h3>
<table border="1" class="table">
<colgroup>
<col width="17%" />
<col width="30%" />
<col width="53%" />
</colgroup>
<thead valign="bottom">
<tr><th>Parameter</th>
<th>Requirement</th>
<th>Description</th>
</tr>
</thead>
<tbody valign="top">
<tr><td><tt class="literal"><span class="pre">T1</span></tt>, <tt class="literal"><span class="pre">T2</span></tt></td>
<td><a class="reference" href="./integral-constant.html">Integral Constant</a></td>
<td>Operation's arguments.</td>
</tr>
</tbody>
</table>
<p>[<em>Note:</em> The requirements listed in this specification
are the ones imposed by the default implementation. See <a class="reference" href="./numeric-metafunction.html">Numeric Metafunction</a> concept
for the details on how to provide an implementation for a user-defined numeric type
that does not satisfy the <a class="reference" href="./integral-constant.html">Integral Constant</a> requirements. — <em>end note</em>]</p>
</div>
<div class="section" id="comparisons-equal-expression-semantics">
<h3><a class="subsection-title" href="#expression-semantics" name="expression-semantics">Expression semantics</a></h3>
<p>For any <a class="reference" href="./integral-constant.html">Integral Constant</a>s <tt class="literal"><span class="pre">c1</span></tt> and <tt class="literal"><span class="pre">c2</span></tt>:</p>
<pre class="literal-block">
typedef <a href="./equal-to.html" class="identifier">equal_to</a>&lt;c1,c2&gt;::type r;
</pre>
<table class="field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Return type:</th><td class="field-body"><a class="reference" href="./integral-constant.html">Integral Constant</a>.</td>
</tr>
<tr class="field"><th class="field-name">Semantics:</th><td class="field-body"><p class="first">Equivalent to</p>
<pre class="last literal-block">
typedef <a href="./bool.html" class="identifier">bool_</a>&lt; (c1::value == c2::value) &gt; r;
</pre>
</td>
</tr>
</tbody>
</table>
<!-- .......................................................................... -->
<pre class="literal-block">
typedef <a href="./equal-to.html" class="identifier">equal_to</a>&lt;c1,c2&gt; r;
</pre>
<table class="field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Return type:</th><td class="field-body"><a class="reference" href="./integral-constant.html">Integral Constant</a>.</td>
</tr>
<tr class="field"><th class="field-name">Semantics:</th><td class="field-body"><p class="first">Equivalent to</p>
<pre class="last literal-block">
struct r : <a href="./equal-to.html" class="identifier">equal_to</a>&lt;c1,c2&gt;::type {};
</pre>
</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="comparisons-equal-complexity">
<h3><a class="subsection-title" href="#complexity" name="complexity">Complexity</a></h3>
<p>Amortized constant time.</p>
</div>
<div class="section" id="comparisons-equal-example">
<h3><a class="subsection-title" href="#example" name="example">Example</a></h3>
<pre class="literal-block">
<a href="./assert-not.html" class="identifier">BOOST_MPL_ASSERT_NOT</a>(( <a href="./equal-to.html" class="identifier">equal_to</a>&lt; <a href="./int.html" class="identifier">int_</a>&lt;0&gt;, <a href="./int.html" class="identifier">int_</a>&lt;10&gt; &gt; ));
<a href="./assert-not.html" class="identifier">BOOST_MPL_ASSERT_NOT</a>(( <a href="./equal-to.html" class="identifier">equal_to</a>&lt; <a href="./long.html" class="identifier">long_</a>&lt;10&gt;, <a href="./int.html" class="identifier">int_</a>&lt;0&gt; &gt; ));
<a href="./assert.html" class="identifier">BOOST_MPL_ASSERT</a>(( <a href="./equal-to.html" class="identifier">equal_to</a>&lt; <a href="./long.html" class="identifier">long_</a>&lt;10&gt;, <a href="./int.html" class="identifier">int_</a>&lt;10&gt; > ));
</pre>
</div>
<div class="section" id="comparisons-equal-see-also">
<h3><a class="subsection-title" href="#see-also" name="see-also">See also</a></h3>
<p><a class="reference" href="./comparisons.html">Comparisons</a>, <a class="reference" href="./numeric-metafunction.html">Numeric Metafunction</a>, <a class="refentry reference" href="./numeric-cast.html"><tt class="refentry literal"><span class="pre">numeric_cast</span></tt></a>, <a class="refentry reference" href="./not-equal-to.html"><tt class="refentry literal"><span class="pre">not_equal_to</span></tt></a>, <a class="refentry reference" href="./less.html"><tt class="refentry literal"><span class="pre">less</span></tt></a></p>
<!-- modtime: November 10, 2004 04:42:40 +0000 -->
<!-- Metafunctions/Comparisons//not_equal_to |60 -->
</div>
</div>
<div class="footer-separator"></div>
<table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./greater-equal.html" class="navigation-link">Prev</a>&nbsp;<a href="./not-equal-to.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./greater-equal.html" class="navigation-link">Back</a>&nbsp;<a href="./not-equal-to.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./comparisons.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>
</tr></table></body>
</html>
+112
View File
@@ -0,0 +1,112 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.3.6: http://docutils.sourceforge.net/" />
<title>The MPL Reference Manual: equal</title>
<link rel="stylesheet" href="../style.css" type="text/css" />
</head>
<body class="docframe refmanual">
<table class="header"><tr class="header"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./max-element.html" class="navigation-link">Prev</a>&nbsp;<a href="./transformation-algorithms.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./max-element.html" class="navigation-link">Back</a>&nbsp;Along</span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./querying-algorithms.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>
<td class="header-group page-location"><a href="../refmanual.html" class="navigation-link">Front Page</a> / <a href="./algorithms.html" class="navigation-link">Algorithms</a> / <a href="./querying-algorithms.html" class="navigation-link">Querying Algorithms</a> / <a href="./equal.html" class="navigation-link">equal</a></td>
</tr></table><div class="header-separator"></div>
<div class="section" id="equal">
<h1><a class="toc-backref" href="./querying-algorithms.html#id412" name="equal">equal</a></h1>
<div class="section" id="equal-synopsis">
<h3><a class="subsection-title" href="#synopsis" name="synopsis">Synopsis</a></h3>
<pre class="literal-block">
template&lt;
typename Seq1
, typename Seq2
, typename Pred = is_same&lt;_1,_2&gt;
&gt;
struct <a href="./equal.html" class="identifier">equal</a>
{
typedef <em>unspecified</em> type;
};
</pre>
</div>
<div class="section" id="equal-description">
<h3><a class="subsection-title" href="#description" name="description">Description</a></h3>
<p>Returns a true-valued <a class="reference" href="./integral-constant.html">Integral Constant</a> if the two sequences <tt class="literal"><span class="pre">Seq1</span></tt>
and <tt class="literal"><span class="pre">Seq2</span></tt> are identical when compared element-by-element.</p>
</div>
<div class="section" id="equal-header">
<h3><a class="subsection-title" href="#header" name="header">Header</a></h3>
<pre class="literal-block">
#include &lt;<a href="../../../../boost/mpl/equal.hpp" class="header">boost/mpl/equal.hpp</a>&gt;
</pre>
</div>
<div class="section" id="equal-parameters">
<h3><a class="subsection-title" href="#parameters" name="parameters">Parameters</a></h3>
<table border="1" class="table">
<colgroup>
<col width="22%" />
<col width="36%" />
<col width="41%" />
</colgroup>
<thead valign="bottom">
<tr><th>Parameter</th>
<th>Requirement</th>
<th>Description</th>
</tr>
</thead>
<tbody valign="top">
<tr><td><tt class="literal"><span class="pre">Seq1</span></tt>, <tt class="literal"><span class="pre">Seq2</span></tt></td>
<td><a class="reference" href="./forward-sequence.html">Forward Sequence</a></td>
<td>Sequences to compare.</td>
</tr>
<tr><td><tt class="literal"><span class="pre">Pred</span></tt></td>
<td>Binary <a class="reference" href="./lambda-expression.html">Lambda Expression</a></td>
<td>A comparison criterion.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="equal-expression-semantics">
<h3><a class="subsection-title" href="#expression-semantics" name="expression-semantics">Expression semantics</a></h3>
<p>For any <a class="reference" href="./forward-sequence.html">Forward Sequence</a>s <tt class="literal"><span class="pre">s1</span></tt> and <tt class="literal"><span class="pre">s2</span></tt> and a binary <a class="reference" href="./lambda-expression.html">Lambda Expression</a> <tt class="literal"><span class="pre">pred</span></tt>:</p>
<pre class="literal-block">
typedef <a href="./equal.html" class="identifier">equal</a>&lt;s1,s2,pred&gt;::type c;
</pre>
<table class="field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Return type:</th><td class="field-body"><a class="reference" href="./integral-constant.html">Integral Constant</a></td>
</tr>
<tr class="field"><th class="field-name">Semantics:</th><td class="field-body"><p class="first"><tt class="literal"><span class="pre">c::value</span> <span class="pre">==</span> <span class="pre">true</span></tt> is and only if <tt class="literal"><span class="pre"><a href="./size.html" class="identifier">size</a>&lt;s1&gt;::value</span> <span class="pre">==</span> <span class="pre"><a href="./size.html" class="identifier">size</a>&lt;s2&gt;::value</span></tt>
and for every iterator <tt class="literal"><span class="pre">i</span></tt> in [<tt class="literal"><span class="pre"><a href="./begin.html" class="identifier">begin</a>&lt;s1&gt;::type</span></tt>, <tt class="literal"><span class="pre"><a href="./end.html" class="identifier">end</a>&lt;s1&gt;::type</span></tt>) <tt class="literal"><span class="pre"><a href="./deref.html" class="identifier">deref</a>&lt;i&gt;::type</span></tt> is identical to</p>
<pre class="last literal-block">
<a href="./advance.html" class="identifier">advance</a>&lt; <a href="./begin.html" class="identifier">begin</a>&lt;s2&gt;::type, <a href="./distance.html" class="identifier">distance</a>&lt; <a href="./begin.html" class="identifier">begin</a>&lt;s1&gt;::type,i &gt;::type &gt;::type
</pre>
</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="equal-complexity">
<h3><a class="subsection-title" href="#complexity" name="complexity">Complexity</a></h3>
<p>Linear. At most <tt class="literal"><span class="pre"><a href="./size.html" class="identifier">size</a>&lt;s1&gt;::value</span></tt> comparisons.</p>
</div>
<div class="section" id="equal-example">
<h3><a class="subsection-title" href="#example" name="example">Example</a></h3>
<pre class="literal-block">
typedef <a href="./vector.html" class="identifier">vector</a>&lt;char,int,unsigned,long,unsigned long&gt; s1;
typedef <a href="./list.html" class="identifier">list</a>&lt;char,int,unsigned,long,unsigned long&gt; s2;
<a href="./assert.html" class="identifier">BOOST_MPL_ASSERT</a>(( <a href="./equal.html" class="identifier">equal</a>&lt;s1,s2&gt; ));
</pre>
</div>
<div class="section" id="equal-see-also">
<h3><a class="subsection-title" href="#see-also" name="see-also">See also</a></h3>
<p><a class="reference" href="./querying-algorithms.html">Querying Algorithms</a>, <a class="refentry reference" href="./find.html"><tt class="refentry literal"><span class="pre">find</span></tt></a>, <a class="refentry reference" href="./find-if.html"><tt class="refentry literal"><span class="pre">find_if</span></tt></a></p>
<!-- modtime: November 10, 2004 04:42:44 +0000 -->
</div>
</div>
<div class="footer-separator"></div>
<table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./max-element.html" class="navigation-link">Prev</a>&nbsp;<a href="./transformation-algorithms.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./max-element.html" class="navigation-link">Back</a>&nbsp;Along</span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./querying-algorithms.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>
</tr></table></body>
</html>
+116
View File
@@ -0,0 +1,116 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.3.6: http://docutils.sourceforge.net/" />
<title>The MPL Reference Manual: erase_key</title>
<link rel="stylesheet" href="../style.css" type="text/css" />
</head>
<body class="docframe refmanual">
<table class="header"><tr class="header"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./erase.html" class="navigation-link">Prev</a>&nbsp;<a href="./front.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./erase.html" class="navigation-link">Back</a>&nbsp;<a href="./front.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./intrinsic-metafunctions.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>
<td class="header-group page-location"><a href="../refmanual.html" class="navigation-link">Front Page</a> / <a href="./sequences.html" class="navigation-link">Sequences</a> / <a href="./intrinsic-metafunctions.html" class="navigation-link">Intrinsic Metafunctions</a> / <a href="./erase-key.html" class="navigation-link">erase_key</a></td>
</tr></table><div class="header-separator"></div>
<div class="section" id="erase-key">
<h1><a class="toc-backref" href="./intrinsic-metafunctions.html#id361" name="erase-key">erase_key</a></h1>
<div class="section" id="intrinsic-erase-synopsis">
<h3><a class="subsection-title" href="#synopsis" name="synopsis">Synopsis</a></h3>
<pre class="literal-block">
template&lt;
typename AssocSeq
, typename Key
&gt;
struct <a href="./erase-key.html" class="identifier">erase_key</a>
{
typedef <em>unspecified</em> type;
};
</pre>
</div>
<div class="section" id="intrinsic-erase-description">
<h3><a class="subsection-title" href="#description" name="description">Description</a></h3>
<p>Erases elements associated with the key <tt class="literal"><span class="pre">Key</span></tt> in the <a class="reference" href="./extensible-associative.html">Extensible Associative Sequence</a>
<tt class="literal"><span class="pre">AssocSeq</span></tt> .</p>
</div>
<div class="section" id="intrinsic-erase-header">
<h3><a class="subsection-title" href="#header" name="header">Header</a></h3>
<pre class="literal-block">
#include &lt;<a href="../../../../boost/mpl/erase_key.hpp" class="header">boost/mpl/erase_key.hpp</a>&gt;
</pre>
</div>
<div class="section" id="intrinsic-erase-model-of">
<h3><a class="subsection-title" href="#model-of" name="model-of">Model of</a></h3>
<p><a class="reference" href="./tag-dispatched.html">Tag Dispatched Metafunction</a></p>
</div>
<div class="section" id="intrinsic-erase-parameters">
<h3><a class="subsection-title" href="#parameters" name="parameters">Parameters</a></h3>
<table border="1" class="table">
<colgroup>
<col width="15%" />
<col width="36%" />
<col width="48%" />
</colgroup>
<thead valign="bottom">
<tr><th>Parameter</th>
<th>Requirement</th>
<th>Description</th>
</tr>
</thead>
<tbody valign="top">
<tr><td><tt class="literal"><span class="pre">AssocSeq</span></tt></td>
<td><a class="reference" href="./extensible-associative.html">Extensible Associative Sequence</a></td>
<td>A sequence to erase elements from.</td>
</tr>
<tr><td><tt class="literal"><span class="pre">Key</span></tt></td>
<td>Any type</td>
<td>A key for the elements to be removed.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="intrinsic-erase-expression-semantics">
<h3><a class="subsection-title" href="#expression-semantics" name="expression-semantics">Expression semantics</a></h3>
<p>For any <a class="reference" href="./extensible-associative.html">Extensible Associative Sequence</a> <tt class="literal"><span class="pre">s</span></tt>, and arbitrary type <tt class="literal"><span class="pre">key</span></tt>:</p>
<pre class="literal-block">
typedef <a href="./erase-key.html" class="identifier">erase_key</a>&lt;s,key&gt;::type r;
</pre>
<table class="field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Return type:</th><td class="field-body"><a class="reference" href="./extensible-associative.html">Extensible Associative Sequence</a>.</td>
</tr>
<tr class="field"><th class="field-name">Semantics:</th><td class="field-body"><tt class="literal"><span class="pre">r</span></tt> is <a class="reference" href="./terminology.html#concept-identical">concept-identical</a> and equivalent to <tt class="literal"><span class="pre">s</span></tt> except that
<tt class="literal"><span class="pre"><a href="./has-key.html" class="identifier">has_key</a>&lt;r,k&gt;::value</span> <span class="pre">==</span> <span class="pre">false</span></tt>.</td>
</tr>
<tr class="field"><th class="field-name">Postcondition:</th><td class="field-body"><tt class="literal"><span class="pre"><a href="./size.html" class="identifier">size</a>&lt;r&gt;::value</span> <span class="pre">==</span> <span class="pre"><a href="./size.html" class="identifier">size</a>&lt;s&gt;::value</span> <span class="pre">-</span> <span class="pre">1</span></tt>.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="intrinsic-erase-complexity">
<h3><a class="subsection-title" href="#complexity" name="complexity">Complexity</a></h3>
<p>Amortized constant time.</p>
</div>
<div class="section" id="intrinsic-erase-example">
<h3><a class="subsection-title" href="#example" name="example">Example</a></h3>
<pre class="literal-block">
typedef <a href="./map.html" class="identifier">map</a>&lt; <a href="./pair.html" class="identifier">pair</a>&lt;int,unsigned&gt;, <a href="./pair.html" class="identifier">pair</a>&lt;char,long&gt; &gt; m;
typedef <a href="./erase-key.html" class="identifier">erase_key</a>&lt;m,char&gt;::type m1;
<a href="./assert-relation.html" class="identifier">BOOST_MPL_ASSERT_RELATION</a>( <a href="./size.html" class="identifier">size</a>&lt;m1&gt;::type::value, ==, 1 );
<a href="./assert.html" class="identifier">BOOST_MPL_ASSERT</a>(( is_same&lt; <a href="./at.html" class="identifier">at</a>&lt;m1,char&gt;::type,<a href="./void.html" class="identifier">void_</a> &gt; ));
<a href="./assert.html" class="identifier">BOOST_MPL_ASSERT</a>(( is_same&lt; <a href="./at.html" class="identifier">at</a>&lt;m1,int&gt;::type,unsigned > ));
</pre>
</div>
<div class="section" id="intrinsic-erase-see-also">
<h3><a class="subsection-title" href="#see-also" name="see-also">See also</a></h3>
<p><a class="reference" href="./extensible-associative.html">Extensible Associative Sequence</a>, <a class="refentry reference" href="./erase.html"><tt class="refentry literal"><span class="pre">erase</span></tt></a>, <a class="refentry reference" href="./has-key.html"><tt class="refentry literal"><span class="pre">has_key</span></tt></a>, <a class="refentry reference" href="./insert.html"><tt class="refentry literal"><span class="pre">insert</span></tt></a></p>
<!-- modtime: November 10, 2004 04:42:33 +0000 -->
<!-- Sequences/Intrinsic Metafunctions//front -->
</div>
</div>
<div class="footer-separator"></div>
<table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./erase.html" class="navigation-link">Prev</a>&nbsp;<a href="./front.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./erase.html" class="navigation-link">Back</a>&nbsp;<a href="./front.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./intrinsic-metafunctions.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>
</tr></table></body>
</html>
+193
View File
@@ -0,0 +1,193 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.3.6: http://docutils.sourceforge.net/" />
<title>The MPL Reference Manual: erase</title>
<link rel="stylesheet" href="../style.css" type="text/css" />
</head>
<body class="docframe refmanual">
<table class="header"><tr class="header"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./end.html" class="navigation-link">Prev</a>&nbsp;<a href="./erase-key.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./end.html" class="navigation-link">Back</a>&nbsp;<a href="./erase-key.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./intrinsic-metafunctions.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>
<td class="header-group page-location"><a href="../refmanual.html" class="navigation-link">Front Page</a> / <a href="./sequences.html" class="navigation-link">Sequences</a> / <a href="./intrinsic-metafunctions.html" class="navigation-link">Intrinsic Metafunctions</a> / <a href="./erase.html" class="navigation-link">erase</a></td>
</tr></table><div class="header-separator"></div>
<div class="section" id="erase">
<h1><a class="toc-backref" href="./intrinsic-metafunctions.html#id360" name="erase">erase</a></h1>
<div class="section" id="erase-synopsis">
<h3><a class="subsection-title" href="#synopsis" name="synopsis">Synopsis</a></h3>
<pre class="literal-block">
template&lt;
typename Sequence
, typename First
, typename Last = <em>unspecified</em>
&gt;
struct <a href="./erase.html" class="identifier">erase</a>
{
typedef <em>unspecified</em> type;
};
</pre>
</div>
<div class="section" id="erase-description">
<h3><a class="subsection-title" href="#description" name="description">Description</a></h3>
<p><tt class="literal"><span class="pre"><a href="./erase.html" class="identifier">erase</a></span></tt> performs a removal of one or more adjacent elements in the sequence
starting from an arbitrary position.</p>
</div>
<div class="section" id="erase-header">
<h3><a class="subsection-title" href="#header" name="header">Header</a></h3>
<pre class="literal-block">
#include &lt;<a href="../../../../boost/mpl/erase.hpp" class="header">boost/mpl/erase.hpp</a>&gt;
</pre>
</div>
<div class="section" id="erase-model-of">
<h3><a class="subsection-title" href="#model-of" name="model-of">Model of</a></h3>
<p><a class="reference" href="./tag-dispatched.html">Tag Dispatched Metafunction</a></p>
</div>
<div class="section" id="erase-parameters">
<h3><a class="subsection-title" href="#parameters" name="parameters">Parameters</a></h3>
<table border="1" class="table">
<colgroup>
<col width="15%" />
<col width="36%" />
<col width="48%" />
</colgroup>
<thead valign="bottom">
<tr><th>Parameter</th>
<th>Requirement</th>
<th>Description</th>
</tr>
</thead>
<tbody valign="top">
<tr><td><tt class="literal"><span class="pre">Sequence</span></tt></td>
<td><a class="reference" href="./extensible-sequence.html">Extensible Sequence</a> or
<a class="reference" href="./extensible-associative.html">Extensible Associative Sequence</a></td>
<td>A sequence to erase from.</td>
</tr>
<tr><td><tt class="literal"><span class="pre">First</span></tt></td>
<td><a class="reference" href="./forward-iterator.html">Forward Iterator</a></td>
<td>An iterator to the beginning of the range to
be erased.</td>
</tr>
<tr><td><tt class="literal"><span class="pre">Last</span></tt></td>
<td><a class="reference" href="./forward-iterator.html">Forward Iterator</a></td>
<td>An iterator past-the-end of the range to be
erased.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="erase-expression-semantics">
<h3><a class="subsection-title" href="#expression-semantics" name="expression-semantics">Expression semantics</a></h3>
<div class="expression-semantics compound">
<p class="compound-first">For any <a class="reference" href="./extensible-sequence.html">Extensible Sequence</a> <tt class="literal"><span class="pre">s</span></tt>, and iterators <tt class="literal"><span class="pre">pos</span></tt>, <tt class="literal"><span class="pre">first</span></tt> and <tt class="literal"><span class="pre">last</span></tt> into <tt class="literal"><span class="pre">s</span></tt>:</p>
<pre class="compound-middle literal-block">
typedef <a href="./erase.html" class="identifier">erase</a>&lt;s,first,last&gt;::type r;
</pre>
<table class="compound-middle field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Return type:</th><td class="field-body"><a class="reference" href="./extensible-sequence.html">Extensible Sequence</a>.</td>
</tr>
<tr class="field"><th class="field-name">Precondition:</th><td class="field-body"><tt class="literal"><span class="pre">[first,last)</span></tt> is a valid range in <tt class="literal"><span class="pre">s</span></tt>.</td>
</tr>
<tr class="field"><th class="field-name">Semantics:</th><td class="field-body"><tt class="literal"><span class="pre">r</span></tt> is a new sequence, <a class="reference" href="./terminology.html#concept-identical">concept-identical</a> to <tt class="literal"><span class="pre">s</span></tt>, of the following elements:
[<tt class="literal"><span class="pre"><a href="./begin.html" class="identifier">begin</a>&lt;s&gt;::type</span></tt>, <tt class="literal"><span class="pre">pos</span></tt>), [<tt class="literal"><span class="pre">last</span></tt>, <tt class="literal"><span class="pre"><a href="./end.html" class="identifier">end</a>&lt;s&gt;::type</span></tt>).</td>
</tr>
<tr class="field"><th class="field-name">Postcondition:</th><td class="field-body"><p class="first">The relative order of the elements in <tt class="literal"><span class="pre">r</span></tt> is the same as in <tt class="literal"><span class="pre">s</span></tt>;</p>
<pre class="last literal-block">
<a href="./size.html" class="identifier">size</a>&lt;r&gt;::value == <a href="./size.html" class="identifier">size</a>&lt;s&gt;::value - <a href="./distance.html" class="identifier">distance</a>&lt;first,last&gt;::value
</pre>
</td>
</tr>
</tbody>
</table>
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<pre class="compound-middle literal-block">
typedef <a href="./erase.html" class="identifier">erase</a>&lt;s,pos&gt;::type r;
</pre>
<table class="compound-last field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Return type:</th><td class="field-body"><a class="reference" href="./extensible-sequence.html">Extensible Sequence</a>.</td>
</tr>
<tr class="field"><th class="field-name">Precondition:</th><td class="field-body"><tt class="literal"><span class="pre">pos</span></tt> is a dereferenceable iterator in <tt class="literal"><span class="pre">s</span></tt>.</td>
</tr>
<tr class="field"><th class="field-name">Semantics:</th><td class="field-body"><p class="first">Equivalent to</p>
<pre class="last literal-block">
typedef <a href="./erase.html" class="identifier">erase</a>&lt; s,pos,<a href="./next.html" class="identifier">next</a>&lt;pos&gt;::type &gt;::type r;
</pre>
</td>
</tr>
</tbody>
</table>
</div>
<div class="expression-semantics compound">
<p class="compound-first">For any <a class="reference" href="./extensible-associative.html">Extensible Associative Sequence</a> <tt class="literal"><span class="pre">s</span></tt>, and iterator <tt class="literal"><span class="pre">pos</span></tt> into <tt class="literal"><span class="pre">s</span></tt>:</p>
<pre class="compound-middle literal-block">
typedef <a href="./erase.html" class="identifier">erase</a>&lt;s,pos&gt;::type r;
</pre>
<table class="compound-last field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Return type:</th><td class="field-body"><a class="reference" href="./extensible-sequence.html">Extensible Sequence</a>.</td>
</tr>
<tr class="field"><th class="field-name">Precondition:</th><td class="field-body"><tt class="literal"><span class="pre">pos</span></tt> is a dereferenceable iterator to <tt class="literal"><span class="pre">s</span></tt>.</td>
</tr>
<tr class="field"><th class="field-name">Semantics:</th><td class="field-body">Erases the element at a specific position <tt class="literal"><span class="pre">pos</span></tt>; equivalent to
<tt class="literal"><span class="pre"><a href="./erase-key.html" class="identifier">erase_key</a>&lt;s,</span> <span class="pre"><a href="./deref.html" class="identifier">deref</a>&lt;pos&gt;::type</span> <span class="pre">&gt;::type</span></tt>.</td>
</tr>
<tr class="field"><th class="field-name">Postcondition:</th><td class="field-body"><tt class="literal"><span class="pre"><a href="./size.html" class="identifier">size</a>&lt;r&gt;::value</span> <span class="pre">==</span> <span class="pre"><a href="./size.html" class="identifier">size</a>&lt;s&gt;::value</span> <span class="pre">-</span> <span class="pre">1</span></tt>.</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section" id="erase-complexity">
<h3><a class="subsection-title" href="#complexity" name="complexity">Complexity</a></h3>
<table border="1" class="table">
<colgroup>
<col width="45%" />
<col width="55%" />
</colgroup>
<thead valign="bottom">
<tr><th>Sequence archetype</th>
<th>Complexity (the range form)</th>
</tr>
</thead>
<tbody valign="top">
<tr><td><a class="reference" href="./extensible-associative.html">Extensible Associative Sequence</a></td>
<td>Amortized constant time.</td>
</tr>
<tr><td><a class="reference" href="./extensible-sequence.html">Extensible Sequence</a></td>
<td>Quadratic in the worst case, linear at best.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="erase-example">
<h3><a class="subsection-title" href="#example" name="example">Example</a></h3>
<pre class="literal-block">
typedef <a href="./vector-c.html" class="identifier">vector_c</a>&lt;int,1,0,5,1,7,5,0,5&gt; values;
typedef <a href="./find.html" class="identifier">find</a>&lt; values, <a href="./integral-c.html" class="identifier">integral_c</a>&lt;int,7&gt; &gt;::type pos;
typedef <a href="./erase.html" class="identifier">erase</a>&lt;values,pos&gt;::type result;
<a href="./assert-relation.html" class="identifier">BOOST_MPL_ASSERT_RELATION</a>( <a href="./size.html" class="identifier">size</a>&lt;result&gt;::value, ==, 7 );
typedef <a href="./find.html" class="identifier">find</a>&lt;result, <a href="./integral-c.html" class="identifier">integral_c</a>&lt;int,7&gt; &gt;::type iter;
<a href="./assert.html" class="identifier">BOOST_MPL_ASSERT</a>(( is_same&lt; iter, <a href="./end.html" class="identifier">end</a>&lt;result&gt;::type > ));
</pre>
</div>
<div class="section" id="erase-see-also">
<h3><a class="subsection-title" href="#see-also" name="see-also">See also</a></h3>
<p><a class="reference" href="./extensible-sequence.html">Extensible Sequence</a>, <a class="reference" href="./extensible-associative.html">Extensible Associative Sequence</a>, <a class="refentry reference" href="./erase-key.html"><tt class="refentry literal"><span class="pre">erase_key</span></tt></a>, <a class="refentry reference" href="./pop-front.html"><tt class="refentry literal"><span class="pre">pop_front</span></tt></a>, <a class="refentry reference" href="./pop-back.html"><tt class="refentry literal"><span class="pre">pop_back</span></tt></a>, <a class="refentry reference" href="./insert.html"><tt class="refentry literal"><span class="pre">insert</span></tt></a></p>
<!-- modtime: November 10, 2004 04:42:36 +0000 -->
<!-- Sequences/Intrinsic Metafunctions//erase_key -->
</div>
</div>
<div class="footer-separator"></div>
<table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./end.html" class="navigation-link">Prev</a>&nbsp;<a href="./erase-key.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./end.html" class="navigation-link">Back</a>&nbsp;<a href="./erase-key.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./intrinsic-metafunctions.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>
</tr></table></body>
</html>
+105
View File
@@ -0,0 +1,105 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.3.6: http://docutils.sourceforge.net/" />
<title>The MPL Reference Manual: eval_if_c</title>
<link rel="stylesheet" href="../style.css" type="text/css" />
</head>
<body class="docframe refmanual">
<table class="header"><tr class="header"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./eval-if.html" class="navigation-link">Prev</a>&nbsp;<a href="./invocation.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./eval-if.html" class="navigation-link">Back</a>&nbsp;Along</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>
<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="./eval-if-c.html" class="navigation-link">eval_if_c</a></td>
</tr></table><div class="header-separator"></div>
<div class="section" id="eval-if-c">
<h1><a class="toc-backref" href="./type-selection.html#id449" name="eval-if-c">eval_if_c</a></h1>
<div class="section" id="type-eval-synopsis">
<h3><a class="subsection-title" href="#synopsis" name="synopsis">Synopsis</a></h3>
<pre class="literal-block">
template&lt;
bool c
, typename F1
, typename F2
&gt;
struct <a href="./eval-if-c.html" class="identifier">eval_if_c</a>
{
typedef <em>unspecified</em> type;
};
</pre>
</div>
<div class="section" id="type-eval-description">
<h3><a class="subsection-title" href="#description" name="description">Description</a></h3>
<p>Evaluates one of its two <a class="reference" href="./metafunction.html#nullary-metafunction">nullary-metafunction</a> arguments, <tt class="literal"><span class="pre">F1</span></tt> or <tt class="literal"><span class="pre">F2</span></tt>, depending
on the value of integral constant <tt class="literal"><span class="pre">c</span></tt>. <tt class="literal"><span class="pre"><a href="./eval-if-c.html" class="identifier">eval_if_c</a>&lt;c,f1,f2&gt;::type</span></tt> is a shorcut
notation for <tt class="literal"><span class="pre"><a href="./eval-if.html" class="identifier">eval_if</a>&lt;</span> <span class="pre"><a href="./bool.html" class="identifier">bool_</a>&lt;c&gt;,f1,f2</span> <span class="pre">&gt;::type</span></tt>.</p>
</div>
<div class="section" id="type-eval-header">
<h3><a class="subsection-title" href="#header" name="header">Header</a></h3>
<pre class="literal-block">
#include &lt;<a href="../../../../boost/mpl/eval_if.hpp" class="header">boost/mpl/eval_if.hpp</a>&gt;
</pre>
</div>
<div class="section" id="type-eval-parameters">
<h3><a class="subsection-title" href="#parameters" name="parameters">Parameters</a></h3>
<table border="1" class="table">
<colgroup>
<col width="15%" />
<col width="36%" />
<col width="48%" />
</colgroup>
<thead valign="bottom">
<tr><th>Parameter</th>
<th>Requirement</th>
<th>Description</th>
</tr>
</thead>
<tbody valign="top">
<tr><td><tt class="literal"><span class="pre">c</span></tt></td>
<td>An integral constant</td>
<td>An evaluation condition.</td>
</tr>
<tr><td><tt class="literal"><span class="pre">F1</span></tt>, <tt class="literal"><span class="pre">F2</span></tt></td>
<td>Nullary <a class="reference" href="./metafunction.html">Metafunction</a></td>
<td>Metafunctions to select for evaluation from.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="type-eval-expression-semantics">
<h3><a class="subsection-title" href="#expression-semantics" name="expression-semantics">Expression semantics</a></h3>
<p>For any integral constant <tt class="literal"><span class="pre">c</span></tt> and nullary <a class="reference" href="./metafunction.html">Metafunction</a>s <tt class="literal"><span class="pre">f1</span></tt>, <tt class="literal"><span class="pre">f2</span></tt>:</p>
<pre class="literal-block">
typedef <a href="./eval-if-c.html" class="identifier">eval_if_c</a>&lt;c,f1,f2&gt;::type t;
</pre>
<table class="field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Return type:</th><td class="field-body">Any type.</td>
</tr>
<tr class="field"><th class="field-name">Semantics:</th><td class="field-body">Equivalent to <tt class="literal"><span class="pre">typedef</span> <span class="pre"><a href="./eval-if.html" class="identifier">eval_if</a>&lt;</span> <span class="pre"><a href="./bool.html" class="identifier">bool_</a>&lt;c&gt;,f1,f2</span> <span class="pre">&gt;::type</span> <span class="pre">t;</span></tt></td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="type-eval-example">
<h3><a class="subsection-title" href="#example" name="example">Example</a></h3>
<pre class="literal-block">
typedef <a href="./eval-if-c.html" class="identifier">eval_if_c</a>&lt; true, <a href="./identity.html" class="identifier">identity</a>&lt;char&gt;, <a href="./identity.html" class="identifier">identity</a>&lt;long&gt; &gt;::type t1;
typedef <a href="./eval-if-c.html" class="identifier">eval_if_c</a>&lt; false, <a href="./identity.html" class="identifier">identity</a>&lt;char&gt;, <a href="./identity.html" class="identifier">identity</a>&lt;long&gt; &gt;::type t2;
<a href="./assert.html" class="identifier">BOOST_MPL_ASSERT</a>(( is_same&lt;t1,char&gt; ));
<a href="./assert.html" class="identifier">BOOST_MPL_ASSERT</a>(( is_same&lt;t2,long&gt; ));
</pre>
</div>
<div class="section" id="type-eval-see-also">
<h3><a class="subsection-title" href="#see-also" name="see-also">See also</a></h3>
<p><a class="reference" href="./metafunctions.html">Metafunctions</a>, <a class="reference" href="./integral-constant.html">Integral Constant</a>, <a class="refentry reference" href="./eval-if.html"><tt class="refentry literal"><span class="pre">eval_if</span></tt></a>, <a class="refentry reference" href="./if.html"><tt class="refentry literal"><span class="pre">if_</span></tt></a>, <a class="refentry reference" href="./bool.html"><tt class="refentry literal"><span class="pre">bool_</span></tt></a></p>
<!-- modtime: November 10, 2004 04:42:25 +0000 -->
</div>
</div>
<div class="footer-separator"></div>
<table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./eval-if.html" class="navigation-link">Prev</a>&nbsp;<a href="./invocation.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./eval-if.html" class="navigation-link">Back</a>&nbsp;Along</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>
</tr></table></body>
</html>
+106
View File
@@ -0,0 +1,106 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.3.6: http://docutils.sourceforge.net/" />
<title>The MPL Reference Manual: eval_if</title>
<link rel="stylesheet" href="../style.css" type="text/css" />
</head>
<body class="docframe refmanual">
<table class="header"><tr class="header"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./if-c.html" class="navigation-link">Prev</a>&nbsp;<a href="./eval-if-c.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./if-c.html" class="navigation-link">Back</a>&nbsp;<a href="./eval-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>
<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="./eval-if.html" class="navigation-link">eval_if</a></td>
</tr></table><div class="header-separator"></div>
<div class="section" id="eval-if">
<h1><a class="toc-backref" href="./type-selection.html#id448" name="eval-if">eval_if</a></h1>
<div class="section" id="eval-synopsis">
<h3><a class="subsection-title" href="#synopsis" name="synopsis">Synopsis</a></h3>
<pre class="literal-block">
template&lt;
typename C
, typename F1
, typename F2
&gt;
struct <a href="./eval-if.html" class="identifier">eval_if</a>
{
typedef <em>unspecified</em> type;
};
</pre>
</div>
<div class="section" id="eval-description">
<h3><a class="subsection-title" href="#description" name="description">Description</a></h3>
<p>Evaluates one of its two <a class="reference" href="./metafunction.html#nullary-metafunction">nullary-metafunction</a> arguments, <tt class="literal"><span class="pre">F1</span></tt> or <tt class="literal"><span class="pre">F2</span></tt>, depending
on the value <tt class="literal"><span class="pre">C</span></tt>.</p>
</div>
<div class="section" id="eval-header">
<h3><a class="subsection-title" href="#header" name="header">Header</a></h3>
<pre class="literal-block">
#include &lt;<a href="../../../../boost/mpl/eval_if.hpp" class="header">boost/mpl/eval_if.hpp</a>&gt;
</pre>
</div>
<div class="section" id="eval-parameters">
<h3><a class="subsection-title" href="#parameters" name="parameters">Parameters</a></h3>
<table border="1" class="table">
<colgroup>
<col width="15%" />
<col width="36%" />
<col width="48%" />
</colgroup>
<thead valign="bottom">
<tr><th>Parameter</th>
<th>Requirement</th>
<th>Description</th>
</tr>
</thead>
<tbody valign="top">
<tr><td><tt class="literal"><span class="pre">C</span></tt></td>
<td><a class="reference" href="./integral-constant.html">Integral Constant</a></td>
<td>An evaluation condition.</td>
</tr>
<tr><td><tt class="literal"><span class="pre">F1</span></tt>, <tt class="literal"><span class="pre">F2</span></tt></td>
<td>Nullary <a class="reference" href="./metafunction.html">Metafunction</a></td>
<td>Metafunctions to select for evaluation from.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="eval-expression-semantics">
<h3><a class="subsection-title" href="#expression-semantics" name="expression-semantics">Expression semantics</a></h3>
<p>For any <a class="reference" href="./integral-constant.html">Integral Constant</a> <tt class="literal"><span class="pre">c</span></tt> and nullary <a class="reference" href="./metafunction.html">Metafunction</a>s <tt class="literal"><span class="pre">f1</span></tt>, <tt class="literal"><span class="pre">f2</span></tt>:</p>
<pre class="literal-block">
typedef <a href="./eval-if.html" class="identifier">eval_if</a>&lt;c,f1,f2&gt;::type t;
</pre>
<table class="field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Return type:</th><td class="field-body">Any type.</td>
</tr>
<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">f1::type</span></tt>; otherwise <tt class="literal"><span class="pre">t</span></tt> is
identical to <tt class="literal"><span class="pre">f2::type</span></tt>.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="eval-example">
<h3><a class="subsection-title" href="#example" name="example">Example</a></h3>
<pre class="literal-block">
typedef <a href="./eval-if.html" class="identifier">eval_if</a>&lt; true_, <a href="./identity.html" class="identifier">identity</a>&lt;char&gt;, <a href="./identity.html" class="identifier">identity</a>&lt;long&gt; &gt;::type t1;
typedef <a href="./eval-if.html" class="identifier">eval_if</a>&lt; false_, <a href="./identity.html" class="identifier">identity</a>&lt;char&gt;, <a href="./identity.html" class="identifier">identity</a>&lt;long&gt; &gt;::type t2;
<a href="./assert.html" class="identifier">BOOST_MPL_ASSERT</a>(( is_same&lt;t1,char&gt; ));
<a href="./assert.html" class="identifier">BOOST_MPL_ASSERT</a>(( is_same&lt;t2,long&gt; ));
</pre>
</div>
<div class="section" id="eval-see-also">
<h3><a class="subsection-title" href="#see-also" name="see-also">See also</a></h3>
<p><a class="reference" href="./metafunctions.html">Metafunctions</a>, <a class="reference" href="./integral-constant.html">Integral Constant</a>, <a class="refentry reference" href="./eval-if-c.html"><tt class="refentry literal"><span class="pre">eval_if_c</span></tt></a>, <a class="refentry reference" href="./if.html"><tt class="refentry literal"><span class="pre">if_</span></tt></a></p>
<!-- modtime: November 10, 2004 04:42:29 +0000 -->
<!-- Metafunctions/Type Selection//eval_if_c |40 -->
</div>
</div>
<div class="footer-separator"></div>
<table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./if-c.html" class="navigation-link">Prev</a>&nbsp;<a href="./eval-if-c.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./if-c.html" class="navigation-link">Back</a>&nbsp;<a href="./eval-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>
</tr></table></body>
</html>
Loaded 100 of 306 files, more files were not shown because too many files have changed in this diff. Show more