mirror of
https://github.com/boostorg/parameter.git
synced 2026-01-19 04:22:13 +00:00
This commit was manufactured by cvs2svn to create branch
'thread_rewrite'. [SVN r30953]
This commit is contained in:
@@ -1,21 +0,0 @@
|
||||
import docutils ;
|
||||
|
||||
import path ;
|
||||
sources = [ path.glob . : *.rst ] ;
|
||||
bases = $(sources:S=) ;
|
||||
|
||||
# This is a path relative to the html/ subdirectory where the
|
||||
# generated output will eventually be moved.
|
||||
stylesheet = "--stylesheet=rst.css" ;
|
||||
|
||||
for local b in $(bases)
|
||||
{
|
||||
html $(b) : $(b).rst :
|
||||
|
||||
#
|
||||
<docutils-html>"-gdt --traceback --trim-footnote-reference-space --footnote-references=superscript "$(stylesheet)
|
||||
;
|
||||
}
|
||||
|
||||
alias htmls : $(bases) ;
|
||||
stage html : $(bases) ;
|
||||
1198
doc/html/index.html
1198
doc/html/index.html
File diff suppressed because it is too large
Load Diff
@@ -1,785 +0,0 @@
|
||||
<?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.8: http://docutils.sourceforge.net/" />
|
||||
<title>The Boost Parameter Library Reference Documentation</title>
|
||||
<link rel="stylesheet" href="rst.css" type="text/css" />
|
||||
</head>
|
||||
<body>
|
||||
<div class="document" id="the-boost-parameter-library-reference-documentation">
|
||||
<h1 class="title">The Boost Parameter Library Reference Documentation</h1>
|
||||
<p><a class="reference" href="../../../../index.htm"><img alt="Boost" src="../../../../boost.png" /></a></p>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field"><th class="field-name">Authors:</th><td class="field-body">David Abrahams, Daniel Wallin</td>
|
||||
</tr>
|
||||
<tr class="field"><th class="field-name">Contact:</th><td class="field-body"><a class="reference" href="mailto:dave@boost-consulting.com">dave@boost-consulting.com</a>, <a class="reference" href="mailto:dalwan01@student.umu.se">dalwan01@student.umu.se</a></td>
|
||||
</tr>
|
||||
<tr class="field"><th class="field-name">organization:</th><td class="field-body"><a class="reference" href="http://www.boost-consulting.com">Boost Consulting</a></td>
|
||||
</tr>
|
||||
<tr class="field"><th class="field-name">date:</th><td class="field-body">$Date: 2005/07/17 19:53:01 $</td>
|
||||
</tr>
|
||||
<tr class="field"><th class="field-name">copyright:</th><td class="field-body">Copyright David Abrahams, Daniel Wallin
|
||||
2005. Distributed under the Boost Software License,
|
||||
Version 1.0. (See accompanying file LICENSE_1_0.txt
|
||||
or copy at <a class="reference" href="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</a>)</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<hr class="docutils" />
|
||||
<div class="contents topic" id="contents">
|
||||
<p class="topic-title first"><a name="contents">Contents</a></p>
|
||||
<ul class="auto-toc simple">
|
||||
<li><a class="reference" href="#preliminaries" id="id23" name="id23">1 Preliminaries</a><ul class="auto-toc">
|
||||
<li><a class="reference" href="#namespaces" id="id24" name="id24">1.1 Namespaces</a></li>
|
||||
<li><a class="reference" href="#exceptions" id="id25" name="id25">1.2 Exceptions</a></li>
|
||||
<li><a class="reference" href="#thread-safety" id="id26" name="id26">1.3 Thread Safety</a></li>
|
||||
<li><a class="reference" href="#typography" id="id27" name="id27">1.4 Typography</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a class="reference" href="#terminology" id="id28" name="id28">2 Terminology</a></li>
|
||||
<li><a class="reference" href="#concepts" id="id29" name="id29">3 Concepts</a><ul class="auto-toc">
|
||||
<li><a class="reference" href="#argumentpack" id="id30" name="id30">3.1 <span class="concept">ArgumentPack</span></a></li>
|
||||
<li><a class="reference" href="#id4" id="id31" name="id31">3.2 <span class="concept">ParameterSpec</span></a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a class="reference" href="#class-templates" id="id32" name="id32">4 Class Templates</a><ul class="auto-toc">
|
||||
<li><a class="reference" href="#id6" id="id33" name="id33">4.1 <tt class="docutils literal"><span class="pre">keyword</span></tt></a></li>
|
||||
<li><a class="reference" href="#parameters" id="id34" name="id34">4.2 <tt class="docutils literal"><span class="pre">parameters</span></tt></a></li>
|
||||
<li><a class="reference" href="#optional-required" id="id35" name="id35">4.3 <tt class="docutils literal"><span class="pre">optional</span></tt>, <tt class="docutils literal"><span class="pre">required</span></tt></a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a class="reference" href="#metafunctions" id="id36" name="id36">5 Metafunctions</a><ul class="auto-toc">
|
||||
<li><a class="reference" href="#binding" id="id37" name="id37">5.1 <tt class="docutils literal"><span class="pre">binding</span></tt></a></li>
|
||||
<li><a class="reference" href="#lazy-binding" id="id38" name="id38">5.2 <tt class="docutils literal"><span class="pre">lazy_binding</span></tt></a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a class="reference" href="#code-generation-macros" id="id39" name="id39">6 Code Generation Macros</a><ul class="auto-toc">
|
||||
<li><a class="reference" href="#boost-parameter-fun-r-n-l-h-p" id="id40" name="id40">6.1 <tt class="docutils literal"><span class="pre">BOOST_PARAMETER_FUN(r,n,l,h,p)</span></tt></a></li>
|
||||
<li><a class="reference" href="#boost-parameter-keyword-n-k" id="id41" name="id41">6.2 <tt class="docutils literal"><span class="pre">BOOST_PARAMETER_KEYWORD(n,k)</span></tt></a></li>
|
||||
<li><a class="reference" href="#boost-parameter-match-p-a-x" id="id42" name="id42">6.3 <tt class="docutils literal"><span class="pre">BOOST_PARAMETER_MATCH(p,a,x)</span></tt></a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a class="reference" href="#configuration-macros" id="id43" name="id43">7 Configuration Macros</a><ul class="auto-toc">
|
||||
<li><a class="reference" href="#boost-parameter-max-arity" id="id44" name="id44">7.1 <tt class="docutils literal"><span class="pre">BOOST_PARAMETER_MAX_ARITY</span></tt></a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a class="reference" href="#tutorial" id="id45" name="id45">8 Tutorial</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<hr class="docutils" />
|
||||
<div class="section" id="preliminaries">
|
||||
<h1><a class="toc-backref" href="#id23" name="preliminaries">1 Preliminaries</a></h1>
|
||||
<p>This section covers some basic information you'll need to know in
|
||||
order to understand this reference</p>
|
||||
<div class="section" id="namespaces">
|
||||
<h2><a class="toc-backref" href="#id24" name="namespaces">1.1 Namespaces</a></h2>
|
||||
<p>In this document, all unqualified identifiers should be assumed to
|
||||
be defined in namespace <tt class="docutils literal"><span class="pre">boost::parameter</span></tt> unless otherwise
|
||||
specified.</p>
|
||||
</div>
|
||||
<div class="section" id="exceptions">
|
||||
<h2><a class="toc-backref" href="#id25" name="exceptions">1.2 Exceptions</a></h2>
|
||||
<p>No operation described in this document
|
||||
throws an exception unless otherwise specified.</p>
|
||||
</div>
|
||||
<div class="section" id="thread-safety">
|
||||
<h2><a class="toc-backref" href="#id26" name="thread-safety">1.3 Thread Safety</a></h2>
|
||||
<p>All components of this library can be used safely from multiple
|
||||
threads without synchronization.<a class="footnote-reference" href="#thread" id="id2" name="id2"><sup>1</sup></a></p>
|
||||
</div>
|
||||
<div class="section" id="typography">
|
||||
<h2><a class="toc-backref" href="#id27" name="typography">1.4 Typography</a></h2>
|
||||
<p>Names written in <span class="concept">sans serif type</span> represent <a class="reference" href="../../../../more/generic_programming.html#concept">concepts</a>.</p>
|
||||
<p>In code blocks, <em>italic type</em> represents unspecified text that
|
||||
satisfies the requirements given in the detailed description that
|
||||
follows the code block.</p>
|
||||
<p>In a specification of the tokens generated by a macro, <strong>bold
|
||||
type</strong> is used to highlight the position of the expanded macro
|
||||
argument in the result.</p>
|
||||
<p>The special character β represents the value of <a class="reference" href="#boost-parameter-max-arity"><tt class="docutils literal"><span class="pre">BOOST_PARAMETER_MAX_ARITY</span></tt></a>.</p>
|
||||
</div>
|
||||
</div>
|
||||
<hr class="docutils" />
|
||||
<div class="section" id="terminology">
|
||||
<h1><a class="toc-backref" href="#id28" name="terminology">2 Terminology</a></h1>
|
||||
<span class="target" id="kw"></span><dl class="docutils">
|
||||
<dt>keyword</dt>
|
||||
<dd>The name of a function parameter.</dd>
|
||||
</dl>
|
||||
<span class="target" id="keyword-tag-type"></span><dl class="docutils">
|
||||
<dt>keyword tag type</dt>
|
||||
<dd>A type used to uniquely identify a function parameter. Typically
|
||||
its name will be the same as that of the parameter.</dd>
|
||||
</dl>
|
||||
<span class="target" id="positional"></span><dl class="docutils">
|
||||
<dt>positional argument</dt>
|
||||
<dd>An argument passed with no explicit keyword. Its parameter is
|
||||
determined in the usual C++ way: by position with respect to a
|
||||
parameter list.</dd>
|
||||
</dl>
|
||||
<span class="target" id="tag-type"></span><dl class="docutils">
|
||||
<dt>tag type</dt>
|
||||
<dd>Shorthand for “<a class="reference" href="#keyword-tag-type">keyword tag type</a>.”</dd>
|
||||
</dl>
|
||||
<span class="target" id="keyword-object"></span><dl class="docutils">
|
||||
<dt>keyword object</dt>
|
||||
<dd>An instance of <a class="reference" href="#keyword"><tt class="docutils literal"><span class="pre">keyword</span></tt></a> <tt class="docutils literal"><span class="pre"><T></span></tt> for some <a class="reference" href="#tag-type">tag type</a> <tt class="docutils literal"><span class="pre">T</span></tt>.</dd>
|
||||
</dl>
|
||||
<span class="target" id="tagged-reference"></span><dl class="docutils">
|
||||
<dt>tagged reference</dt>
|
||||
<dd><p class="first">An object whose type is associated with a <a class="reference" href="#keyword-tag-type">keyword tag type</a> (the
|
||||
object's <em>keyword</em>), and that holds a reference (to the object's
|
||||
<em>value</em>).</p>
|
||||
<p class="last">As a shorthand, a “tagged reference to <tt class="docutils literal"><span class="pre">x</span></tt>” means a tagged
|
||||
reference whose <em>value</em> is <tt class="docutils literal"><span class="pre">x</span></tt>.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
<span class="target" id="tagged-default"></span><dl class="docutils">
|
||||
<dt>tagged default </dt>
|
||||
<dd>A <a class="reference" href="#tagged-reference">tagged reference</a> whose <em>value</em> represents the value of a
|
||||
default argument.</dd>
|
||||
</dl>
|
||||
<span class="target" id="tagged-lazy-default"></span><dl class="docutils">
|
||||
<dt>tagged lazy default </dt>
|
||||
<dd>A <a class="reference" href="#tagged-reference">tagged reference</a> whose <em>value</em>, when invoked with no
|
||||
arguments, computes a default argument value.</dd>
|
||||
</dl>
|
||||
<span class="target" id="intended-argument-type"></span><dl class="docutils">
|
||||
<dt>intended argument type</dt>
|
||||
<dd>The <em>intended argument type</em> of a single-element <a class="reference" href="#argumentpack"><span class="concept">ArgumentPack</span></a> is the
|
||||
type of its element's <em>value</em>. The intended argument type of any other
|
||||
type <tt class="docutils literal"><span class="pre">X</span></tt> is <tt class="docutils literal"><span class="pre">X</span></tt> itself.</dd>
|
||||
</dl>
|
||||
<div class="note">
|
||||
<p class="first admonition-title">Note</p>
|
||||
<p class="last">In this reference, we will use concept names (and other names)
|
||||
to describe both types and objects, depending on context. So
|
||||
for example, “an <a class="reference" href="#argumentpack"><span class="concept">ArgumentPack</span></a>” can refer to a type that
|
||||
models <a class="reference" href="#argumentpack"><span class="concept">ArgumentPack</span></a> <em>or</em> an object of such a type.</p>
|
||||
</div>
|
||||
</div>
|
||||
<hr class="docutils" />
|
||||
<div class="section" id="concepts">
|
||||
<h1><a class="toc-backref" href="#id29" name="concepts">3 Concepts</a></h1>
|
||||
<p>This section describes the generic type <a class="reference" href="../../../../more/generic_programming.html#concept">concepts</a> used by the Parameter library.</p>
|
||||
<div class="section" id="argumentpack">
|
||||
<h2><a class="toc-backref" href="#id30" name="argumentpack">3.1 <span class="concept">ArgumentPack</span></a></h2>
|
||||
<p>An <span class="concept">ArgumentPack</span> is a collection of <a class="reference" href="#tagged-reference">tagged reference</a>s to the
|
||||
actual arguments passed to a function.</p>
|
||||
<div class="section" id="requirements">
|
||||
<h3><a name="requirements">Requirements</a></h3>
|
||||
<p>In the table below,</p>
|
||||
<ul class="simple">
|
||||
<li><tt class="docutils literal"><span class="pre">A</span></tt> is a model of <span class="concept">ArgumentPack</span></li>
|
||||
<li><tt class="docutils literal"><span class="pre">x</span></tt> is an instance of <tt class="docutils literal"><span class="pre">A</span></tt></li>
|
||||
<li><tt class="docutils literal"><span class="pre">u</span></tt> is a <a class="reference" href="#keyword-object">keyword object</a> of type <tt class="docutils literal"><span class="pre">K</span></tt></li>
|
||||
<li><tt class="docutils literal"><span class="pre">v</span></tt> is a <a class="reference" href="#tagged-default">tagged default</a> with <a class="reference" href="#tag-type">tag type</a> <tt class="docutils literal"><span class="pre">L</span></tt> and <em>value</em> of type <tt class="docutils literal"><span class="pre">D</span></tt></li>
|
||||
<li><tt class="docutils literal"><span class="pre">w</span></tt> is a <a class="reference" href="#tagged-lazy-default">tagged lazy default</a> with <a class="reference" href="#tag-type">tag type</a> <tt class="docutils literal"><span class="pre">M</span></tt> and <em>value</em> of type <tt class="docutils literal"><span class="pre">E</span> <span class="pre">const</span></tt></li>
|
||||
<li><tt class="docutils literal"><span class="pre">z</span></tt> is an <span class="concept">ArgumentPack</span> containing a single element (as created by <a class="reference" href="#keyword"><tt class="docutils literal"><span class="pre">keyword</span></tt></a><tt class="docutils literal"><span class="pre"><…>::operator=</span></tt>)</li>
|
||||
</ul>
|
||||
<p>Any exceptions are thrown from the invocation of <tt class="docutils literal"><span class="pre">w</span></tt>'s <em>value</em>
|
||||
will be propagated to the caller.</p>
|
||||
<table border="1" class="docutils">
|
||||
<caption><span class="concept">ArgumentPack</span> requirements</caption>
|
||||
<colgroup>
|
||||
<col width="11%" />
|
||||
<col width="31%" />
|
||||
<col width="19%" />
|
||||
<col width="40%" />
|
||||
</colgroup>
|
||||
<thead valign="bottom">
|
||||
<tr><th>Expression</th>
|
||||
<th>Type</th>
|
||||
<th>Requirements</th>
|
||||
<th>Semantics/Notes</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody valign="top">
|
||||
<tr><td><tt class="docutils literal"><span class="pre">x[u]</span></tt></td>
|
||||
<td><tt class="docutils literal"><span class="pre">binding<A,K>::type</span></tt></td>
|
||||
<td><tt class="docutils literal"><span class="pre">x</span></tt> contains an
|
||||
element <em>b</em> whose
|
||||
<a class="reference" href="#kw">keyword</a> is <tt class="docutils literal"><span class="pre">K</span></tt></td>
|
||||
<td>Returns <em>b</em>'s <em>value</em> (by
|
||||
reference).</td>
|
||||
</tr>
|
||||
<tr><td><tt class="docutils literal"><span class="pre">x[u]</span></tt></td>
|
||||
<td><tt class="docutils literal"><span class="pre">binding<A,L,D>::type</span></tt></td>
|
||||
<td><em>none</em></td>
|
||||
<td>If <tt class="docutils literal"><span class="pre">x</span></tt> contains an element <em>b</em> whose
|
||||
<a class="reference" href="#kw">keyword</a> is the same as <tt class="docutils literal"><span class="pre">u</span></tt>'s,
|
||||
returns <em>b</em>'s <em>value</em> (by
|
||||
reference). Otherwise, returns <tt class="docutils literal"><span class="pre">u</span></tt>'s <em>value</em>.</td>
|
||||
</tr>
|
||||
<tr><td><tt class="docutils literal"><span class="pre">x[w]</span></tt></td>
|
||||
<td><tt class="docutils literal"><span class="pre">lazy_binding<A,M,E>::type</span></tt></td>
|
||||
<td><em>none</em></td>
|
||||
<td>If <tt class="docutils literal"><span class="pre">x</span></tt> contains an element <em>b</em> whose
|
||||
<a class="reference" href="#kw">keyword</a> is the same as <tt class="docutils literal"><span class="pre">w</span></tt>'s,
|
||||
returns <em>b</em>'s <em>value</em> (by
|
||||
reference). Otherwise, invokes <tt class="docutils literal"><span class="pre">w</span></tt>'s <em>value</em> and returns the result.</td>
|
||||
</tr>
|
||||
<tr><td><tt class="docutils literal"><span class="pre">x,</span> <span class="pre">z</span></tt></td>
|
||||
<td>Model of <span class="concept">ArgumentPack</span></td>
|
||||
<td><em>none</em></td>
|
||||
<td>Returns an <a class="reference" href="#argumentpack"><span class="concept">ArgumentPack</span></a> containing
|
||||
all the elements of both <tt class="docutils literal"><span class="pre">x</span></tt> and
|
||||
<tt class="docutils literal"><span class="pre">z</span></tt>.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="id4">
|
||||
<h2><a class="toc-backref" href="#id31" name="id4">3.2 <span class="target" id="parameterspec"></span><span class="concept">ParameterSpec</span></a></h2>
|
||||
<p>A <span class="concept">ParameterSpec</span> describes the type requirements for arguments
|
||||
corresponding to a given <a class="reference" href="#kw">keyword</a> and indicates whether the argument
|
||||
is optional or required. The table below details the allowed forms
|
||||
and describes their condition for satisfaction by an actual
|
||||
argument type. In each row,</p>
|
||||
<span class="target" id="conditions"></span><ul class="simple">
|
||||
<li><tt class="docutils literal"><span class="pre">K</span></tt> is the <span class="concept">ParameterSpec</span>'s <a class="reference" href="#keyword-tag-type">keyword tag type</a></li>
|
||||
<li><tt class="docutils literal"><span class="pre">A</span></tt> is an <a class="reference" href="#intended-argument-type">intended argument type</a> associated with <tt class="docutils literal"><span class="pre">K</span></tt>, if any</li>
|
||||
<li><tt class="docutils literal"><span class="pre">F</span></tt> is a unary <a class="reference" href="../../../mpl/doc/refmanual/lambda-expression.html">MPL lambda expression</a></li>
|
||||
</ul>
|
||||
<table border="1" class="docutils">
|
||||
<caption><span class="concept">ParameterSpec</span> allowed forms and conditions of satisfaction</caption>
|
||||
<colgroup>
|
||||
<col width="32%" />
|
||||
<col width="21%" />
|
||||
<col width="47%" />
|
||||
</colgroup>
|
||||
<thead valign="bottom">
|
||||
<tr><th>Type</th>
|
||||
<th><tt class="docutils literal"><span class="pre">A</span></tt> required</th>
|
||||
<th>Condition <tt class="docutils literal"><span class="pre">A</span></tt> must satisfy</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody valign="top">
|
||||
<tr><td><a class="reference" href="#keyword"><tt class="docutils literal"><span class="pre">keyword</span></tt></a><tt class="docutils literal"><span class="pre"><K></span></tt></td>
|
||||
<td>no</td>
|
||||
<td><em>n/a</em></td>
|
||||
</tr>
|
||||
<tr><td><a class="reference" href="#optional"><tt class="docutils literal"><span class="pre">optional</span></tt></a><tt class="docutils literal"><span class="pre"><K,F></span></tt></td>
|
||||
<td>no</td>
|
||||
<td><tt class="docutils literal"><span class="pre">mpl::apply<F,A>::type::value</span></tt>
|
||||
is <tt class="docutils literal"><span class="pre">true</span></tt>.</td>
|
||||
</tr>
|
||||
<tr><td><a class="reference" href="#required"><tt class="docutils literal"><span class="pre">required</span></tt></a><tt class="docutils literal"><span class="pre"><K,F></span></tt></td>
|
||||
<td>yes</td>
|
||||
<td><tt class="docutils literal"><span class="pre">mpl::apply<F,A>::type::value</span></tt>
|
||||
is <tt class="docutils literal"><span class="pre">true</span></tt>.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p>The information in a <span class="concept">ParameterSpec</span> is used to <a class="reference" href="index.html#controlling-overload-resolution">limit</a> the
|
||||
arguments that will be matched by <a class="reference" href="index.html#forwarding-functions">forwarding functions</a>.</p>
|
||||
</div>
|
||||
</div>
|
||||
<hr class="docutils" />
|
||||
<div class="section" id="class-templates">
|
||||
<h1><a class="toc-backref" href="#id32" name="class-templates">4 Class Templates</a></h1>
|
||||
<div class="section" id="id6">
|
||||
<h2><a class="toc-backref" href="#id33" name="id6">4.1 <span class="target" id="keyword"></span><tt class="docutils literal"><span class="pre">keyword</span></tt></a></h2>
|
||||
<p>The type of every <a class="reference" href="#keyword-object">keyword object</a> is a specialization of <tt class="docutils literal"><span class="pre">keyword</span></tt>.</p>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field"><th class="field-name">Defined in:</th><td class="field-body"><a class="reference" href="../../../../boost/parameter/keyword.hpp">boost/parameter/keyword.hpp</a></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<pre class="literal-block">
|
||||
template <class Tag>
|
||||
struct keyword
|
||||
{
|
||||
template <class T> <a class="reference" href="#argumentpack"><span class="concept">ArgumentPack</span></a> <a class="reference" href="#operator">operator=</a>(T& value) const;
|
||||
template <class T> <a class="reference" href="#argumentpack"><span class="concept">ArgumentPack</span></a> <a class="reference" href="#operator">operator=</a>(T const& value) const;
|
||||
|
||||
template <class T> <em>tagged default</em> <a class="reference" href="#id8">operator|</a>(T& x) const;
|
||||
template <class T> <em>tagged default</em> <a class="reference" href="#id8">operator|</a>(T const& x) const;
|
||||
|
||||
template <class F> <em>tagged lazy default</em> <a class="reference" href="#id9">operator||</a>(F const&) const;
|
||||
|
||||
static keyword<Tag>& <a class="reference" href="#get">get</a>();
|
||||
};
|
||||
</pre>
|
||||
<span class="target" id="operator"></span><dl class="docutils">
|
||||
<dt><tt class="docutils literal"><span class="pre">operator=</span></tt></dt>
|
||||
<dd><pre class="first literal-block">
|
||||
template <class T> <a class="reference" href="#argumentpack"><span class="concept">ArgumentPack</span></a> operator=(T& value) const;
|
||||
template <class T> <a class="reference" href="#argumentpack"><span class="concept">ArgumentPack</span></a> operator=(T const& value) const;
|
||||
</pre>
|
||||
<table class="last docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field"><th class="field-name">Requires:</th><td class="field-body">nothing</td>
|
||||
</tr>
|
||||
<tr class="field"><th class="field-name">Returns:</th><td class="field-body">an <a class="reference" href="#argumentpack"><span class="concept">ArgumentPack</span></a> containing a single <a class="reference" href="#tagged-reference">tagged reference</a> to
|
||||
<tt class="docutils literal"><span class="pre">value</span></tt> with <a class="reference" href="#kw">keyword</a> <tt class="docutils literal"><span class="pre">Tag</span></tt></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</dd>
|
||||
</dl>
|
||||
<span class="target" id="id8"></span><dl class="docutils">
|
||||
<dt><tt class="docutils literal"><span class="pre">operator|</span></tt></dt>
|
||||
<dd><pre class="first literal-block">
|
||||
template <class T> <em>tagged default</em> operator|(T& x) const;
|
||||
template <class T> <em>tagged default</em> operator|(T const& x) const;
|
||||
</pre>
|
||||
<table class="last docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field"><th class="field-name">Returns:</th><td class="field-body">a <a class="reference" href="#tagged-default">tagged default</a> with <em>value</em> <tt class="docutils literal"><span class="pre">x</span></tt> and <a class="reference" href="#kw">keyword</a> <tt class="docutils literal"><span class="pre">Tag</span></tt>.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</dd>
|
||||
</dl>
|
||||
<span class="target" id="id9"></span><dl class="docutils">
|
||||
<dt><tt class="docutils literal"><span class="pre">operator||</span></tt></dt>
|
||||
<dd><pre class="first literal-block">
|
||||
template <class F> <em>tagged lazy default</em> operator||(F const& g) const;
|
||||
</pre>
|
||||
<table class="last docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field"><th class="field-name">Requires:</th><td class="field-body"><tt class="docutils literal"><span class="pre">g()</span></tt> is valid, with type <tt class="docutils literal"><span class="pre">boost::</span></tt><a class="reference" href="../../../utility/utility.htm#result_of"><tt class="docutils literal"><span class="pre">result_of</span></tt></a><tt class="docutils literal"><span class="pre"><F()>::type</span></tt>.<a class="footnote-reference" href="#no-result-of" id="id10" name="id10"><sup>2</sup></a></td>
|
||||
</tr>
|
||||
<tr class="field"><th class="field-name">Returns:</th><td class="field-body">a <a class="reference" href="#tagged-lazy-default">tagged lazy default</a> with <em>value</em> <tt class="docutils literal"><span class="pre">g</span></tt> and <a class="reference" href="#kw">keyword</a> <tt class="docutils literal"><span class="pre">Tag</span></tt>.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</dd>
|
||||
</dl>
|
||||
<span class="target" id="get"></span><dl class="docutils">
|
||||
<dt><tt class="docutils literal"><span class="pre">get</span></tt></dt>
|
||||
<dd><pre class="first literal-block">
|
||||
static keyword<Tag>& get();
|
||||
</pre>
|
||||
<table class="last docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field"><th class="field-name">Returns:</th><td class="field-body">a “singleton instance”: the same object will be
|
||||
returned on each invocation of <tt class="docutils literal"><span class="pre">get()</span></tt>.</td>
|
||||
</tr>
|
||||
<tr class="field"><th class="field-name">Thread Safety:</th><td class="field-body"><tt class="docutils literal"><span class="pre">get()</span></tt> can be called from multiple threads
|
||||
simultaneously.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="section" id="parameters">
|
||||
<h2><a class="toc-backref" href="#id34" name="parameters">4.2 <tt class="docutils literal"><span class="pre">parameters</span></tt></a></h2>
|
||||
<p>Provides an interface for assembling the actual arguments to a
|
||||
<cite>forwarding function</cite> into an <span class="concept">ArgumentPack</span>, in which any
|
||||
<a class="reference" href="#positional">positional</a> arguments will be tagged according to the
|
||||
corresponding template argument to <tt class="docutils literal"><span class="pre">parameters</span></tt>.</p>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field"><th class="field-name">Defined in:</th><td class="field-body"><a class="reference" href="../../../../boost/parameter/parameters.hpp">boost/parameter/parameters.hpp</a></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<pre class="literal-block">
|
||||
template <class P0 = <em>unspecified</em>, class P1 = <em>unspecified</em>, …class Pβ = <em>unspecified</em>>
|
||||
struct parameters
|
||||
{
|
||||
template <class A0, class A1 = <em>unspecified</em>, …class Aβ = <em>unspecified</em>>
|
||||
struct <a class="reference" href="#match">match</a>
|
||||
{
|
||||
typedef … type;
|
||||
};
|
||||
|
||||
template <class A0>
|
||||
<a class="reference" href="#argumentpack"><span class="concept">ArgumentPack</span></a> <a class="reference" href="#id12">operator()</a>(A0 const& a0) const;
|
||||
|
||||
template <class A0, class A1>
|
||||
<a class="reference" href="#argumentpack"><span class="concept">ArgumentPack</span></a> <a class="reference" href="#id12">operator()</a>(A0 const& a0, A1 const& a1) const; <span class="vellipsis">
|
||||
.
|
||||
.
|
||||
.
|
||||
</span>
|
||||
template <class A0, class A1, …class Aβ>
|
||||
<a class="reference" href="#argumentpack"><span class="concept">ArgumentPack</span></a> <a class="reference" href="#id12">operator()</a>(A0 const& a0, A1 const& a1, …Aβ const& aβ) const;
|
||||
};
|
||||
</pre>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field"><th class="field-name">Requires:</th><td class="field-body"><tt class="docutils literal"><span class="pre">P0</span></tt>, <tt class="docutils literal"><span class="pre">P1</span></tt>, … <tt class="docutils literal"><span class="pre">P</span></tt>β are models of <a class="reference" href="#parameterspec"><span class="concept">ParameterSpec</span></a>.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="note">
|
||||
<p class="first admonition-title">Note</p>
|
||||
<p>In this section, <tt class="docutils literal"><span class="pre">R</span></tt><em>i</em> and <tt class="docutils literal"><span class="pre">K</span></tt><em>i</em> are defined as
|
||||
follows, for any argument type <tt class="docutils literal"><span class="pre">A</span></tt><em>i</em>:</p>
|
||||
<blockquote class="last">
|
||||
<div class="line-block">
|
||||
<div class="line"><tt class="docutils literal"><span class="pre">R</span></tt><em>i</em> is <tt class="docutils literal"><span class="pre">A</span></tt><em>i</em>'s <a class="reference" href="#intended-argument-type">intended argument type</a></div>
|
||||
<div class="line"><br /></div>
|
||||
<div class="line-block">
|
||||
<div class="line">if <tt class="docutils literal"><span class="pre">A</span></tt><em>i</em> is a result type of <tt class="docutils literal"><span class="pre">keyword<T>::</span></tt><a class="reference" href="#operator"><tt class="docutils literal"><span class="pre">operator=</span></tt></a></div>
|
||||
<div class="line">then </div>
|
||||
<div class="line-block">
|
||||
<div class="line"><tt class="docutils literal"><span class="pre">K</span></tt><em>i</em> is <tt class="docutils literal"><span class="pre">T</span></tt></div>
|
||||
</div>
|
||||
<div class="line">else </div>
|
||||
<div class="line-block">
|
||||
<div class="line"><tt class="docutils literal"><span class="pre">K</span></tt><em>i</em> is <tt class="docutils literal"><span class="pre">P</span></tt><em>i</em>'s <a class="reference" href="#keyword-tag-type">keyword tag type</a>.</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</blockquote>
|
||||
</div>
|
||||
<span class="target" id="match"></span><dl class="docutils">
|
||||
<dt><tt class="docutils literal"><span class="pre">match</span></tt></dt>
|
||||
<dd><p class="first">A <a class="reference" href="../../../mpl/doc/refmanual/metafunction.html"><span class="concept">Metafunction</span></a> used to remove a <a class="reference" href="index.html#forwarding-functions">forwarding function</a> from overload resolution.</p>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field"><th class="field-name">Returns:</th><td class="field-body">if <tt class="docutils literal"><span class="pre">P0</span></tt>, <tt class="docutils literal"><span class="pre">P1</span></tt>, …<tt class="docutils literal"><span class="pre">P</span></tt>β are <em>satisfied</em> (see
|
||||
below), then <tt class="docutils literal"><span class="pre">parameters<P0,P1,…Pβ></span></tt>. Otherwise,
|
||||
<tt class="docutils literal"><span class="pre">match<A0,A1,…Aβ>::type</span></tt> is not defined.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p><tt class="docutils literal"><span class="pre">P0</span></tt>, <tt class="docutils literal"><span class="pre">P1</span></tt>, …<tt class="docutils literal"><span class="pre">P</span></tt>β are <strong>satisfied</strong> if, for
|
||||
every <em>j</em> in 0…β, either:</p>
|
||||
<ul class="last simple">
|
||||
<li><tt class="docutils literal"><span class="pre">P</span></tt><em>j</em> is the <em>unspecified</em> default</li>
|
||||
<li><strong>or</strong>, <tt class="docutils literal"><span class="pre">P</span></tt><em>j</em> is a specialization of <a class="reference" href="#keyword"><tt class="docutils literal"><span class="pre">keyword</span></tt></a>,</li>
|
||||
<li><strong>or</strong>, <tt class="docutils literal"><span class="pre">P</span></tt><em>j</em> is <a class="reference" href="#optional"><tt class="docutils literal"><span class="pre">optional</span></tt></a> <tt class="docutils literal"><span class="pre"><X,F></span></tt> and either<ul>
|
||||
<li><tt class="docutils literal"><span class="pre">X</span></tt> is not <tt class="docutils literal"><span class="pre">K</span></tt><em>i</em> for any <em>i</em>,</li>
|
||||
<li><strong>or</strong> <tt class="docutils literal"><span class="pre">X</span></tt> is some <tt class="docutils literal"><span class="pre">K</span></tt><em>i</em> and <tt class="docutils literal"><span class="pre">mpl::apply<F,R</span></tt><em>i</em><tt class="docutils literal"><span class="pre">>::type::value</span></tt> is <tt class="docutils literal"><span class="pre">true</span></tt></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><strong>or</strong>, <tt class="docutils literal"><span class="pre">P</span></tt><em>j</em> is <a class="reference" href="#required"><tt class="docutils literal"><span class="pre">required</span></tt></a> <tt class="docutils literal"><span class="pre"><X,F></span></tt>, and<ul>
|
||||
<li><tt class="docutils literal"><span class="pre">X</span></tt> is some <tt class="docutils literal"><span class="pre">K</span></tt><em>i</em>, <strong>and</strong></li>
|
||||
<li><tt class="docutils literal"><span class="pre">mpl::apply<F,R</span></tt><em>i</em><tt class="docutils literal"><span class="pre">>::type::value</span></tt> is <tt class="docutils literal"><span class="pre">true</span></tt></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</dd>
|
||||
</dl>
|
||||
<span class="target" id="id12"></span><dl class="docutils">
|
||||
<dt><tt class="docutils literal"><span class="pre">operator()</span></tt></dt>
|
||||
<dd><pre class="first literal-block">
|
||||
template <class A0> <a class="reference" href="#argumentpack"><span class="concept">ArgumentPack</span></a> operator()(A0 const& a0) const; <span class="vellipsis">
|
||||
.
|
||||
.
|
||||
.
|
||||
</span>
|
||||
template <class A0, …class Aβ> <a class="reference" href="#argumentpack"><span class="concept">ArgumentPack</span></a> <a class="reference" href="#id12">operator()</a>(A0 const& a0, …Aβ const& aβ) const;
|
||||
</pre>
|
||||
<table class="last docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">An <a class="reference" href="#argumentpack"><span class="concept">ArgumentPack</span></a> containing, for each <tt class="docutils literal"><span class="pre">a</span></tt><em>i</em>,</p>
|
||||
<ul class="last simple">
|
||||
<li>if <tt class="docutils literal"><span class="pre">a</span></tt><em>i</em>, is a single-element <span class="concept">ArgumentPack</span>, its element</li>
|
||||
<li>Otherwise, a <a class="reference" href="#tagged-reference">tagged reference</a> with <a class="reference" href="#kw">keyword</a> <tt class="docutils literal"><span class="pre">K</span></tt><em>i</em> and <em>value</em> <tt class="docutils literal"><span class="pre">a</span></tt><em>i</em></li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="section" id="optional-required">
|
||||
<h2><a class="toc-backref" href="#id35" name="optional-required">4.3 <span class="target" id="required"></span><span class="target" id="optional"></span><tt class="docutils literal"><span class="pre">optional</span></tt>, <tt class="docutils literal"><span class="pre">required</span></tt></a></h2>
|
||||
<p>These templates describe the requirements on a function parameter.</p>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field"><th class="field-name">Defined in:</th><td class="field-body"><a class="reference" href="../../../../boost/parameter/parameters.hpp">boost/parameter/parameters.hpp</a></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field"><th class="field-name" colspan="2">Specializations model:</th></tr>
|
||||
<tr><td> </td><td class="field-body"><a class="reference" href="#parameterspec"><span class="concept">ParameterSpec</span></a></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<pre class="literal-block">
|
||||
template <class Tag, class Predicate = <em>unspecified</em>>
|
||||
struct optional;
|
||||
|
||||
template <class Tag, class Predicate = <em>unspecified</em>>
|
||||
struct required;
|
||||
</pre>
|
||||
<p>The default value of <tt class="docutils literal"><span class="pre">Predicate</span></tt> is an unspecified <a class="reference" href="../../../mpl/doc/refmanual/metafunction.html"><span class="concept">Metafunction</span></a> that returns
|
||||
<tt class="docutils literal"><span class="pre">mpl::true_</span></tt> for any argument.</p>
|
||||
</div>
|
||||
</div>
|
||||
<hr class="docutils" />
|
||||
<div class="section" id="metafunctions">
|
||||
<h1><a class="toc-backref" href="#id36" name="metafunctions">5 Metafunctions</a></h1>
|
||||
<p>A <a class="reference" href="../../../mpl/doc/refmanual/metafunction.html"><span class="concept">Metafunction</span></a> is conceptually a function that operates on, and
|
||||
returns, C++ types.</p>
|
||||
<div class="section" id="binding">
|
||||
<h2><a class="toc-backref" href="#id37" name="binding">5.1 <tt class="docutils literal"><span class="pre">binding</span></tt></a></h2>
|
||||
<p>Returns the result type of indexing an argument pack with a
|
||||
<a class="reference" href="#keyword-tag-type">keyword tag type</a> or with a <a class="reference" href="#tagged-default">tagged default</a>.</p>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field"><th class="field-name">Defined n:</th><td class="field-body"><a class="reference" href="../../../../boost/parameter/binding.hpp">boost/parameter/binding.hpp</a></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<pre class="literal-block">
|
||||
template <class A, class K, class D = void>
|
||||
struct binding
|
||||
{
|
||||
typedef … type;
|
||||
};
|
||||
</pre>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field"><th class="field-name">Requires:</th><td class="field-body"><tt class="docutils literal"><span class="pre">A</span></tt> is a model of <a class="reference" href="#argumentpack"><span class="concept">ArgumentPack</span></a>.</td>
|
||||
</tr>
|
||||
<tr class="field"><th class="field-name">Returns:</th><td class="field-body">the reference type of the <a class="reference" href="#tagged-reference">tagged reference</a> in <tt class="docutils literal"><span class="pre">A</span></tt>
|
||||
having <a class="reference" href="#keyword-tag-type">keyword tag type</a> <tt class="docutils literal"><span class="pre">K</span></tt>, if any. If no such <a class="reference" href="#tagged-reference">tagged reference</a> exists, returns <tt class="docutils literal"><span class="pre">D</span></tt>.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="section" id="lazy-binding">
|
||||
<h2><a class="toc-backref" href="#id38" name="lazy-binding">5.2 <tt class="docutils literal"><span class="pre">lazy_binding</span></tt></a></h2>
|
||||
<p>Returns the result type of indexing an argument pack with a <a class="reference" href="#tagged-lazy-default">tagged lazy default</a>.</p>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field"><th class="field-name">Defined in:</th><td class="field-body"><a class="reference" href="../../../../boost/parameter/binding.hpp">boost/parameter/binding.hpp</a></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<pre class="literal-block">
|
||||
template <class A, class K, class F>
|
||||
struct lazy_binding
|
||||
{
|
||||
typedef … type;
|
||||
};
|
||||
</pre>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field"><th class="field-name">Requires:</th><td class="field-body"><tt class="docutils literal"><span class="pre">A</span></tt> is a model of <a class="reference" href="#argumentpack"><span class="concept">ArgumentPack</span></a>.</td>
|
||||
</tr>
|
||||
<tr class="field"><th class="field-name">Returns:</th><td class="field-body">the reference type of the <a class="reference" href="#tagged-reference">tagged reference</a> in <tt class="docutils literal"><span class="pre">A</span></tt>
|
||||
having <a class="reference" href="#keyword-tag-type">keyword tag type</a> <tt class="docutils literal"><span class="pre">K</span></tt>, if any. If no such <a class="reference" href="#tagged-reference">tagged reference</a> exists, returns <tt class="docutils literal"><span class="pre">boost::</span></tt><a class="reference" href="../../../utility/utility.htm#result_of"><tt class="docutils literal"><span class="pre">result_of</span></tt></a><tt class="docutils literal"><span class="pre"><F()>::type</span></tt>.<a class="footnote-reference" href="#no-result-of" id="id16" name="id16"><sup>2</sup></a></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<hr class="docutils" />
|
||||
<div class="section" id="code-generation-macros">
|
||||
<h1><a class="toc-backref" href="#id39" name="code-generation-macros">6 Code Generation Macros</a></h1>
|
||||
<p>Macros in this section can be used to ease the writing of code
|
||||
using the Parameter libray by eliminating repetitive boilerplate.</p>
|
||||
<div class="section" id="boost-parameter-fun-r-n-l-h-p">
|
||||
<h2><a class="toc-backref" href="#id40" name="boost-parameter-fun-r-n-l-h-p">6.1 <tt class="docutils literal"><span class="pre">BOOST_PARAMETER_FUN(r,n,l,h,p)</span></tt></a></h2>
|
||||
<p>Generates a sequence of <a class="reference" href="index.html#forwarding-functions">forwarding function</a> templates named
|
||||
<tt class="docutils literal"><span class="pre">n</span></tt>, with arities ranging from <tt class="docutils literal"><span class="pre">l</span></tt> to <tt class="docutils literal"><span class="pre">h</span></tt> , returning <tt class="docutils literal"><span class="pre">r</span></tt>,
|
||||
and using <tt class="docutils literal"><span class="pre">p</span></tt> to control overload resolution and assign tags to
|
||||
positional arguments.</p>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field"><th class="field-name">Defined in:</th><td class="field-body"><a class="reference" href="../../../../boost/parameter/macros.hpp">boost/parameter/macros.hpp</a></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field"><th class="field-name">Requires:</th><td class="field-body"><tt class="docutils literal"><span class="pre">l</span></tt> and <tt class="docutils literal"><span class="pre">h</span></tt> are nonnegative integer tokens such
|
||||
that <tt class="docutils literal"><span class="pre">l</span></tt> < <tt class="docutils literal"><span class="pre">h</span></tt></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<dl class="docutils">
|
||||
<dt>Generates</dt>
|
||||
<dd><pre class="first last literal-block">
|
||||
template <class A1, class A2, …class A##<strong>l</strong>>
|
||||
r name(
|
||||
A1 const& a1, A2 const& a2, …A<strong>l</strong> const& x<strong>l</strong>
|
||||
, typename <strong>p</strong>::match<A1,A2,…A<strong>l</strong>>::type p = <strong>p</strong>())
|
||||
{
|
||||
return <strong>name</strong>_with_named_params(<strong>p</strong>(x1,x2,…x<strong>l</strong>));
|
||||
}
|
||||
|
||||
template <class A1, class A2, …class A<strong>l</strong>, class A##<a class="reference" href="../../../preprocessor/doc/ref/inc.html">BOOST_PP_INC</a>(<strong>l</strong>)>
|
||||
r name(
|
||||
A1 const& a1, A2 const& a2, …A<strong>l</strong> const& x<strong>l</strong>
|
||||
, A##<a class="reference" href="../../../preprocessor/doc/ref/inc.html">BOOST_PP_INC</a>(<strong>l</strong>) const& x##<a class="reference" href="../../../preprocessor/doc/ref/inc.html">BOOST_PP_INC</a>(<strong>l</strong>)
|
||||
, typename <strong>p</strong>::match<A1,A2,…A<strong>l</strong>,A##<a class="reference" href="../../../preprocessor/doc/ref/inc.html">BOOST_PP_INC</a>(<strong>l</strong>)>::type p = <strong>p</strong>())
|
||||
{
|
||||
return <strong>name</strong>_with_named_params(<strong>p</strong>(x1,x2,…x<strong>l</strong>,x##<a class="reference" href="../../../preprocessor/doc/ref/inc.html">BOOST_PP_INC</a>(<strong>l</strong>)));
|
||||
} <span class="vellipsis">
|
||||
.
|
||||
.
|
||||
.
|
||||
</span>
|
||||
template <class A1, class A2, …class A<strong>h</strong>>
|
||||
r name(
|
||||
A1 const& a1, A2 const& a2, …A<strong>h</strong> const& x<strong>h</strong>
|
||||
, typename <strong>p</strong>::match<A1,A2,…A<strong>h</strong>>::type p = <strong>p</strong>())
|
||||
{
|
||||
return <strong>name</strong>_with_named_params(<strong>p</strong>(a1,a2,…a<strong>h</strong>));
|
||||
}
|
||||
</pre>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="section" id="boost-parameter-keyword-n-k">
|
||||
<h2><a class="toc-backref" href="#id41" name="boost-parameter-keyword-n-k">6.2 <tt class="docutils literal"><span class="pre">BOOST_PARAMETER_KEYWORD(n,k)</span></tt></a></h2>
|
||||
<p>Generates the declaration of a <a class="reference" href="#keyword-tag-type">keyword tag type</a> named <tt class="docutils literal"><span class="pre">k</span></tt> in
|
||||
namespace <tt class="docutils literal"><span class="pre">n</span></tt>, and a corresponding <a class="reference" href="#keyword-object">keyword object</a> definition in
|
||||
the enclosing namespace.</p>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field"><th class="field-name">Defined in:</th><td class="field-body"><a class="reference" href="../../../../boost/parameter/keyword.hpp">boost/parameter/keyword.hpp</a></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<dl class="docutils">
|
||||
<dt>Generates</dt>
|
||||
<dd><pre class="first last literal-block">
|
||||
namespace <strong>n</strong> { struct <strong>k</strong>; }
|
||||
namespace {
|
||||
boost::parameter::keyword<<em>tag-namespace</em>::<strong>k</strong>>& <strong>k</strong>
|
||||
= boost::parameter::keyword<<em>tag-namespace</em>::<strong>k</strong>>::get();
|
||||
}
|
||||
</pre>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="section" id="boost-parameter-match-p-a-x">
|
||||
<h2><a class="toc-backref" href="#id42" name="boost-parameter-match-p-a-x">6.3 <tt class="docutils literal"><span class="pre">BOOST_PARAMETER_MATCH(p,a,x)</span></tt></a></h2>
|
||||
<p>Generates a defaulted parameter declaration for a <a class="reference" href="index.html#forwarding-functions">forwarding
|
||||
function</a>.</p>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field"><th class="field-name">Defined in:</th><td class="field-body"><a class="reference" href="../../../../boost/parameter/match.hpp">boost/parameter/match.hpp</a></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field"><th class="field-name">Requires:</th><td class="field-body"><p class="first"><tt class="docutils literal"><span class="pre">a</span></tt> is a <a class="reference" href="http://www.boost.org/libs/preprocessor/doc/data.html">Boost.Preprocessor sequence</a>
|
||||
of the form</p>
|
||||
<pre class="last literal-block">
|
||||
(A0)(A1)…(A<em>n</em>)
|
||||
</pre>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<dl class="docutils">
|
||||
<dt>Generates</dt>
|
||||
<dd><pre class="first last literal-block">
|
||||
typename <strong>p</strong>::match<<strong>A0</strong>,<strong>A1</strong>…,<strong>A</strong><em>n</em>>::type <strong>x</strong> = <strong>p</strong>()
|
||||
</pre>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="configuration-macros">
|
||||
<h1><a class="toc-backref" href="#id43" name="configuration-macros">7 Configuration Macros</a></h1>
|
||||
<div class="section" id="boost-parameter-max-arity">
|
||||
<h2><a class="toc-backref" href="#id44" name="boost-parameter-max-arity">7.1 <tt class="docutils literal"><span class="pre">BOOST_PARAMETER_MAX_ARITY</span></tt></a></h2>
|
||||
<p>Determines the maximum number of arguments supported by the
|
||||
library. Will only be <tt class="docutils literal"><span class="pre">#defined</span></tt> by the library if it is not
|
||||
already <tt class="docutils literal"><span class="pre">#defined</span></tt>.</p>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field"><th class="field-name">Defined in:</th><td class="field-body"><a class="reference" href="../../../../boost/parameter/config.hpp">boost/parameter/config.hpp</a></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field"><th class="field-name">Default Value:</th><td class="field-body"><tt class="docutils literal"><span class="pre">5</span></tt></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="tutorial">
|
||||
<h1><a class="toc-backref" href="#id45" name="tutorial">8 Tutorial</a></h1>
|
||||
<p>Follow <a class="reference" href="index.html#tutorial">this link</a> to the Boost.Parameter tutorial
|
||||
documentation.</p>
|
||||
<hr class="docutils" />
|
||||
<table class="docutils footnote" frame="void" id="thread" rules="none">
|
||||
<colgroup><col class="label" /><col /></colgroup>
|
||||
<tbody valign="top">
|
||||
<tr><td class="label"><a class="fn-backref" href="#id2" name="thread">[1]</a></td><td>References to tag objects may be initialized multiple
|
||||
times. This scenario can only occur in the presence of
|
||||
threading. Because the C++ standard doesn't consider threading,
|
||||
it doesn't explicitly allow or forbid multiple initialization of
|
||||
references. That said, it's hard to imagine an implementation
|
||||
where it could make a difference.</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<table class="docutils footnote" frame="void" id="no-result-of" rules="none">
|
||||
<colgroup><col class="label" /><col /></colgroup>
|
||||
<tbody valign="top">
|
||||
<tr><td class="label"><a name="no-result-of">[2]</a></td><td><em>(<a class="fn-backref" href="#id10">1</a>, <a class="fn-backref" href="#id16">2</a>)</em> Where <a class="reference" href="../../../utility/utility.htm#BOOST_NO_RESULT_OF"><tt class="docutils literal"><span class="pre">BOOST_NO_RESULT_OF</span></tt></a> is <tt class="docutils literal"><span class="pre">#defined</span></tt>,
|
||||
<tt class="docutils literal"><span class="pre">boost::</span></tt><a class="reference" href="../../../utility/utility.htm#result_of"><tt class="docutils literal"><span class="pre">result_of</span></tt></a><tt class="docutils literal"><span class="pre"><F()>::type</span></tt> is replaced by
|
||||
<tt class="docutils literal"><span class="pre">F::result_type</span></tt>.</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<hr class="docutils footer" />
|
||||
<div class="footer">
|
||||
Generated on: 2005-08-05 14:58 UTC.
|
||||
Generated by <a class="reference" href="http://docutils.sourceforge.net/">Docutils</a> from <a class="reference" href="http://docutils.sourceforge.net/rst.html">reStructuredText</a> source.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,34 +0,0 @@
|
||||
@import "../../../../rst.css";
|
||||
|
||||
div.section div.section div.section dl {
|
||||
margin-left: 2em;
|
||||
}
|
||||
|
||||
td span {
|
||||
vertical-align: text-top;
|
||||
}
|
||||
|
||||
img {
|
||||
border: none;
|
||||
vertical-align: middle
|
||||
}
|
||||
|
||||
span.vellipsis {
|
||||
line-height: 30% ;
|
||||
font-size: 200% ;
|
||||
}
|
||||
|
||||
|
||||
PRE
|
||||
{
|
||||
FONT-FAMILY: monospace ;
|
||||
}
|
||||
|
||||
CODE
|
||||
{
|
||||
FONT-FAMILY: monospace;
|
||||
}
|
||||
.pre
|
||||
{
|
||||
FONT-FAMILY: monospace;
|
||||
}
|
||||
1275
doc/index.rst
1275
doc/index.rst
File diff suppressed because it is too large
Load Diff
@@ -1,689 +0,0 @@
|
||||
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
The Boost Parameter Library Reference Documentation
|
||||
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
|(logo)|__
|
||||
|
||||
.. |(logo)| image:: ../../../../boost.png
|
||||
:alt: Boost
|
||||
|
||||
__ ../../../../index.htm
|
||||
|
||||
:Authors: David Abrahams, Daniel Wallin
|
||||
:Contact: dave@boost-consulting.com, dalwan01@student.umu.se
|
||||
:organization: `Boost Consulting`_
|
||||
:date: $Date: 2005/07/17 19:53:01 $
|
||||
|
||||
:copyright: Copyright David Abrahams, Daniel Wallin
|
||||
2005. Distributed under the Boost Software License,
|
||||
Version 1.0. (See accompanying file LICENSE_1_0.txt
|
||||
or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
.. _`Boost Consulting`: http://www.boost-consulting.com
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
.. contents::
|
||||
:depth: 2
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
.. role:: class
|
||||
:class: class
|
||||
|
||||
.. role:: concept
|
||||
:class: concept
|
||||
|
||||
.. role:: function
|
||||
:class: function
|
||||
|
||||
.. |ArgumentPack| replace:: :concept:`ArgumentPack`
|
||||
.. |ParameterSpec| replace:: :concept:`ParameterSpec`
|
||||
|
||||
.. role:: vellipsis
|
||||
:class: vellipsis
|
||||
|
||||
.. section-numbering::
|
||||
:depth: 2
|
||||
|
||||
Preliminaries
|
||||
=============
|
||||
|
||||
This section covers some basic information you'll need to know in
|
||||
order to understand this reference
|
||||
|
||||
Namespaces
|
||||
----------
|
||||
|
||||
In this document, all unqualified identifiers should be assumed to
|
||||
be defined in namespace ``boost::parameter`` unless otherwise
|
||||
specified.
|
||||
|
||||
Exceptions
|
||||
----------
|
||||
|
||||
No operation described in this document
|
||||
throws an exception unless otherwise specified.
|
||||
|
||||
Thread Safety
|
||||
-------------
|
||||
|
||||
All components of this library can be used safely from multiple
|
||||
threads without synchronization. [#thread]_
|
||||
|
||||
Typography
|
||||
----------
|
||||
|
||||
Names written in :concept:`sans serif type` represent concepts_.
|
||||
|
||||
In code blocks, *italic type* represents unspecified text that
|
||||
satisfies the requirements given in the detailed description that
|
||||
follows the code block.
|
||||
|
||||
In a specification of the tokens generated by a macro, **bold
|
||||
type** is used to highlight the position of the expanded macro
|
||||
argument in the result.
|
||||
|
||||
The special character β represents the value of |BOOST_PARAMETER_MAX_ARITY|_.
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Terminology
|
||||
===========
|
||||
|
||||
.. |kw| replace:: keyword
|
||||
.. _kw:
|
||||
|
||||
keyword
|
||||
The name of a function parameter.
|
||||
|
||||
.. _keyword tag type:
|
||||
.. |keyword tag type| replace:: `keyword tag type`_
|
||||
|
||||
keyword tag type
|
||||
A type used to uniquely identify a function parameter. Typically
|
||||
its name will be the same as that of the parameter.
|
||||
|
||||
.. _positional:
|
||||
.. |positional| replace:: `positional`_
|
||||
|
||||
positional argument
|
||||
An argument passed with no explicit |kw|. Its parameter is
|
||||
determined in the usual C++ way: by position with respect to a
|
||||
parameter list.
|
||||
|
||||
.. _tag type:
|
||||
.. |tag type| replace:: `tag type`_
|
||||
|
||||
tag type
|
||||
Shorthand for “\ |keyword tag type|.”
|
||||
|
||||
.. _keyword object:
|
||||
.. |keyword object| replace:: `keyword object`_
|
||||
|
||||
keyword object
|
||||
An instance of |keyword|_ ``<T>`` for some |tag
|
||||
type| ``T``.
|
||||
|
||||
.. _tagged reference:
|
||||
.. |tagged reference| replace:: `tagged reference`_
|
||||
|
||||
tagged reference
|
||||
An object whose type is associated with a |keyword tag type| (the
|
||||
object's *keyword*), and that holds a reference (to the object's
|
||||
*value*).
|
||||
|
||||
As a shorthand, a “tagged reference to ``x``\ ” means a tagged
|
||||
reference whose *value* is ``x``.
|
||||
|
||||
.. _tagged default:
|
||||
.. |tagged default| replace:: `tagged default`_
|
||||
|
||||
tagged default
|
||||
A |tagged reference| whose *value* represents the value of a
|
||||
default argument.
|
||||
|
||||
.. _tagged lazy default:
|
||||
.. |tagged lazy default| replace:: `tagged lazy default`_
|
||||
|
||||
tagged lazy default
|
||||
A |tagged reference| whose *value*, when invoked with no
|
||||
arguments, computes a default argument value.
|
||||
|
||||
.. _intended argument type:
|
||||
.. |intended argument type| replace:: `intended argument type`_
|
||||
|
||||
intended argument type
|
||||
The *intended argument type* of a single-element |ArgumentPack|_ is the
|
||||
type of its element's *value*. The intended argument type of any other
|
||||
type ``X`` is ``X`` itself.
|
||||
|
||||
.. Note::
|
||||
|
||||
In this reference, we will use concept names (and other names)
|
||||
to describe both types and objects, depending on context. So
|
||||
for example, “an |ArgumentPack|_\ ” can refer to a type that
|
||||
models |ArgumentPack|_ *or* an object of such a type.
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Concepts
|
||||
========
|
||||
|
||||
This section describes the generic type concepts_ used by the Parameter library.
|
||||
|
||||
.. _concepts: ../../../../more/generic_programming.html#concept
|
||||
|
||||
|ArgumentPack|
|
||||
--------------
|
||||
|
||||
An |ArgumentPack| is a collection of |tagged reference|\ s to the
|
||||
actual arguments passed to a function.
|
||||
|
||||
Requirements
|
||||
............
|
||||
|
||||
In the table below,
|
||||
|
||||
* ``A`` is a model of |ArgumentPack|
|
||||
* ``x`` is an instance of ``A``
|
||||
* ``u`` is a |keyword object| of type ``K``
|
||||
* ``v`` is a |tagged default| with |tag type| ``L`` and *value* of type ``D``
|
||||
* ``w`` is a |tagged lazy default| with |tag type| ``M`` and *value* of type ``E const``
|
||||
* ``z`` is an |ArgumentPack| containing a single element (as created by |keyword|_\ ``<…>::operator=``)
|
||||
|
||||
Any exceptions are thrown from the invocation of ``w``\ 's *value*
|
||||
will be propagated to the caller.
|
||||
|
||||
.. table:: |ArgumentPack| requirements
|
||||
|
||||
+----------+-----------------------------+------------------+--------------------------------------+
|
||||
|Expression| Type |Requirements |Semantics/Notes |
|
||||
+==========+=============================+==================+======================================+
|
||||
|``x[u]`` |``binding<A,K>::type`` |``x`` contains an |Returns *b*\ 's *value* (by |
|
||||
| | |element *b* whose |reference). |
|
||||
| | ||kw|_ is ``K`` | |
|
||||
+----------+-----------------------------+------------------+--------------------------------------+
|
||||
|``x[u]`` |``binding<A,L,D>::type`` |*none* |If ``x`` contains an element *b* whose|
|
||||
| | | ||kw|_ is the same as ``u``\ 's, |
|
||||
| | | |returns *b*\ 's *value* (by |
|
||||
| | | |reference). Otherwise, returns ``u``\|
|
||||
| | | |'s *value*. |
|
||||
+----------+-----------------------------+------------------+--------------------------------------+
|
||||
|``x[w]`` |``lazy_binding<A,M,E>::type``|*none* |If ``x`` contains an element *b* whose|
|
||||
| | | ||kw|_ is the same as ``w``\ 's, |
|
||||
| | | |returns *b*\ 's *value* (by |
|
||||
| | | |reference). Otherwise, invokes ``w``\|
|
||||
| | | |'s *value* and returns the result. |
|
||||
+----------+-----------------------------+------------------+--------------------------------------+
|
||||
|``x, z`` |Model of |ArgumentPack| |*none* |Returns an |ArgumentPack|_ containing |
|
||||
| | | |all the elements of both ``x`` and |
|
||||
| | | |``z``. |
|
||||
+----------+-----------------------------+------------------+--------------------------------------+
|
||||
|
||||
|
||||
|
||||
.. _parameterspec:
|
||||
|
||||
|ParameterSpec|
|
||||
---------------
|
||||
|
||||
A |ParameterSpec| describes the type requirements for arguments
|
||||
corresponding to a given |kw|_ and indicates whether the argument
|
||||
is optional or required. The table below details the allowed forms
|
||||
and describes their condition for satisfaction by an actual
|
||||
argument type. In each row,
|
||||
|
||||
.. _conditions:
|
||||
|
||||
* ``K`` is the |ParameterSpec|\ 's |keyword tag type|
|
||||
* ``A`` is an |intended argument type| associated with ``K``, if any
|
||||
* ``F`` is a unary `MPL lambda expression`_
|
||||
|
||||
.. _`MPL lambda expression`: ../../../mpl/doc/refmanual/lambda-expression.html
|
||||
|
||||
.. table:: |ParameterSpec| allowed forms and conditions of satisfaction
|
||||
|
||||
+----------------------+--------------+--------------------------------+
|
||||
|Type |``A`` required|Condition ``A`` must satisfy |
|
||||
+======================+==============+================================+
|
||||
||keyword|_\ ``<K>`` |no |*n/a* |
|
||||
+----------------------+--------------+--------------------------------+
|
||||
||optional|_\ ``<K,F>``|no |``mpl::apply<F,A>::type::value``|
|
||||
| | |is ``true``. |
|
||||
+----------------------+--------------+--------------------------------+
|
||||
||required|_\ ``<K,F>``|yes |``mpl::apply<F,A>::type::value``|
|
||||
| | |is ``true``. |
|
||||
+----------------------+--------------+--------------------------------+
|
||||
|
||||
The information in a |ParameterSpec| is used to `limit`__ the
|
||||
arguments that will be matched by `forwarding functions`_.
|
||||
|
||||
__ overloadcontrol_
|
||||
.. _overloadcontrol: index.html#controlling-overload-resolution
|
||||
.. _forwarding functions: index.html#forwarding-functions
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Class Templates
|
||||
===============
|
||||
|
||||
.. |keyword| replace:: ``keyword``
|
||||
.. _keyword:
|
||||
|
||||
``keyword``
|
||||
-----------
|
||||
|
||||
The type of every |keyword object| is a specialization of |keyword|.
|
||||
|
||||
:Defined in: `boost/parameter/keyword.hpp`__
|
||||
|
||||
__ ../../../../boost/parameter/keyword.hpp
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
template <class Tag>
|
||||
struct keyword
|
||||
{
|
||||
template <class T> |ArgumentPack|_ `operator=`_\(T& value) const;
|
||||
template <class T> |ArgumentPack|_ `operator=`_\(T const& value) const;
|
||||
|
||||
template <class T> *tagged default* `operator|`_\(T& x) const;
|
||||
template <class T> *tagged default* `operator|`_\(T const& x) const;
|
||||
|
||||
template <class F> *tagged lazy default* `operator||`_\(F const&) const;
|
||||
|
||||
static keyword<Tag>& get_\();
|
||||
};
|
||||
|
||||
|
||||
.. |operator=| replace:: ``operator=``
|
||||
.. _operator=:
|
||||
|
||||
``operator=``
|
||||
.. parsed-literal::
|
||||
|
||||
template <class T> |ArgumentPack|_ operator=(T& value) const;
|
||||
template <class T> |ArgumentPack|_ operator=(T const& value) const;
|
||||
|
||||
:Requires: nothing
|
||||
|
||||
:Returns:
|
||||
an |ArgumentPack|_ containing a single |tagged reference| to
|
||||
``value`` with |kw|_ ``Tag``
|
||||
|
||||
.. _operator|:
|
||||
|
||||
``operator|``
|
||||
.. parsed-literal::
|
||||
|
||||
template <class T> *tagged default* operator|(T& x) const;
|
||||
template <class T> *tagged default* operator|(T const& x) const;
|
||||
|
||||
:Returns: a |tagged default| with *value* ``x`` and |kw|_ ``Tag``.
|
||||
|
||||
.. _operator||:
|
||||
|
||||
``operator||``
|
||||
.. parsed-literal::
|
||||
|
||||
template <class F> *tagged lazy default* operator||(F const& g) const;
|
||||
|
||||
:Requires: ``g()`` is valid, with type ``boost::``\ |result_of|_\
|
||||
``<F()>::type``. [#no_result_of]_
|
||||
|
||||
|
||||
:Returns: a |tagged lazy default| with *value* ``g`` and |kw|_ ``Tag``.
|
||||
|
||||
.. _get:
|
||||
|
||||
``get``
|
||||
.. parsed-literal::
|
||||
|
||||
static keyword<Tag>& get\();
|
||||
|
||||
:Returns: a “singleton instance”: the same object will be
|
||||
returned on each invocation of ``get()``.
|
||||
|
||||
:Thread Safety: ``get()`` can be called from multiple threads
|
||||
simultaneously.
|
||||
|
||||
``parameters``
|
||||
--------------
|
||||
|
||||
Provides an interface for assembling the actual arguments to a
|
||||
`forwarding function` into an |ArgumentPack|, in which any
|
||||
|positional| arguments will be tagged according to the
|
||||
corresponding template argument to ``parameters``.
|
||||
|
||||
.. _forwarding function: `forwarding functions`_
|
||||
|
||||
:Defined in: `boost/parameter/parameters.hpp`__
|
||||
|
||||
__ ../../../../boost/parameter/parameters.hpp
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
template <class P0 = *unspecified*, class P1 = *unspecified*, …class P\ β = *unspecified*>
|
||||
struct parameters
|
||||
{
|
||||
template <class A0, class A1 = *unspecified*, …class A\ β = *unspecified*>
|
||||
struct `match`_
|
||||
{
|
||||
typedef … type;
|
||||
};
|
||||
|
||||
template <class A0>
|
||||
|ArgumentPack|_ `operator()`_\(A0 const& a0) const;
|
||||
|
||||
template <class A0, class A1>
|
||||
|ArgumentPack|_ `operator()`_\(A0 const& a0, A1 const& a1) const; :vellipsis:`\
|
||||
.
|
||||
.
|
||||
.
|
||||
`
|
||||
template <class A0, class A1, …class A\ β>
|
||||
|ArgumentPack|_ `operator()`_\(A0 const& a0, A1 const& a1, …A\ β const& a\ β) const;
|
||||
};
|
||||
|
||||
|
||||
:Requires: ``P0``, ``P1``, … ``P``\ β are models of |ParameterSpec|_.
|
||||
|
||||
|
||||
.. Note::
|
||||
|
||||
In this section, ``R``\ *i* and ``K``\ *i* are defined as
|
||||
follows, for any argument type ``A``\ *i*:
|
||||
|
||||
|
||||
| ``R``\ *i* is ``A``\ *i*\ 's |intended argument type|
|
||||
|
|
||||
| if ``A``\ *i* is a result type of ``keyword<T>::``\ |operator=|_
|
||||
| then
|
||||
| ``K``\ *i* is ``T``
|
||||
| else
|
||||
| ``K``\ *i* is ``P``\ *i*\ 's |keyword tag type|.
|
||||
|
||||
|
||||
.. _match:
|
||||
|
||||
``match``
|
||||
A |Metafunction|_ used to remove a `forwarding function`_ from overload resolution.
|
||||
|
||||
:Returns: if ``P0``, ``P1``, …\ ``P``\ β are *satisfied* (see
|
||||
below), then ``parameters<P0,P1,…Pβ>``. Otherwise,
|
||||
``match<A0,A1,…Aβ>::type`` is not defined.
|
||||
|
||||
``P0``, ``P1``, …\ ``P``\ β are **satisfied** if, for
|
||||
every *j* in 0…β, either:
|
||||
|
||||
* ``P``\ *j* is the *unspecified* default
|
||||
* **or**, ``P``\ *j* is a specialization of |keyword|_,
|
||||
|
||||
* **or**, ``P``\ *j* is |optional|_ ``<X,F>`` and either
|
||||
|
||||
- ``X`` is not ``K``\ *i* for any *i*,
|
||||
- **or** ``X`` is some ``K``\ *i* and ``mpl::apply<F,R``\ *i*\
|
||||
``>::type::value`` is ``true``
|
||||
|
||||
* **or**, ``P``\ *j* is |required|_ ``<X,F>``, and
|
||||
|
||||
- ``X`` is some ``K``\ *i*, **and**
|
||||
- ``mpl::apply<F,R``\ *i*\ ``>::type::value`` is ``true``
|
||||
|
||||
.. _operator():
|
||||
|
||||
``operator()``
|
||||
.. parsed-literal::
|
||||
|
||||
template <class A0> |ArgumentPack|_ operator()(A0 const& a0) const; :vellipsis:`\
|
||||
.
|
||||
.
|
||||
.
|
||||
`
|
||||
template <class A0, …class A\ β> |ArgumentPack|_ `operator()`_\(A0 const& a0, …A\ β const& a\ β) const;
|
||||
|
||||
:Returns:
|
||||
An |ArgumentPack|_ containing, for each ``a``\ *i*,
|
||||
|
||||
- if ``a``\ *i*, is a single-element |ArgumentPack|, its element
|
||||
- Otherwise, a |tagged reference| with |kw|_ ``K``\ *i* and *value* ``a``\ *i*
|
||||
|
||||
|
||||
.. |optional| replace:: ``optional``
|
||||
.. |required| replace:: ``required``
|
||||
|
||||
.. _optional:
|
||||
.. _required:
|
||||
|
||||
``optional``, ``required``
|
||||
--------------------------
|
||||
|
||||
These templates describe the requirements on a function parameter.
|
||||
|
||||
:Defined in: `boost/parameter/parameters.hpp`__
|
||||
|
||||
__ ../../../../boost/parameter/parameters.hpp
|
||||
|
||||
:Specializations model: |ParameterSpec|_
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
template <class Tag, class Predicate = *unspecified*>
|
||||
struct optional;
|
||||
|
||||
template <class Tag, class Predicate = *unspecified*>
|
||||
struct required;
|
||||
|
||||
The default value of ``Predicate`` is an unspecified |Metafunction|_ that returns
|
||||
``mpl::true_`` for any argument.
|
||||
|
||||
.. |Metafunction| replace:: :concept:`Metafunction`
|
||||
.. _Metafunction: ../../../mpl/doc/refmanual/metafunction.html
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Metafunctions
|
||||
=============
|
||||
|
||||
A |Metafunction|_ is conceptually a function that operates on, and
|
||||
returns, C++ types.
|
||||
|
||||
``binding``
|
||||
-----------
|
||||
|
||||
Returns the result type of indexing an argument pack with a
|
||||
|keyword tag type| or with a |tagged default|.
|
||||
|
||||
:Defined n: `boost/parameter/binding.hpp`__
|
||||
|
||||
__ ../../../../boost/parameter/binding.hpp
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
template <class A, class K, class D = void>
|
||||
struct binding
|
||||
{
|
||||
typedef … type;
|
||||
};
|
||||
|
||||
:Requires: ``A`` is a model of |ArgumentPack|_.
|
||||
|
||||
:Returns: the reference type of the |tagged reference| in ``A``
|
||||
having |keyword tag type| ``K``, if any. If no such |tagged
|
||||
reference| exists, returns ``D``.
|
||||
|
||||
``lazy_binding``
|
||||
----------------
|
||||
|
||||
Returns the result type of indexing an argument pack with a |tagged
|
||||
lazy default|.
|
||||
|
||||
:Defined in:
|
||||
`boost/parameter/binding.hpp`__
|
||||
|
||||
__ ../../../../boost/parameter/binding.hpp
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
template <class A, class K, class F>
|
||||
struct lazy_binding
|
||||
{
|
||||
typedef … type;
|
||||
};
|
||||
|
||||
:Requires: ``A`` is a model of |ArgumentPack|_.
|
||||
|
||||
:Returns: the reference type of the |tagged reference| in ``A``
|
||||
having |keyword tag type| ``K``, if any. If no such |tagged
|
||||
reference| exists, returns ``boost::``\ |result_of|_\ ``<F()>::type``. [#no_result_of]_
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Code Generation Macros
|
||||
======================
|
||||
|
||||
Macros in this section can be used to ease the writing of code
|
||||
using the Parameter libray by eliminating repetitive boilerplate.
|
||||
|
||||
``BOOST_PARAMETER_FUN(r,n,l,h,p)``
|
||||
----------------------------------
|
||||
|
||||
Generates a sequence of `forwarding function`_ templates named
|
||||
``n``, with arities ranging from ``l`` to ``h`` , returning ``r``,
|
||||
and using ``p`` to control overload resolution and assign tags to
|
||||
positional arguments.
|
||||
|
||||
:Defined in: `boost/parameter/macros.hpp`__
|
||||
|
||||
__ ../../../../boost/parameter/macros.hpp
|
||||
|
||||
:Requires: ``l`` and ``h`` are nonnegative integer tokens such
|
||||
that ``l`` < ``h``
|
||||
|
||||
Generates
|
||||
.. parsed-literal::
|
||||
|
||||
template <class A1, class A2, …class A##\ **l**>
|
||||
r name(
|
||||
A1 const& a1, A2 const& a2, …A\ **l** const& x\ **l**
|
||||
, typename **p**::match<A1,A2,…A\ **l**>::type p = **p**\ ())
|
||||
{
|
||||
return **name**\ _with_named_params(**p**\ (x1,x2,…x\ **l**));
|
||||
}
|
||||
|
||||
template <class A1, class A2, …class A\ **l**, class A\ ##\ BOOST_PP_INC_\ (**l**)>
|
||||
r name(
|
||||
A1 const& a1, A2 const& a2, …A\ **l** const& x\ **l**
|
||||
, A\ ##\ BOOST_PP_INC_\ (**l**) const& x\ ##\ BOOST_PP_INC_\ (**l**)
|
||||
, typename **p**::match<A1,A2,…A\ **l**,A\ ##\ BOOST_PP_INC_\ (**l**)>::type p = **p**\ ())
|
||||
{
|
||||
return **name**\ _with_named_params(**p**\ (x1,x2,…x\ **l**,x\ ##\ BOOST_PP_INC_\ (**l**)));
|
||||
} :vellipsis:`\
|
||||
.
|
||||
.
|
||||
.
|
||||
`
|
||||
template <class A1, class A2, …class A\ **h**>
|
||||
r name(
|
||||
A1 const& a1, A2 const& a2, …A\ **h** const& x\ **h**
|
||||
, typename **p**::match<A1,A2,…A\ **h**>::type p = **p**\ ())
|
||||
{
|
||||
return **name**\ _with_named_params(**p**\ (a1,a2,…a\ **h**));
|
||||
}
|
||||
|
||||
|
||||
.. _BOOST_PP_INC: ../../../preprocessor/doc/ref/inc.html
|
||||
|
||||
``BOOST_PARAMETER_KEYWORD(n,k)``
|
||||
--------------------------------
|
||||
|
||||
Generates the declaration of a |keyword tag type| named ``k`` in
|
||||
namespace ``n``, and a corresponding |keyword object| definition in
|
||||
the enclosing namespace.
|
||||
|
||||
:Defined in: `boost/parameter/keyword.hpp`__
|
||||
|
||||
__ ../../../../boost/parameter/keyword.hpp
|
||||
|
||||
Generates
|
||||
.. parsed-literal::
|
||||
|
||||
namespace **n** { struct **k**; }
|
||||
namespace {
|
||||
boost::parameter::keyword<*tag-namespace*::**k**>& **k**
|
||||
= boost::parameter::keyword<*tag-namespace*::**k**>::get();
|
||||
}
|
||||
|
||||
``BOOST_PARAMETER_MATCH(p,a,x)``
|
||||
--------------------------------
|
||||
|
||||
Generates a defaulted parameter declaration for a `forwarding
|
||||
function`_.
|
||||
|
||||
:Defined in: `boost/parameter/match.hpp`__
|
||||
|
||||
__ ../../../../boost/parameter/match.hpp
|
||||
|
||||
:Requires: ``a`` is a `Boost.Preprocessor sequence`__
|
||||
of the form
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
(A0)(A1)…(A\ *n*)
|
||||
|
||||
__ http://www.boost.org/libs/preprocessor/doc/data.html
|
||||
|
||||
Generates
|
||||
.. parsed-literal::
|
||||
|
||||
typename **p**::match<**A0**\ ,\ **A1**\ …,\ **A**\ *n*>::type **x** = **p**\ ()
|
||||
|
||||
|
||||
Configuration Macros
|
||||
====================
|
||||
|
||||
``BOOST_PARAMETER_MAX_ARITY``
|
||||
-----------------------------
|
||||
|
||||
Determines the maximum number of arguments supported by the
|
||||
library. Will only be ``#defined`` by the library if it is not
|
||||
already ``#defined``.
|
||||
|
||||
.. |BOOST_PARAMETER_MAX_ARITY| replace:: ``BOOST_PARAMETER_MAX_ARITY``
|
||||
|
||||
:Defined in: `boost/parameter/config.hpp`__
|
||||
|
||||
__ ../../../../boost/parameter/config.hpp
|
||||
|
||||
:Default Value: ``5``
|
||||
|
||||
Tutorial
|
||||
========
|
||||
|
||||
Follow `this link`__ to the Boost.Parameter tutorial
|
||||
documentation.
|
||||
|
||||
__ index.html#tutorial
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
.. [#thread] References to tag objects may be initialized multiple
|
||||
times. This scenario can only occur in the presence of
|
||||
threading. Because the C++ standard doesn't consider threading,
|
||||
it doesn't explicitly allow or forbid multiple initialization of
|
||||
references. That said, it's hard to imagine an implementation
|
||||
where it could make a difference.
|
||||
|
||||
.. [#no_result_of] Where |BOOST_NO_RESULT_OF|_ is ``#defined``,
|
||||
``boost::``\ |result_of|_\ ``<F()>::type`` is replaced by
|
||||
``F::result_type``.
|
||||
|
||||
.. |result_of| replace:: ``result_of``
|
||||
.. _result_of: ../../../utility/utility.htm#result_of
|
||||
|
||||
.. |BOOST_NO_RESULT_OF| replace:: ``BOOST_NO_RESULT_OF``
|
||||
.. _BOOST_NO_RESULT_OF: ../../../utility/utility.htm#BOOST_NO_RESULT_OF
|
||||
12
index.html
12
index.html
@@ -1,12 +0,0 @@
|
||||
<!-- Copyright David Abrahams 2005. Distributed under the Boost -->
|
||||
<!-- Software License, Version 1.0. (See accompanying -->
|
||||
<!-- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -->
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0; URL=doc/html/index.html">
|
||||
</head>
|
||||
<body>
|
||||
Automatically loading index page... if nothing happens, please go to
|
||||
<a href="doc/html/index.html">doc/html/index.html</a>.
|
||||
</body>
|
||||
</html>
|
||||
15
test/Jamfile
15
test/Jamfile
@@ -1,15 +0,0 @@
|
||||
# Boost Parameter Library test Jamfile
|
||||
|
||||
subproject libs/parameter/test ;
|
||||
|
||||
# bring in rules for testing
|
||||
import testing ;
|
||||
|
||||
test-suite "parameter"
|
||||
: [ run basics.cpp ]
|
||||
[ run sfinae.cpp ]
|
||||
[ run macros.cpp ]
|
||||
[ run unnamed.cpp ]
|
||||
[ run efficiency.cpp ]
|
||||
[ compile unwrap_cv_reference.cpp ]
|
||||
;
|
||||
@@ -1,10 +0,0 @@
|
||||
# Boost Parameter Library test Jamfile
|
||||
|
||||
test-suite "parameter"
|
||||
: [ run basics.cpp ]
|
||||
[ run sfinae.cpp ]
|
||||
[ run macros.cpp ]
|
||||
[ run unnamed.cpp ]
|
||||
[ run efficiency.cpp ]
|
||||
[ compile unwrap_cv_reference.cpp ]
|
||||
;
|
||||
112
test/basics.cpp
112
test/basics.cpp
@@ -1,112 +0,0 @@
|
||||
// Copyright David Abrahams, Daniel Wallin 2003. Use, modification and
|
||||
// distribution is subject to the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <boost/parameter.hpp>
|
||||
#include <cassert>
|
||||
#include <string.h>
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/ref.hpp>
|
||||
|
||||
#include "basics.hpp"
|
||||
|
||||
|
||||
namespace test
|
||||
{
|
||||
// A separate function for getting the "value" key, so we can deduce
|
||||
// F and use lazy_binding on it.
|
||||
template <class Params, class F>
|
||||
typename boost::parameter::lazy_binding<Params,tag::value,F>::type
|
||||
extract_value(Params const& p, F const& f)
|
||||
{
|
||||
typename boost::parameter::lazy_binding<
|
||||
Params, tag::value, F
|
||||
>::type v = p[value || f ];
|
||||
return v;
|
||||
}
|
||||
|
||||
template<class Params>
|
||||
int f_impl(Params const& p)
|
||||
{
|
||||
typename boost::parameter::binding<Params, tag::name>::type
|
||||
n = p[name];
|
||||
|
||||
typename boost::parameter::binding<
|
||||
Params, tag::value, double
|
||||
>::type v = extract_value(p, boost::bind(&value_default));
|
||||
|
||||
typename boost::parameter::binding<
|
||||
Params, tag::index, int
|
||||
>::type i =
|
||||
#if BOOST_WORKAROUND(__DECCXX_VER, BOOST_TESTED_AT(60590042))
|
||||
p[test::index | 999];
|
||||
#else
|
||||
p[index | 999];
|
||||
#endif
|
||||
|
||||
p[tester](n,v,i);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
template<class Tester, class Name, class Value, class Index>
|
||||
int f(Tester const& t, const Name& name_,
|
||||
const Value& value_, const Index& index_)
|
||||
{
|
||||
return f_impl(f_parameters()(t, name_, value_, index_));
|
||||
}
|
||||
|
||||
template<class Tester, class Name, class Value>
|
||||
int f(Tester const& t, const Name& name_, const Value& value_)
|
||||
{
|
||||
return f_impl(f_parameters()(t, name_, value_));
|
||||
}
|
||||
|
||||
template<class Tester, class Name>
|
||||
int f(Tester const& t, const Name& name_)
|
||||
{
|
||||
return f_impl(f_parameters()(t, name_));
|
||||
}
|
||||
|
||||
template<class Params>
|
||||
int f_list(Params const& params)
|
||||
{
|
||||
return f_impl(params);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
using test::f;
|
||||
using test::f_list;
|
||||
using test::name;
|
||||
using test::value;
|
||||
using test::index;
|
||||
using test::tester;
|
||||
|
||||
f(
|
||||
test::values(S("foo"), S("bar"), S("baz"))
|
||||
, S("foo"), S("bar"), S("baz")
|
||||
);
|
||||
|
||||
int x = 56;
|
||||
f(
|
||||
test::values("foo", 666.222, 56)
|
||||
, index = boost::ref(x), name = "foo"
|
||||
);
|
||||
|
||||
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
|
||||
// No comma operator available on Borland
|
||||
f_list((
|
||||
tester = test::values("foo", 666.222, 56)
|
||||
, index = boost::ref(x)
|
||||
, name = "foo"
|
||||
));
|
||||
#endif
|
||||
|
||||
//f(index = 56, name = 55); // won't compile
|
||||
return 0;
|
||||
}
|
||||
|
||||
105
test/basics.hpp
105
test/basics.hpp
@@ -1,105 +0,0 @@
|
||||
// Copyright David Abrahams, Daniel Wallin 2005. Use, modification and
|
||||
// distribution is subject to the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifndef BASICS_050424_HPP
|
||||
#define BASICS_050424_HPP
|
||||
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/parameter/keyword.hpp>
|
||||
|
||||
namespace test {
|
||||
|
||||
BOOST_PARAMETER_KEYWORD(tag, name)
|
||||
BOOST_PARAMETER_KEYWORD(tag, value)
|
||||
BOOST_PARAMETER_KEYWORD(tag, index)
|
||||
BOOST_PARAMETER_KEYWORD(tag, tester)
|
||||
|
||||
using namespace boost::parameter;
|
||||
|
||||
struct f_parameters // vc6 is happier with inheritance than with a typedef
|
||||
: parameters<
|
||||
tag::tester
|
||||
, tag::name
|
||||
, tag::value
|
||||
, tag::index
|
||||
>
|
||||
{};
|
||||
|
||||
inline double value_default()
|
||||
{
|
||||
return 666.222;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline bool equal(T const& x, T const& y)
|
||||
{
|
||||
return x == y;
|
||||
}
|
||||
|
||||
inline bool equal(char const* s1, char const* s2)
|
||||
{
|
||||
return !strcmp(s1,s2);
|
||||
}
|
||||
|
||||
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
|
||||
inline bool equal(char* s1, char* s2)
|
||||
{
|
||||
return !strcmp(s1,s2);
|
||||
}
|
||||
#endif
|
||||
|
||||
template <class Name, class Value, class Index>
|
||||
struct values_t
|
||||
{
|
||||
values_t(Name const& n, Value const& v, Index const& i)
|
||||
: n(n), v(v), i(i)
|
||||
{}
|
||||
|
||||
template <class Name_, class Value_, class Index_>
|
||||
void operator()(Name_ const& n_, Value_ const& v_, Index_ const& i_) const
|
||||
{
|
||||
|
||||
// Only VC and its emulators fail this; they seem to have
|
||||
// problems with deducing the constness of string literal
|
||||
// arrays.
|
||||
#if defined(_MSC_VER) \
|
||||
&& (BOOST_WORKAROUND(BOOST_INTEL_CXX_VERSION, <= 700) \
|
||||
|| BOOST_WORKAROUND(BOOST_MSVC, < 1310)) \
|
||||
|| BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
|
||||
# else
|
||||
BOOST_STATIC_ASSERT((boost::is_same<Index,Index_>::value));
|
||||
BOOST_STATIC_ASSERT((boost::is_same<Value,Value_>::value));
|
||||
BOOST_STATIC_ASSERT((boost::is_same<Name,Name_>::value));
|
||||
#endif
|
||||
assert(equal(n, n_));
|
||||
assert(equal(v, v_));
|
||||
assert(equal(i, i_));
|
||||
}
|
||||
|
||||
Name const& n;
|
||||
Value const& v;
|
||||
Index const& i;
|
||||
};
|
||||
|
||||
template <class Name, class Value, class Index>
|
||||
inline values_t<Name,Value,Index>
|
||||
values(Name const& n, Value const& v, Index const& i)
|
||||
{
|
||||
return values_t<Name,Value,Index>(n,v,i);
|
||||
}
|
||||
|
||||
} // namespace test
|
||||
|
||||
// GCC2 has a problem with char (&)[] deduction, so we'll cast string
|
||||
// literals there.
|
||||
#undef S
|
||||
#if BOOST_WORKAROUND(__GNUC__, == 2) || BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
|
||||
# define S(s) (char const*)s
|
||||
#else
|
||||
# define S(s) s
|
||||
#endif
|
||||
|
||||
#endif // BASICS_050424_HPP
|
||||
|
||||
@@ -1,171 +0,0 @@
|
||||
// Copyright David Abrahams, Matthias Troyer, Michael Gauckler
|
||||
// 2005. Distributed under the Boost Software License, Version
|
||||
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <boost/parameter.hpp>
|
||||
#include <boost/timer.hpp>
|
||||
#include <iostream>
|
||||
|
||||
namespace test
|
||||
{
|
||||
//
|
||||
// This test measures the abstraction overhead of using the named
|
||||
// parameter interface. Some actual test results have been recorded
|
||||
// in timings.txt in this source file's directory, or
|
||||
// http://www.boost.org/libs/parameter/test/timings.txt.
|
||||
//
|
||||
// Caveats:
|
||||
//
|
||||
// 1. This test penalizes the named parameter library slightly, by
|
||||
// passing two arguments through the named interface, while
|
||||
// only passing one through the plain C++ interface.
|
||||
//
|
||||
// 2. This test does not measure the case where an ArgumentPack is
|
||||
// so large that it doesn't fit in the L1 cache.
|
||||
//
|
||||
// 3. Although we've tried to make this test as general as
|
||||
// possible, we are targeting it at a specific application.
|
||||
// Where that affects design decisions, we've noted it below in
|
||||
// ***...***.
|
||||
//
|
||||
// 4. The first time you run this program, the time may not be
|
||||
// representative because of disk and memory cache effects, so
|
||||
// always run it multiple times and ignore the first
|
||||
// measurement. This approach will also allow you to estimate
|
||||
// the statistical error of your test by observing the
|
||||
// variation in the valid times.
|
||||
//
|
||||
// 5. Try to run this program on a machine that's otherwise idle,
|
||||
// or other processes and even device hardware interrupts may
|
||||
// interfere by causing caches to be flushed.
|
||||
|
||||
// Accumulator function object with plain C++ interface
|
||||
template <class T>
|
||||
struct plain_weight_running_total
|
||||
{
|
||||
plain_weight_running_total()
|
||||
: sum()
|
||||
{}
|
||||
|
||||
void operator()(T w)
|
||||
{
|
||||
this->sum += w;
|
||||
}
|
||||
|
||||
T sum;
|
||||
};
|
||||
|
||||
BOOST_PARAMETER_KEYWORD(tag, weight)
|
||||
BOOST_PARAMETER_KEYWORD(tag, value)
|
||||
|
||||
// Accumulator function object with named parameter interface
|
||||
template <class T>
|
||||
struct named_param_weight_running_total
|
||||
{
|
||||
named_param_weight_running_total()
|
||||
: sum()
|
||||
{}
|
||||
|
||||
template <class ArgumentPack>
|
||||
void operator()(ArgumentPack const& variates)
|
||||
{
|
||||
this->sum += variates[weight];
|
||||
}
|
||||
|
||||
T sum;
|
||||
};
|
||||
|
||||
// This value is required to ensure that a smart compiler's dead
|
||||
// code elimination doesn't optimize away anything we're testing.
|
||||
// We'll use it to compute the return code of the executable to make
|
||||
// sure it's needed.
|
||||
double live_code;
|
||||
|
||||
// Call objects of the given Accumulator type repeatedly with x as
|
||||
// an argument.
|
||||
template <class Accumulator, class Arg>
|
||||
void hammer(Arg const& x)
|
||||
{
|
||||
// Strategy: because the sum in an accumulator after each call
|
||||
// depends on the previous value of the sum, the CPU's pipeline
|
||||
// might be stalled while waiting for the previous addition to
|
||||
// complete. Therefore, we allocate an array of accumulators,
|
||||
// and update them in sequence, so that there's no dependency
|
||||
// between adjacent addition operations.
|
||||
//
|
||||
// Additionally, if there were only one accumulator, the
|
||||
// compiler or CPU might decide to update the value in a
|
||||
// register rather that writing it back to memory. we want each
|
||||
// operation to at least update the L1 cache. *** Note: This
|
||||
// concern is specific to the particular application at which
|
||||
// we're targeting the test. ***
|
||||
|
||||
// This has to be at least as large as the number of
|
||||
// simultaneous accumulations that can be executing in the
|
||||
// compiler pipeline. A safe number here is larger than the
|
||||
// machine's maximum pipeline depth. If you want to test the L2
|
||||
// or L3 cache, or main memory, you can increase the size of
|
||||
// this array. 1024 is an upper limit on the pipeline depth of
|
||||
// current vector machines.
|
||||
const std::size_t number_of_accumulators = 1024;
|
||||
|
||||
Accumulator a[number_of_accumulators];
|
||||
|
||||
for (long iteration = 0; iteration < 1000000; ++iteration)
|
||||
{
|
||||
for (Accumulator* ap = a; ap < a + number_of_accumulators; ++ap)
|
||||
{
|
||||
(*ap)(x);
|
||||
}
|
||||
}
|
||||
|
||||
// Accumulate all the partial sums to avoid dead code
|
||||
// elimination.
|
||||
for (Accumulator* ap = a; ap < a + number_of_accumulators; ++ap)
|
||||
{
|
||||
live_code += ap->sum;
|
||||
}
|
||||
}
|
||||
|
||||
// Measure the time required to hammer accumulators of the given
|
||||
// type with the argument x.
|
||||
template <class Accumulator, class T>
|
||||
double measure(T const& x)
|
||||
{
|
||||
// Hammer accumulators a couple of times to ensure the
|
||||
// instruction cache is full of our test code, and that we don't
|
||||
// measure the cost of a page fault for accessing the data page
|
||||
// containing the memory where the accumulators will be
|
||||
// allocated
|
||||
hammer<Accumulator>(x);
|
||||
hammer<Accumulator>(x);
|
||||
|
||||
// Now start a timer
|
||||
boost::timer time;
|
||||
hammer<Accumulator>(x); // This time, we'll measure
|
||||
return time.elapsed();
|
||||
}
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace test;
|
||||
|
||||
std::cout
|
||||
<< "plain time: "
|
||||
<< measure<plain_weight_running_total<double> >(.1)
|
||||
<< std::endl;
|
||||
|
||||
std::cout
|
||||
<< "named parameter time: "
|
||||
<< measure<named_param_weight_running_total<double> >(
|
||||
(weight = .1, value = .2)
|
||||
)
|
||||
<< std::endl;
|
||||
|
||||
// This is ultimately responsible for preventing all the test code
|
||||
// from being optimized away. Change this to return 0 and you
|
||||
// unplug the whole test's life support system.
|
||||
return live_code < 0.;
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
// Copyright David Abrahams, Daniel Wallin 2003. Use, modification and
|
||||
// distribution is subject to the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <boost/parameter.hpp>
|
||||
#include <boost/parameter/macros.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/ref.hpp>
|
||||
#include <cassert>
|
||||
#include <string.h>
|
||||
|
||||
#include "basics.hpp"
|
||||
|
||||
namespace test
|
||||
{
|
||||
|
||||
BOOST_PARAMETER_FUN(int, f, 2, 4, f_parameters)
|
||||
{
|
||||
p[tester](
|
||||
p[name]
|
||||
, p[value || boost::bind(&value_default) ]
|
||||
#if BOOST_WORKAROUND(__DECCXX_VER, BOOST_TESTED_AT(60590042))
|
||||
, p[test::index | 999 ]
|
||||
#else
|
||||
, p[index | 999 ]
|
||||
#endif
|
||||
);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
} // namespace test
|
||||
|
||||
int main()
|
||||
{
|
||||
using test::f;
|
||||
using test::name;
|
||||
using test::value;
|
||||
using test::index;
|
||||
using test::tester;
|
||||
|
||||
f(
|
||||
test::values(S("foo"), S("bar"), S("baz"))
|
||||
, S("foo"), S("bar"), S("baz")
|
||||
);
|
||||
|
||||
int x = 56;
|
||||
f(
|
||||
test::values("foo", 666.222, 56)
|
||||
, index = boost::ref(x), name = "foo"
|
||||
);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
105
test/sfinae.cpp
105
test/sfinae.cpp
@@ -1,105 +0,0 @@
|
||||
// Copyright David Abrahams, Daniel Wallin 2003. Use, modification and
|
||||
// distribution is subject to the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/parameter.hpp>
|
||||
#include <boost/parameter/match.hpp>
|
||||
#include <cassert>
|
||||
#include <string>
|
||||
#include <boost/type_traits/is_convertible.hpp>
|
||||
#include <iostream>
|
||||
|
||||
#ifndef BOOST_NO_SFINAE
|
||||
# include <boost/utility/enable_if.hpp>
|
||||
# include <boost/type_traits/is_same.hpp>
|
||||
#endif
|
||||
|
||||
namespace test
|
||||
{
|
||||
BOOST_PARAMETER_KEYWORD(keywords,name)
|
||||
BOOST_PARAMETER_KEYWORD(keywords,value)
|
||||
|
||||
using namespace boost::parameter;
|
||||
|
||||
struct f_parameters
|
||||
: parameters<
|
||||
optional<
|
||||
keywords::name
|
||||
, boost::is_convertible<boost::mpl::_, std::string>
|
||||
>
|
||||
, optional<
|
||||
keywords::value
|
||||
, boost::is_convertible<boost::mpl::_, float>
|
||||
>
|
||||
>
|
||||
{};
|
||||
|
||||
template <class T> struct not_implemented;
|
||||
|
||||
template<class P>
|
||||
void f_impl(P const& p)
|
||||
{
|
||||
std::string s = p[name | "bar"];
|
||||
float v = p[value | 3.f];
|
||||
|
||||
assert(s == "foo");
|
||||
assert(v == 3.f);
|
||||
}
|
||||
|
||||
void f()
|
||||
{
|
||||
f_impl(f_parameters()());
|
||||
}
|
||||
|
||||
using boost::parameter::aux::void_;
|
||||
|
||||
template<class A0>
|
||||
void f(
|
||||
A0 const& a0
|
||||
, BOOST_PARAMETER_MATCH(f_parameters, (A0), args))
|
||||
{
|
||||
f_impl(args(a0));
|
||||
}
|
||||
|
||||
template<class A0, class A1>
|
||||
void f(
|
||||
A0 const& a0, A1 const& a1
|
||||
, BOOST_PARAMETER_MATCH(f_parameters,(A0)(A1), args))
|
||||
{
|
||||
f_impl(args(a0, a1));
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_SFINAE
|
||||
// On compilers that actually support SFINAE, add another overload
|
||||
// that is an equally good match and can only be in the overload set
|
||||
// when the others are not. This tests that the SFINAE is actually
|
||||
// working. On all other compilers we're just checking that
|
||||
// everything about SFINAE-enabled code will work, except of course
|
||||
// the SFINAE.
|
||||
template<class A0, class A1>
|
||||
typename boost::enable_if<boost::is_same<int,A0>, int>::type
|
||||
f(A0 const& a0, A1 const& a1)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
} // namespace test
|
||||
|
||||
int main()
|
||||
{
|
||||
using test::name;
|
||||
using test::value;
|
||||
using test::f;
|
||||
|
||||
f("foo");
|
||||
f("foo", 3.f);
|
||||
f(value = 3.f, name = "foo");
|
||||
|
||||
#ifndef BOOST_NO_SFINAE
|
||||
return f(3, 4);
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
# Copyright David Abrahams 2005. Distributed under the Boost
|
||||
# Software License, Version 1.0. (See accompanying
|
||||
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
----------------- Test #1 ----------------
|
||||
Testers:
|
||||
Matthias Troyer, Michael Gauckler, David Abrahams
|
||||
|
||||
Date:
|
||||
2005-09-09
|
||||
|
||||
Compiler:
|
||||
Cygwin g++-4.0.0
|
||||
|
||||
Command lines:
|
||||
g++ -c -o efficiency.o -ftemplate-depth-100 -funroll-loops \
|
||||
-O3 -finline-functions -Wno-inline -DNDEBUG efficiency.cpp
|
||||
|
||||
g++ -o efficiency.exe efficiency.o -Wl,--strip-all
|
||||
|
||||
efficiency && efficiency && efficiency
|
||||
|
||||
Machine:
|
||||
Dell Inspiron 9300
|
||||
Intel(R) Pentium(R) M processor 2.00GHz
|
||||
Running on 230 volts AC power
|
||||
|
||||
Timings:
|
||||
Run #1 results discarded per standard practice
|
||||
|
||||
Run #2
|
||||
plain time: 0.75
|
||||
named parameter time: 0.734
|
||||
|
||||
Run #3
|
||||
plain time: 0.781
|
||||
named parameter time: 0.766
|
||||
|
||||
-----------------------------------------
|
||||
|
||||
@@ -1,75 +0,0 @@
|
||||
// Copyright David Abrahams, Daniel Wallin 2003. Use, modification and
|
||||
// distribution is subject to the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <boost/parameter.hpp>
|
||||
#include <boost/parameter/match.hpp>
|
||||
#include <cassert>
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/ref.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/type_traits/is_convertible.hpp>
|
||||
#include <string>
|
||||
|
||||
namespace test
|
||||
{
|
||||
using namespace boost::parameter;
|
||||
namespace mpl = boost::mpl;
|
||||
|
||||
BOOST_PARAMETER_KEYWORD(tag, name)
|
||||
BOOST_PARAMETER_KEYWORD(tag, value)
|
||||
|
||||
struct g_parameters
|
||||
: parameters<
|
||||
unnamed<tag::name, boost::is_convertible<mpl::_, std::string> >
|
||||
, unnamed<tag::value, boost::is_convertible<mpl::_, float> >
|
||||
>
|
||||
{};
|
||||
|
||||
|
||||
// Keeping this out here avoids an ICE with vc-6.x
|
||||
std::string const foo("foo");
|
||||
|
||||
template<class Params>
|
||||
int g_(Params const& p)
|
||||
{
|
||||
assert(p[name] == foo);
|
||||
assert(p[value] == 3.14f);
|
||||
return 1;
|
||||
}
|
||||
|
||||
template<class A0>
|
||||
int g(A0 const& a0, BOOST_PARAMETER_MATCH(g_parameters, (A0), args))
|
||||
{
|
||||
return g_(args(a0));
|
||||
}
|
||||
|
||||
template<class A0, class A1>
|
||||
int g(A0 const& a0, A1 const& a1, BOOST_PARAMETER_MATCH(g_parameters, (A0)(A1), args))
|
||||
{
|
||||
return g_(args(a0, a1));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#include <typeinfo>
|
||||
#include <iostream>
|
||||
|
||||
int main()
|
||||
{
|
||||
using test::g;
|
||||
using test::name;
|
||||
using test::value;
|
||||
|
||||
g("foo", 3.14f);
|
||||
g(3.14f, "foo");
|
||||
|
||||
g(value = 3.14f, "foo");
|
||||
g(name = "foo", 3.14f);
|
||||
g(3.14f, name = "foo");
|
||||
g(name = "foo", value = 3.14f);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
// Copyright David Abrahams 2005. Distributed under the Boost
|
||||
// Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <boost/parameter/aux_/unwrap_cv_reference.hpp>
|
||||
#include <boost/mpl/assert.hpp>
|
||||
#include <boost/ref.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
|
||||
namespace test
|
||||
{
|
||||
using namespace boost::parameter::aux;
|
||||
using namespace boost;
|
||||
struct foo {};
|
||||
|
||||
BOOST_MPL_ASSERT((is_same<unwrap_cv_reference<int>::type,int>));
|
||||
BOOST_MPL_ASSERT((is_same<unwrap_cv_reference<int const>::type,int const>));
|
||||
BOOST_MPL_ASSERT((is_same<unwrap_cv_reference<int volatile>::type,int volatile>));
|
||||
BOOST_MPL_ASSERT((is_same<unwrap_cv_reference<int const volatile>::type,int const volatile>));
|
||||
|
||||
BOOST_MPL_ASSERT((is_same<unwrap_cv_reference<foo>::type,foo>));
|
||||
BOOST_MPL_ASSERT((is_same<unwrap_cv_reference<foo const>::type,foo const>));
|
||||
BOOST_MPL_ASSERT((is_same<unwrap_cv_reference<foo volatile>::type,foo volatile>));
|
||||
BOOST_MPL_ASSERT((is_same<unwrap_cv_reference<foo const volatile>::type,foo const volatile>));
|
||||
|
||||
BOOST_MPL_ASSERT((is_same<unwrap_cv_reference<reference_wrapper<foo> >::type,foo>));
|
||||
BOOST_MPL_ASSERT((is_same<unwrap_cv_reference<reference_wrapper<foo> const>::type,foo>));
|
||||
BOOST_MPL_ASSERT((is_same<unwrap_cv_reference<reference_wrapper<foo> volatile>::type,foo>));
|
||||
BOOST_MPL_ASSERT((is_same<unwrap_cv_reference<reference_wrapper<foo> const volatile>::type,foo>));
|
||||
}
|
||||
Reference in New Issue
Block a user