Compare commits

...

19 Commits

Author SHA1 Message Date
Dave Abrahams
8ea9931a55 Every ArgumentPack is now a valid MPL Forward Sequence.
[SVN r32442]
2006-01-27 20:57:33 +00:00
Dave Abrahams
bb4b55b7a7 Every ArgumentPack is now a valid MPL Forward Sequence.
[SVN r32427]
2006-01-27 02:28:26 +00:00
Dave Abrahams
d3affb9173 VC6 workaround
[SVN r32426]
2006-01-27 01:55:17 +00:00
Dave Abrahams
c8dbe27c0d Workarounds for vc6 et al.
[SVN r32425]
2006-01-27 01:25:39 +00:00
Dave Abrahams
0becf3904e Workarounds for Borland and GCC2
[SVN r32420]
2006-01-26 17:00:06 +00:00
Dave Abrahams
ca0899bf88 Workarounds for Borland
[SVN r32410]
2006-01-24 22:35:49 +00:00
Dave Abrahams
01a95f4f5a workaround vc6 ICE
[SVN r32409]
2006-01-24 22:12:13 +00:00
Eric Niebler
3d432ba007 add test_general
[SVN r32318]
2006-01-13 19:05:59 +00:00
Eric Niebler
c637e24175 simple patch to make libs/parameter/test/python/general.cpp compile
[SVN r32315]
2006-01-13 18:41:43 +00:00
Eric Niebler
6a39e83db0 add some python test scripts for simple.cpp and accumulator.cpp
[SVN r32223]
2006-01-04 23:35:53 +00:00
Eric Niebler
76f55205e6 add missing return statements
[SVN r32222]
2006-01-04 23:34:32 +00:00
Daniel Wallin
98f43217b2 Added accumulator sample.
[SVN r32130]
2005-12-22 00:59:40 +00:00
Daniel Wallin
1656f8badd More work on python binding.
[SVN r32129]
2005-12-22 00:58:22 +00:00
Daniel Wallin
5479e72b94 Added runtime determined default's. For use with python wrapping code.
[SVN r32128]
2005-12-22 00:57:53 +00:00
Eric Niebler
914d36970c fix spelling error
[SVN r32110]
2005-12-19 18:21:41 +00:00
Daniel Wallin
e1fce8fbc5 Test for general binding of parameter-enabled functions.
[SVN r31976]
2005-12-10 17:42:26 +00:00
Daniel Wallin
d5378a587a General 2^N case of binding parameter-enabled functions.
[SVN r31975]
2005-12-10 17:40:48 +00:00
Daniel Wallin
9dc905e4c6 Boost.Parameter->BPL initial checkin
[SVN r31843]
2005-11-30 23:18:30 +00:00
nobody
68786750ca This commit was manufactured by cvs2svn to create branch
'parameter-python'.

[SVN r31672]
2005-11-15 20:50:59 +00:00
32 changed files with 2235 additions and 221 deletions

View File

@@ -620,11 +620,8 @@ namespace graphs
void depth_first_search(A0 const& a0, A1 const& a1)
{
core::depth_first_search(dfs_params()(a0,a1));
} <span class="vellipsis">
.
.
.
</span>
}
<span class="doublesize"></span>
template &lt;class A0, class A1, …class A4&gt;
void depth_first_search(A0 const&amp; a0, A1 const&amp; a1, …A4 const&amp; a4)
{
@@ -791,11 +788,8 @@ namespace graphs
, typename dfs_params::match&lt;A0,A1&gt;::type p = dfs_params())
{
core::depth_first_search(<strong>p</strong>(a0,a1));
} <span class="vellipsis">
.
.
.
</span>
}
<span class="doublesize"></span>
template &lt;class A0, class A1, …class A4&gt;
void depth_first_search(
A0 const&amp; a0, A1 const&amp; a1, …A4 const&amp; A4
@@ -839,11 +833,8 @@ namespace graphs
, <strong>BOOST_PARAMETER_MATCH(dfs_params, (A0)(A1), p)</strong>)
{
core::depth_first_search(p(a0,a1));
} <span class="vellipsis">
.
.
.
</span>
}
<span class="doublesize"></span>
template &lt;class A0, class A1, …class A4&gt;
void depth_first_search(
A0 const&amp; a0, A1 const&amp; a1, …A4 const&amp; A4
@@ -926,7 +917,7 @@ typename parameter::binding&lt;
];
</pre>
<div class="sidebar">
<p class="first sidebar-title">Mnemonics</p>
<p class="first sidebar-title">Memnonics</p>
<p class="last">To remember the difference between <tt class="docutils literal"><span class="pre">|</span></tt> and <tt class="docutils literal"><span class="pre">||</span></tt>, recall that
<tt class="docutils literal"><span class="pre">||</span></tt> normally uses short-circuit evaluation: its second
argument is only evaluated if its first argument is <tt class="docutils literal"><span class="pre">false</span></tt>.
@@ -1145,12 +1136,12 @@ define</p>
typedef T result_type;
template &lt;class A1, class A2&gt;
T operator()(A1 a1, A2 a2) { return T(a1,a2); }
T operator() { return T(a1,a2); }
};
and use `Boost.Bind`_ to generate the function object::
and use Boost.Bind_ to generate the function object::
boost::bind(construct2&lt;default_color_map&gt;(),num_vertices(g),i)
boost::bind(construct2&lt;default_color_map&gt;,num_vertices(g),i)
</pre>
</td></tr>
</tbody>
@@ -1191,7 +1182,7 @@ information on SFINAE.</td></tr>
</div>
<hr class="docutils footer" />
<div class="footer">
Generated on: 2005-08-13 01:16 UTC.
Generated on: 2005-07-28 16:32 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>

View File

@@ -34,66 +34,66 @@ or copy at <a class="reference" href="http://www.boost.org/LICENSE_1_0.txt">http
<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&nbsp;&nbsp;&nbsp;Preliminaries</a><ul class="auto-toc">
<li><a class="reference" href="#namespaces" id="id24" name="id24">1.1&nbsp;&nbsp;&nbsp;Namespaces</a></li>
<li><a class="reference" href="#exceptions" id="id25" name="id25">1.2&nbsp;&nbsp;&nbsp;Exceptions</a></li>
<li><a class="reference" href="#thread-safety" id="id26" name="id26">1.3&nbsp;&nbsp;&nbsp;Thread Safety</a></li>
<li><a class="reference" href="#typography" id="id27" name="id27">1.4&nbsp;&nbsp;&nbsp;Typography</a></li>
<li><a class="reference" href="#preliminaries" id="id24" name="id24">1&nbsp;&nbsp;&nbsp;Preliminaries</a><ul class="auto-toc">
<li><a class="reference" href="#namespaces" id="id25" name="id25">1.1&nbsp;&nbsp;&nbsp;Namespaces</a></li>
<li><a class="reference" href="#exceptions" id="id26" name="id26">1.2&nbsp;&nbsp;&nbsp;Exceptions</a></li>
<li><a class="reference" href="#thread-safety" id="id27" name="id27">1.3&nbsp;&nbsp;&nbsp;Thread Safety</a></li>
<li><a class="reference" href="#typography" id="id28" name="id28">1.4&nbsp;&nbsp;&nbsp;Typography</a></li>
</ul>
</li>
<li><a class="reference" href="#terminology" id="id28" name="id28">2&nbsp;&nbsp;&nbsp;Terminology</a></li>
<li><a class="reference" href="#concepts" id="id29" name="id29">3&nbsp;&nbsp;&nbsp;Concepts</a><ul class="auto-toc">
<li><a class="reference" href="#argumentpack" id="id30" name="id30">3.1&nbsp;&nbsp;&nbsp;<span class="concept">ArgumentPack</span></a></li>
<li><a class="reference" href="#id4" id="id31" name="id31">3.2&nbsp;&nbsp;&nbsp;<span class="concept">ParameterSpec</span></a></li>
<li><a class="reference" href="#terminology" id="id29" name="id29">2&nbsp;&nbsp;&nbsp;Terminology</a></li>
<li><a class="reference" href="#concepts" id="id30" name="id30">3&nbsp;&nbsp;&nbsp;Concepts</a><ul class="auto-toc">
<li><a class="reference" href="#argumentpack" id="id31" name="id31">3.1&nbsp;&nbsp;&nbsp;<span class="concept">ArgumentPack</span></a></li>
<li><a class="reference" href="#id5" id="id32" name="id32">3.2&nbsp;&nbsp;&nbsp;<span class="concept">ParameterSpec</span></a></li>
</ul>
</li>
<li><a class="reference" href="#class-templates" id="id32" name="id32">4&nbsp;&nbsp;&nbsp;Class Templates</a><ul class="auto-toc">
<li><a class="reference" href="#id6" id="id33" name="id33">4.1&nbsp;&nbsp;&nbsp;<tt class="docutils literal"><span class="pre">keyword</span></tt></a></li>
<li><a class="reference" href="#parameters" id="id34" name="id34">4.2&nbsp;&nbsp;&nbsp;<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&nbsp;&nbsp;&nbsp;<tt class="docutils literal"><span class="pre">optional</span></tt>, <tt class="docutils literal"><span class="pre">required</span></tt></a></li>
<li><a class="reference" href="#class-templates" id="id33" name="id33">4&nbsp;&nbsp;&nbsp;Class Templates</a><ul class="auto-toc">
<li><a class="reference" href="#id7" id="id34" name="id34">4.1&nbsp;&nbsp;&nbsp;<tt class="docutils literal"><span class="pre">keyword</span></tt></a></li>
<li><a class="reference" href="#parameters" id="id35" name="id35">4.2&nbsp;&nbsp;&nbsp;<tt class="docutils literal"><span class="pre">parameters</span></tt></a></li>
<li><a class="reference" href="#optional-required" id="id36" name="id36">4.3&nbsp;&nbsp;&nbsp;<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&nbsp;&nbsp;&nbsp;Metafunctions</a><ul class="auto-toc">
<li><a class="reference" href="#binding" id="id37" name="id37">5.1&nbsp;&nbsp;&nbsp;<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&nbsp;&nbsp;&nbsp;<tt class="docutils literal"><span class="pre">lazy_binding</span></tt></a></li>
<li><a class="reference" href="#metafunctions" id="id37" name="id37">5&nbsp;&nbsp;&nbsp;Metafunctions</a><ul class="auto-toc">
<li><a class="reference" href="#binding" id="id38" name="id38">5.1&nbsp;&nbsp;&nbsp;<tt class="docutils literal"><span class="pre">binding</span></tt></a></li>
<li><a class="reference" href="#lazy-binding" id="id39" name="id39">5.2&nbsp;&nbsp;&nbsp;<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&nbsp;&nbsp;&nbsp;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&nbsp;&nbsp;&nbsp;<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&nbsp;&nbsp;&nbsp;<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&nbsp;&nbsp;&nbsp;<tt class="docutils literal"><span class="pre">BOOST_PARAMETER_MATCH(p,a,x)</span></tt></a></li>
<li><a class="reference" href="#code-generation-macros" id="id40" name="id40">6&nbsp;&nbsp;&nbsp;Code Generation Macros</a><ul class="auto-toc">
<li><a class="reference" href="#boost-parameter-fun-r-n-l-h-p" id="id41" name="id41">6.1&nbsp;&nbsp;&nbsp;<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="id42" name="id42">6.2&nbsp;&nbsp;&nbsp;<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="id43" name="id43">6.3&nbsp;&nbsp;&nbsp;<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&nbsp;&nbsp;&nbsp;Configuration Macros</a><ul class="auto-toc">
<li><a class="reference" href="#boost-parameter-max-arity" id="id44" name="id44">7.1&nbsp;&nbsp;&nbsp;<tt class="docutils literal"><span class="pre">BOOST_PARAMETER_MAX_ARITY</span></tt></a></li>
<li><a class="reference" href="#configuration-macros" id="id44" name="id44">7&nbsp;&nbsp;&nbsp;Configuration Macros</a><ul class="auto-toc">
<li><a class="reference" href="#boost-parameter-max-arity" id="id45" name="id45">7.1&nbsp;&nbsp;&nbsp;<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&nbsp;&nbsp;&nbsp;Tutorial</a></li>
<li><a class="reference" href="#tutorial" id="id46" name="id46">8&nbsp;&nbsp;&nbsp;Tutorial</a></li>
</ul>
</div>
<hr class="docutils" />
<div class="section" id="preliminaries">
<h1><a class="toc-backref" href="#id23" name="preliminaries">1&nbsp;&nbsp;&nbsp;Preliminaries</a></h1>
<h1><a class="toc-backref" href="#id24" name="preliminaries">1&nbsp;&nbsp;&nbsp;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&nbsp;&nbsp;&nbsp;Namespaces</a></h2>
<h2><a class="toc-backref" href="#id25" name="namespaces">1.1&nbsp;&nbsp;&nbsp;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&nbsp;&nbsp;&nbsp;Exceptions</a></h2>
<h2><a class="toc-backref" href="#id26" name="exceptions">1.2&nbsp;&nbsp;&nbsp;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&nbsp;&nbsp;&nbsp;Thread Safety</a></h2>
<h2><a class="toc-backref" href="#id27" name="thread-safety">1.3&nbsp;&nbsp;&nbsp;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&nbsp;&nbsp;&nbsp;Typography</a></h2>
<h2><a class="toc-backref" href="#id28" name="typography">1.4&nbsp;&nbsp;&nbsp;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
@@ -106,7 +106,7 @@ argument in the result.</p>
</div>
<hr class="docutils" />
<div class="section" id="terminology">
<h1><a class="toc-backref" href="#id28" name="terminology">2&nbsp;&nbsp;&nbsp;Terminology</a></h1>
<h1><a class="toc-backref" href="#id29" name="terminology">2&nbsp;&nbsp;&nbsp;Terminology</a></h1>
<span class="target" id="kw"></span><dl class="docutils">
<dt>keyword</dt>
<dd>The name of a function parameter.</dd>
@@ -165,12 +165,13 @@ models <a class="reference" href="#argumentpack"><span class="concept">ArgumentP
</div>
<hr class="docutils" />
<div class="section" id="concepts">
<h1><a class="toc-backref" href="#id29" name="concepts">3&nbsp;&nbsp;&nbsp;Concepts</a></h1>
<h1><a class="toc-backref" href="#id30" name="concepts">3&nbsp;&nbsp;&nbsp;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&nbsp;&nbsp;&nbsp;<span class="concept">ArgumentPack</span></a></h2>
<h2><a class="toc-backref" href="#id31" name="argumentpack">3.1&nbsp;&nbsp;&nbsp;<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>
actual arguments passed to a function. Every <span class="concept">ArgumentPack</span> is
also a valid MPL <a class="reference" href="../../../mpl/doc/refmanual/forward-sequence.html"><span class="concept">Forward Sequence</span></a> consisting of the <a class="reference" href="#keyword-tag-type">keyword tag type</a>s in its <a class="reference" href="#tagged-reference">tagged reference</a>s.</p>
<div class="section" id="requirements">
<h3><a name="requirements">Requirements</a></h3>
<p>In the table below,</p>
@@ -235,8 +236,8 @@ all the elements of both <tt class="docutils literal"><span class="pre">x</span>
</table>
</div>
</div>
<div class="section" id="id4">
<h2><a class="toc-backref" href="#id31" name="id4">3.2&nbsp;&nbsp;&nbsp;<span class="target" id="parameterspec"></span><span class="concept">ParameterSpec</span></a></h2>
<div class="section" id="id5">
<h2><a class="toc-backref" href="#id32" name="id5">3.2&nbsp;&nbsp;&nbsp;<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
@@ -283,9 +284,9 @@ arguments that will be matched by <a class="reference" href="index.html#forwardi
</div>
<hr class="docutils" />
<div class="section" id="class-templates">
<h1><a class="toc-backref" href="#id32" name="class-templates">4&nbsp;&nbsp;&nbsp;Class Templates</a></h1>
<div class="section" id="id6">
<h2><a class="toc-backref" href="#id33" name="id6">4.1&nbsp;&nbsp;&nbsp;<span class="target" id="keyword"></span><tt class="docutils literal"><span class="pre">keyword</span></tt></a></h2>
<h1><a class="toc-backref" href="#id33" name="class-templates">4&nbsp;&nbsp;&nbsp;Class Templates</a></h1>
<div class="section" id="id7">
<h2><a class="toc-backref" href="#id34" name="id7">4.1&nbsp;&nbsp;&nbsp;<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" />
@@ -302,10 +303,10 @@ struct keyword
template &lt;class T&gt; <a class="reference" href="#argumentpack"><span class="concept">ArgumentPack</span></a> <a class="reference" href="#operator">operator=</a>(T&amp; value) const;
template &lt;class T&gt; <a class="reference" href="#argumentpack"><span class="concept">ArgumentPack</span></a> <a class="reference" href="#operator">operator=</a>(T const&amp; value) const;
template &lt;class T&gt; <em>tagged default</em> <a class="reference" href="#id8">operator|</a>(T&amp; x) const;
template &lt;class T&gt; <em>tagged default</em> <a class="reference" href="#id8">operator|</a>(T const&amp; x) const;
template &lt;class T&gt; <em>tagged default</em> <a class="reference" href="#id9">operator|</a>(T&amp; x) const;
template &lt;class T&gt; <em>tagged default</em> <a class="reference" href="#id9">operator|</a>(T const&amp; x) const;
template &lt;class F&gt; <em>tagged lazy default</em> <a class="reference" href="#id9">operator||</a>(F const&amp;) const;
template &lt;class F&gt; <em>tagged lazy default</em> <a class="reference" href="#id10">operator||</a>(F const&amp;) const;
static keyword&lt;Tag&gt;&amp; <a class="reference" href="#get">get</a>();
};
@@ -329,7 +330,7 @@ template &lt;class T&gt; <a class="reference" href="#argumentpack"><span class="
</table>
</dd>
</dl>
<span class="target" id="id8"></span><dl class="docutils">
<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 &lt;class T&gt; <em>tagged default</em> operator|(T&amp; x) const;
@@ -345,7 +346,7 @@ template &lt;class T&gt; <em>tagged default</em> operator|(T const&amp; x) const
</table>
</dd>
</dl>
<span class="target" id="id9"></span><dl class="docutils">
<span class="target" id="id10"></span><dl class="docutils">
<dt><tt class="docutils literal"><span class="pre">operator||</span></tt></dt>
<dd><pre class="first literal-block">
template &lt;class F&gt; <em>tagged lazy default</em> operator||(F const&amp; g) const;
@@ -354,7 +355,7 @@ template &lt;class F&gt; <em>tagged lazy default</em> operator||(F const&amp; g)
<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">&lt;F()&gt;::type</span></tt>.<a class="footnote-reference" href="#no-result-of" id="id10" name="id10"><sup>2</sup></a></td>
<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">&lt;F()&gt;::type</span></tt>.<a class="footnote-reference" href="#no-result-of" id="id11" name="id11"><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>
@@ -383,7 +384,7 @@ simultaneously.</td>
</dl>
</div>
<div class="section" id="parameters">
<h2><a class="toc-backref" href="#id34" name="parameters">4.2&nbsp;&nbsp;&nbsp;<tt class="docutils literal"><span class="pre">parameters</span></tt></a></h2>
<h2><a class="toc-backref" href="#id35" name="parameters">4.2&nbsp;&nbsp;&nbsp;<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
@@ -407,16 +408,13 @@ struct parameters
};
template &lt;class A0&gt;
<a class="reference" href="#argumentpack"><span class="concept">ArgumentPack</span></a> <a class="reference" href="#id12">operator()</a>(A0 const&amp; a0) const;
<a class="reference" href="#argumentpack"><span class="concept">ArgumentPack</span></a> <a class="reference" href="#id13">operator()</a>(A0 const&amp; a0) const;
template &lt;class A0, class A1&gt;
<a class="reference" href="#argumentpack"><span class="concept">ArgumentPack</span></a> <a class="reference" href="#id12">operator()</a>(A0 const&amp; a0, A1 const&amp; a1) const; <span class="vellipsis">
.
.
.
</span>
<a class="reference" href="#argumentpack"><span class="concept">ArgumentPack</span></a> <a class="reference" href="#id13">operator()</a>(A0 const&amp; a0, A1 const&amp; a1) const;
<span class="doublesize"></span>
template &lt;class A0, class A1, …class Aβ&gt;
<a class="reference" href="#argumentpack"><span class="concept">ArgumentPack</span></a> <a class="reference" href="#id12">operator()</a>(A0 const&amp; a0, A1 const&amp; a1, …Aβ const&amp; aβ) const;
<a class="reference" href="#argumentpack"><span class="concept">ArgumentPack</span></a> <a class="reference" href="#id13">operator()</a>(A0 const&amp; a0, A1 const&amp; a1, …Aβ const&amp; aβ) const;
};
</pre>
<table class="docutils field-list" frame="void" rules="none">
@@ -480,15 +478,12 @@ every <em>j</em> in 0…β, either:</p>
</ul>
</dd>
</dl>
<span class="target" id="id12"></span><dl class="docutils">
<span class="target" id="id13"></span><dl class="docutils">
<dt><tt class="docutils literal"><span class="pre">operator()</span></tt></dt>
<dd><pre class="first literal-block">
template &lt;class A0&gt; <a class="reference" href="#argumentpack"><span class="concept">ArgumentPack</span></a> operator()(A0 const&amp; a0) const; <span class="vellipsis">
.
.
.
</span>
template &lt;class A0, …class Aβ&gt; <a class="reference" href="#argumentpack"><span class="concept">ArgumentPack</span></a> <a class="reference" href="#id12">operator()</a>(A0 const&amp; a0, …Aβ const&amp; aβ) const;
template &lt;class A0&gt; <a class="reference" href="#argumentpack"><span class="concept">ArgumentPack</span></a> operator()(A0 const&amp; a0) const;
<span class="doublesize"></span>
template &lt;class A0, …class Aβ&gt; <a class="reference" href="#argumentpack"><span class="concept">ArgumentPack</span></a> <a class="reference" href="#id13">operator()</a>(A0 const&amp; a0, …Aβ const&amp; aβ) const;
</pre>
<table class="last docutils field-list" frame="void" rules="none">
<col class="field-name" />
@@ -507,7 +502,7 @@ template &lt;class A0, …class Aβ&gt; <a class="reference" href="#argumentpack
</dl>
</div>
<div class="section" id="optional-required">
<h2><a class="toc-backref" href="#id35" name="optional-required">4.3&nbsp;&nbsp;&nbsp;<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>
<h2><a class="toc-backref" href="#id36" name="optional-required">4.3&nbsp;&nbsp;&nbsp;<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" />
@@ -539,11 +534,11 @@ struct required;
</div>
<hr class="docutils" />
<div class="section" id="metafunctions">
<h1><a class="toc-backref" href="#id36" name="metafunctions">5&nbsp;&nbsp;&nbsp;Metafunctions</a></h1>
<h1><a class="toc-backref" href="#id37" name="metafunctions">5&nbsp;&nbsp;&nbsp;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&nbsp;&nbsp;&nbsp;<tt class="docutils literal"><span class="pre">binding</span></tt></a></h2>
<h2><a class="toc-backref" href="#id38" name="binding">5.1&nbsp;&nbsp;&nbsp;<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">
@@ -574,7 +569,7 @@ having <a class="reference" href="#keyword-tag-type">keyword tag type</a> <tt cl
</table>
</div>
<div class="section" id="lazy-binding">
<h2><a class="toc-backref" href="#id38" name="lazy-binding">5.2&nbsp;&nbsp;&nbsp;<tt class="docutils literal"><span class="pre">lazy_binding</span></tt></a></h2>
<h2><a class="toc-backref" href="#id39" name="lazy-binding">5.2&nbsp;&nbsp;&nbsp;<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" />
@@ -598,7 +593,7 @@ struct lazy_binding
<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">&lt;F()&gt;::type</span></tt>.<a class="footnote-reference" href="#no-result-of" id="id16" name="id16"><sup>2</sup></a></td>
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">&lt;F()&gt;::type</span></tt>.<a class="footnote-reference" href="#no-result-of" id="id17" name="id17"><sup>2</sup></a></td>
</tr>
</tbody>
</table>
@@ -606,11 +601,11 @@ having <a class="reference" href="#keyword-tag-type">keyword tag type</a> <tt cl
</div>
<hr class="docutils" />
<div class="section" id="code-generation-macros">
<h1><a class="toc-backref" href="#id39" name="code-generation-macros">6&nbsp;&nbsp;&nbsp;Code Generation Macros</a></h1>
<h1><a class="toc-backref" href="#id40" name="code-generation-macros">6&nbsp;&nbsp;&nbsp;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&nbsp;&nbsp;&nbsp;<tt class="docutils literal"><span class="pre">BOOST_PARAMETER_FUN(r,n,l,h,p)</span></tt></a></h2>
<h2><a class="toc-backref" href="#id41" name="boost-parameter-fun-r-n-l-h-p">6.1&nbsp;&nbsp;&nbsp;<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
@@ -650,11 +645,8 @@ r name(
, typename <strong>p</strong>::match&lt;A1,A2,…A<strong>l</strong>,A##<a class="reference" href="../../../preprocessor/doc/ref/inc.html">BOOST_PP_INC</a>(<strong>l</strong>)&gt;::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>
}
<span class="doublesize"></span>
template &lt;class A1, class A2, …class A<strong>h</strong>&gt;
r name(
A1 const&amp; a1, A2 const&amp; a2, …A<strong>h</strong> const&amp; x<strong>h</strong>
@@ -667,7 +659,7 @@ r name(
</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&nbsp;&nbsp;&nbsp;<tt class="docutils literal"><span class="pre">BOOST_PARAMETER_KEYWORD(n,k)</span></tt></a></h2>
<h2><a class="toc-backref" href="#id42" name="boost-parameter-keyword-n-k">6.2&nbsp;&nbsp;&nbsp;<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>
@@ -692,7 +684,7 @@ namespace {
</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&nbsp;&nbsp;&nbsp;<tt class="docutils literal"><span class="pre">BOOST_PARAMETER_MATCH(p,a,x)</span></tt></a></h2>
<h2><a class="toc-backref" href="#id43" name="boost-parameter-match-p-a-x">6.3&nbsp;&nbsp;&nbsp;<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">
@@ -726,9 +718,9 @@ typename <strong>p</strong>::match&lt;<strong>A0</strong>,<strong>A1</strong>…
</div>
</div>
<div class="section" id="configuration-macros">
<h1><a class="toc-backref" href="#id43" name="configuration-macros">7&nbsp;&nbsp;&nbsp;Configuration Macros</a></h1>
<h1><a class="toc-backref" href="#id44" name="configuration-macros">7&nbsp;&nbsp;&nbsp;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&nbsp;&nbsp;&nbsp;<tt class="docutils literal"><span class="pre">BOOST_PARAMETER_MAX_ARITY</span></tt></a></h2>
<h2><a class="toc-backref" href="#id45" name="boost-parameter-max-arity">7.1&nbsp;&nbsp;&nbsp;<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>
@@ -751,7 +743,7 @@ already <tt class="docutils literal"><span class="pre">#defined</span></tt>.</p>
</div>
</div>
<div class="section" id="tutorial">
<h1><a class="toc-backref" href="#id45" name="tutorial">8&nbsp;&nbsp;&nbsp;Tutorial</a></h1>
<h1><a class="toc-backref" href="#id46" name="tutorial">8&nbsp;&nbsp;&nbsp;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" />
@@ -769,7 +761,7 @@ where it could make a difference.</td></tr>
<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>,
<tr><td class="label"><a name="no-result-of">[2]</a></td><td><em>(<a class="fn-backref" href="#id11">1</a>, <a class="fn-backref" href="#id17">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">&lt;F()&gt;::type</span></tt> is replaced by
<tt class="docutils literal"><span class="pre">F::result_type</span></tt>.</td></tr>
</tbody>
@@ -778,7 +770,7 @@ where it could make a difference.</td></tr>
</div>
<hr class="docutils footer" />
<div class="footer">
Generated on: 2005-08-05 14:58 UTC.
Generated on: 2006-01-27 01:56 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>

View File

@@ -13,12 +13,6 @@ img {
vertical-align: middle
}
span.vellipsis {
line-height: 30% ;
font-size: 200% ;
}
PRE
{
FONT-FAMILY: monospace ;

View File

@@ -1,4 +1,4 @@
+++++++++++++++++++++++++++++++++++++++++++++++++
+++++++++++++++++++++++++++++++++++++++++++++++++
The Boost Parameter Library
+++++++++++++++++++++++++++++++++++++++++++++++++
@@ -45,8 +45,8 @@ __ ../../../../index.htm
.. role:: concept
:class: concept
.. role:: vellipsis
:class: vellipsis
.. role:: large
:class: doublesize
.. section-numbering::
@@ -629,11 +629,8 @@ to its ``operator()`` and forwarding the result on to
void depth_first_search(A0 const& a0, A1 const& a1)
{
core::depth_first_search(dfs_params()(a0,a1));
} :vellipsis:`\
.
.
.
`
}
:large:`⋮`
template <class A0, class A1, …class A4>
void depth_first_search(A0 const& a0, A1 const& a1, …A4 const& a4)
{
@@ -834,11 +831,8 @@ Now we add a special defaulted argument to each of our
, typename dfs_params::match<A0,A1>::type p = dfs_params())
{
core::depth_first_search(**p**\ (a0,a1));
} :vellipsis:`\
.
.
.
`
}
:large:`⋮`
template <class A0, class A1, …class A4>
void depth_first_search(
A0 const& a0, A1 const& a1, …A4 const& A4
@@ -892,11 +886,8 @@ __ http://boost-consulting.com/mplbook/preprocessor.html#sequences
, **BOOST_PARAMETER_MATCH(dfs_params, (A0)(A1), p)**)
{
core::depth_first_search(p(a0,a1));
} :vellipsis:`\
.
.
.
`
}
:large:`⋮`
template <class A0, class A1, …class A4>
void depth_first_search(
A0 const& a0, A1 const& a1, …A4 const& A4
@@ -1235,12 +1226,12 @@ __ ../../../graph/doc/bgl_named_params.html
typedef T result_type;
template <class A1, class A2>
T operator()(A1 a1, A2 a2) { return T(a1,a2); }
T operator() { return T(a1,a2); }
};
and use `Boost.Bind`_ to generate the function object::
and use Boost.Bind_ to generate the function object::
boost::bind(construct2<default_color_map>(),num_vertices(g),i)
boost::bind(construct2<default_color_map>,num_vertices(g),i)
__ http://www.boost.org/regression/release/user/lambda.html
.. _Boost.Bind: ../../../libs/bind/index.html

View File

@@ -39,10 +39,12 @@ __ ../../../../index.htm
:class: function
.. |ArgumentPack| replace:: :concept:`ArgumentPack`
.. |ForwardSequence| replace:: :concept:`Forward Sequence`
.. |ParameterSpec| replace:: :concept:`ParameterSpec`
.. role:: vellipsis
:class: vellipsis
.. role:: large
:class: doublesize
.. section-numbering::
:depth: 2
@@ -179,7 +181,11 @@ This section describes the generic type concepts_ used by the Parameter library.
--------------
An |ArgumentPack| is a collection of |tagged reference|\ s to the
actual arguments passed to a function.
actual arguments passed to a function. Every |ArgumentPack| is
also a valid MPL |ForwardSequence|__ consisting of the |keyword tag
type|\ s in its |tagged reference|\ s.
__ ../../../mpl/doc/refmanual/forward-sequence.html
Requirements
............
@@ -379,11 +385,8 @@ __ ../../../../boost/parameter/parameters.hpp
|ArgumentPack|_ `operator()`_\(A0 const& a0) const;
template <class A0, class A1>
|ArgumentPack|_ `operator()`_\(A0 const& a0, A1 const& a1) const; :vellipsis:`\
.
.
.
`
|ArgumentPack|_ `operator()`_\(A0 const& a0, A1 const& a1) const;
:large:`⋮`
template <class A0, class A1, …class A\ β>
|ArgumentPack|_ `operator()`_\(A0 const& a0, A1 const& a1, …A\ β const& a\ β) const;
};
@@ -438,11 +441,8 @@ __ ../../../../boost/parameter/parameters.hpp
``operator()``
.. parsed-literal::
template <class A0> |ArgumentPack|_ operator()(A0 const& a0) const; :vellipsis:`\
.
.
.
`
template <class A0> |ArgumentPack|_ operator()(A0 const& a0) const;
:large:`⋮`
template <class A0, …class A\ β> |ArgumentPack|_ `operator()`_\(A0 const& a0, …A\ β const& a\ β) const;
:Returns:
@@ -582,11 +582,8 @@ Generates
, 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:`\
.
.
.
`
}
:large:`⋮`
template <class A1, class A2, …class A\ **h**>
r name(
A1 const& a1, A2 const& a2, …A\ **h** const& x\ **h**

View File

@@ -1,16 +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 BOOST_PARAMETER_050401_HPP
#define BOOST_PARAMETER_050401_HPP
#include <boost/parameter/parameters.hpp>
#include <boost/parameter/keyword.hpp>
#include <boost/parameter/binding.hpp>
#include <boost/parameter/macros.hpp>
#include <boost/parameter/match.hpp>
#endif // BOOST_PARAMETER_050401_HPP

View File

@@ -11,10 +11,14 @@
#include <boost/parameter/aux_/default.hpp>
#include <boost/parameter/aux_/parameter_requirements.hpp>
#include <boost/parameter/aux_/yesno.hpp>
#include <boost/parameter/aux_/maybe_fwd.hpp>
#include <boost/parameter/config.hpp>
#include <boost/mpl/apply.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/mpl/begin.hpp>
#include <boost/mpl/end.hpp>
#include <boost/mpl/iterator_tags.hpp>
#include <boost/type_traits/add_reference.hpp>
#include <boost/type_traits/is_same.hpp>
@@ -22,6 +26,8 @@
#include <boost/preprocessor/repetition/enum_params.hpp>
#include <boost/preprocessor/facilities/intercept.hpp>
#include <boost/optional.hpp>
namespace boost { namespace parameter {
// Forward declaration for aux::arg_list, below.
@@ -40,6 +46,9 @@ namespace aux {
// match against keywords.
//
// MPL sequence support
struct arg_list_tag;
// Terminates arg_list<> and represents an empty list. Since this
// is just the terminating case you might want to look at arg_list
// first, to get a feel for what's really happening here.
@@ -134,6 +143,10 @@ struct empty_arg_list
template <class ParameterRequirements>
static typename ParameterRequirements::has_default
satisfies(ParameterRequirements*);
// MPL sequence support
typedef empty_arg_list type; // convenience
typedef arg_list_tag tag; // For dispatching to sequence intrinsics
};
#if BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
@@ -196,24 +209,26 @@ struct arg_list : Next
};
};
#if BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && !BOOST_WORKAROUND(__GNUC__, == 2)
# if BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
friend yes_tag operator*(arg_list, key_type*);
# define BOOST_PARAMETER_CALL_HAS_KEY(next, key) (*(next*)0 * (key*)0)
#else
# define BOOST_PARAMETER_CALL_HAS_KEY(next, key) (*(next*)0 * (key*)0)
# else
// Overload for key_type, so the assert below will fire if the
// same keyword is used again
static yes_tag has_key(key_type*);
using Next::has_key;
# define BOOST_PARAMETER_CALL_HAS_KEY(next, key) next::has_key((key*)0)
#endif
# define BOOST_PARAMETER_CALL_HAS_KEY(next, key) next::has_key((key*)0)
# endif
BOOST_MPL_ASSERT_MSG(
sizeof(BOOST_PARAMETER_CALL_HAS_KEY(Next,key_type)) == sizeof(no_tag)
, duplicate_keyword, (key_type)
);
#undef BOOST_PARAMETER_CALL_HAS_KEY
# undef BOOST_PARAMETER_CALL_HAS_KEY
#endif
//
// Begin implementation of indexing operators for looking up
// specific arguments by name
@@ -294,17 +309,35 @@ struct arg_list : Next
#else
typedef typename mpl::eval_if<
is_maybe<value_type>
, get_reference<value_type>
, mpl::identity<reference>
>::type default_reference;
reference operator[](keyword<key_type> const&) const
{
return arg.value;
}
template <class Default>
reference operator[](default_<key_type, Default>) const
template <class T, class D>
default_reference get_value(T&, D&) const
{
return arg.value;
}
template <class T, class D>
default_reference get_value(maybe<T>&, D& x) const
{
return arg.value ? arg.value.get() : x;
}
template <class Default>
default_reference operator[](default_<key_type, Default> const& x) const
{
return get_value(arg.value, x.value);
}
template <class Default>
reference operator[](lazy_default<key_type, Default>) const
{
@@ -346,13 +379,60 @@ struct arg_list : Next
{
return arg_list<tagged_argument<KW,T2>, self>(x, *this);
}
// MPL sequence support
typedef self type; // Convenience for users
typedef Next tail_type; // For the benefit of iterators
typedef arg_list_tag tag; // For dispatching to sequence intrinsics
};
#if BOOST_WORKAROUND(BOOST_MSVC, <= 1300) // ETI workaround
template <> struct arg_list<int,int> {};
#endif
}}} // namespace boost::parameter::aux
// MPL sequence support
template <class ArgumentPack>
struct arg_list_iterator
{
typedef mpl::forward_iterator_tag category;
// The incremented iterator
typedef arg_list_iterator<typename ArgumentPack::tail_type> next;
// dereferencing yields the key type
typedef typename ArgumentPack::key_type type;
};
template <>
struct arg_list_iterator<empty_arg_list> {};
}} // namespace parameter::aux
// MPL sequence support
namespace mpl
{
template <>
struct begin_impl<parameter::aux::arg_list_tag>
{
template <class S>
struct apply
{
typedef parameter::aux::arg_list_iterator<S> type;
};
};
template <>
struct end_impl<parameter::aux::arg_list_tag>
{
template <class>
struct apply
{
typedef parameter::aux::arg_list_iterator<parameter::aux::empty_arg_list> type;
};
};
}
} // namespace boost
#endif // ARG_LIST_050329_HPP

View File

@@ -0,0 +1,52 @@
// Copyright 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 BOOST_PARAMETER_MAYBE_051212_HPP
# define BOOST_PARAMETER_MAYBE_051212_HPP
# include <boost/type_traits/is_reference.hpp>
# include <boost/type_traits/add_reference.hpp>
# include <boost/type_traits/add_const.hpp>
# include <boost/optional.hpp>
# include <boost/mpl/if.hpp>
namespace boost { namespace parameter { namespace aux {
struct empty_maybe_tag {};
template <class T>
struct maybe
{
typedef typename mpl::if_<
is_reference<T>
, T
, typename add_reference<typename add_const<T>::type>::type
>::type reference;
maybe()
{}
explicit maybe(reference x)
: value(x)
{}
typedef reference(maybe<T>::*safe_bool)() const;
operator safe_bool() const
{
return value ? &maybe<T>::get : 0 ;
}
reference get() const
{
return value.get();
}
boost::optional<T> value;
};
}}} // namespace boost::parameter::aux
#endif // BOOST_PARAMETER_MAYBE_051212_HPP

View File

@@ -0,0 +1,26 @@
// Copyright 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 BOOST_PARAMETER_MAYBE_FWD_051212_HPP
# define BOOST_PARAMETER_MAYBE_FWD_051212_HPP
# include <boost/detail/is_xxx.hpp>
namespace boost { namespace parameter { namespace aux {
template <class T>
struct maybe;
BOOST_DETAIL_IS_XXX_DEF(maybe,maybe,1)
template <class T>
struct get_reference
{
typedef typename T::reference type;
};
}}} // namespace boost::parameter::aux
#endif // BOOST_PARAMETER_MAYBE_FWD_051212_HPP

View File

@@ -78,7 +78,7 @@
#define BOOST_PARAMETER_FUN(ret, name, lo, hi, parameters) \
\
template<class Params> \
ret BOOST_PP_CAT(name, _with_named_params)(Params const&); \
ret BOOST_PP_CAT(name, _with_named_params)(Params const& p); \
\
BOOST_PP_REPEAT_FROM_TO( \
lo, BOOST_PP_INC(hi), BOOST_PARAMETER_FUN_DECL, (ret, name, parameters)) \

View File

@@ -0,0 +1,103 @@
// Copyright 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 BOOST_PARAMETER_INVOKER_051210_HPP
# define BOOST_PARAMETER_INVOKER_051210_HPP
# include <boost/mpl/begin.hpp>
# include <boost/mpl/next.hpp>
# include <boost/mpl/deref.hpp>
# include <boost/parameter/keyword.hpp>
# include <boost/preprocessor/iteration/iterate.hpp>
namespace boost { namespace parameter { namespace python { namespace aux {
template <long Arity, class M, class R, class Args>
struct invoker;
template <class M, class R>
struct make_invoker
{
template <class Args>
struct apply
{
typedef invoker<
mpl::size<Args>::value, M, R, Args
> type;
};
};
template <long Arity, class T, class R, class Args>
struct call_invoker;
template <class T, class R>
struct make_call_invoker
{
template <class Args>
struct apply
{
typedef call_invoker<
mpl::size<Args>::value, T, R, Args
> type;
};
};
template <long Arity, class T, class Args>
struct init_invoker;
template <class T>
struct make_init_invoker
{
template <class Args>
struct apply
{
typedef init_invoker<
mpl::size<Args>::value, T, Args
> type;
};
};
template <class M, class R, class Args>
struct invoker<0, M, R, Args>
{
static R execute()
{
return M()(boost::type<R>());
}
};
template <class T, class R, class Args>
struct call_invoker<0, T, R, Args>
{
static R execute(T& self)
{
return self();
}
};
template <class T, class Args>
struct init_invoker<0, T, Args>
{
static T* execute(T& self)
{
return new T;
}
};
# define BOOST_PP_ITERATION_PARAMS_1 (4, \
(1, BOOST_PARAMETER_MAX_ARITY, <boost/parameter/python/aux_/invoker_iterate.hpp>, 1))
# include BOOST_PP_ITERATE()
# define BOOST_PP_ITERATION_PARAMS_1 (4, \
(1, BOOST_PARAMETER_MAX_ARITY, <boost/parameter/python/aux_/invoker_iterate.hpp>, 2))
# include BOOST_PP_ITERATE()
# define BOOST_PP_ITERATION_PARAMS_1 (4, \
(1, BOOST_PARAMETER_MAX_ARITY, <boost/parameter/python/aux_/invoker_iterate.hpp>, 3))
# include BOOST_PP_ITERATE()
}}}} // namespace boost::parameter::python::aux
#endif // BOOST_PARAMETER_INVOKER_051210_HPP

View File

@@ -0,0 +1,87 @@
// Copyright 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)
#include <boost/preprocessor/cat.hpp>
#include <boost/preprocessor/dec.hpp>
#include <boost/preprocessor/repetition/enum_binary_params.hpp>
#include <boost/preprocessor/repetition/repeat_from_to.hpp>
#define N BOOST_PP_ITERATION()
#define BOOST_PARAMETER_PY_ARG_TYPES(z, n, _) \
typedef typename mpl::next< \
BOOST_PP_CAT(iter,BOOST_PP_DEC(n)) \
>::type BOOST_PP_CAT(iter,n); \
\
typedef typename mpl::deref<BOOST_PP_CAT(iter,n)>::type BOOST_PP_CAT(spec,n); \
typedef typename mpl::if_< \
mpl::and_< \
mpl::not_<typename BOOST_PP_CAT(spec,n)::required> \
, typename BOOST_PP_CAT(spec,n)::optimized_default \
> \
, parameter::aux::maybe<typename BOOST_PP_CAT(spec,n)::type> \
, typename BOOST_PP_CAT(spec,n)::type \
>::type BOOST_PP_CAT(arg,n); \
typedef typename BOOST_PP_CAT(spec,n)::keyword BOOST_PP_CAT(kw,n);
#if BOOST_PP_ITERATION_FLAGS() == 1
template <class M, class R, class Args>
struct invoker<N, M, R, Args>
#elif BOOST_PP_ITERATION_FLAGS() == 2
template <class T, class R, class Args>
struct call_invoker<N, T, R, Args>
#elif BOOST_PP_ITERATION_FLAGS() == 3
template <class T, class Args>
struct init_invoker<N, T, Args>
#endif
{
typedef typename mpl::begin<Args>::type iter0;
typedef typename mpl::deref<iter0>::type spec0;
typedef typename mpl::if_<
mpl::and_<
mpl::not_<typename spec0::required>
, typename spec0::optimized_default
>
, parameter::aux::maybe<typename spec0::type>
, typename spec0::type
>::type arg0;
typedef typename spec0::keyword kw0;
BOOST_PP_REPEAT_FROM_TO(1, N, BOOST_PARAMETER_PY_ARG_TYPES, ~)
static
#if BOOST_PP_ITERATION_FLAGS() == 1 || BOOST_PP_ITERATION_FLAGS() == 2
R
#else
T*
#endif
execute(
#if BOOST_PP_ITERATION_FLAGS() == 2
T& self
,
#endif
BOOST_PP_ENUM_BINARY_PARAMS(N, arg, a)
)
{
return
#if BOOST_PP_ITERATION_FLAGS() == 1
M()(
boost::type<R>()
, BOOST_PP_ENUM_BINARY_PARAMS(N, keyword<kw, >::get() = a)
);
#elif BOOST_PP_ITERATION_FLAGS() == 2
self(
BOOST_PP_ENUM_BINARY_PARAMS(N, keyword<kw, >::get() = a)
);
#elif BOOST_PP_ITERATION_FLAGS() == 3
new T(
BOOST_PP_ENUM_BINARY_PARAMS(N, keyword<kw, >::get() = a)
);
#endif
}
};
#undef BOOST_PARAMETER_PY_ARG_TYPES
#undef N

View File

@@ -0,0 +1,494 @@
// Copyright 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 BOOST_PARAMETER_FUNCTION_051130_HPP
# define BOOST_PARAMETER_FUNCTION_051130_HPP
# include <boost/preprocessor/cat.hpp>
# include <boost/preprocessor/for.hpp>
# include <boost/preprocessor/detail/split.hpp>
# include <boost/preprocessor/facilities/is_empty.hpp>
# include <boost/preprocessor/tuple/eat.hpp>
# include <boost/preprocessor/logical/not.hpp>
# include <boost/preprocessor/repeat.hpp>
# include <boost/preprocessor/punctuation/comma_if.hpp>
# include <boost/preprocessor/seq/for_each.hpp>
# include <boost/preprocessor/seq/for_each_i.hpp>
# include <boost/preprocessor/seq/fold_left.hpp>
# include <boost/preprocessor/arithmetic/inc.hpp>
# include <boost/preprocessor/arithmetic/add.hpp>
# include <boost/preprocessor/control/if.hpp>
# include <boost/preprocessor/repetition/repeat_from_to.hpp>
# include <boost/preprocessor/repetition/enum_params.hpp>
# include <boost/preprocessor/repetition/enum_binary_params.hpp>
# include <boost/implicit_cast.hpp>
# include <boost/parameter.hpp>
# include <boost/type_traits/is_convertible.hpp>
# include <boost/mpl/vector.hpp>
# include <boost/mpl/bool.hpp>
# define ZKB_KEYWORD(tag_namespace,name) \
BOOST_PARAMETER_KEYWORD(tag_namespace,name) \
namespace tag_namespace \
{ \
struct name \
{ \
static inline char const* keyword() \
{ \
return #name; \
} \
}; \
}
//
// A ``spec`` is a 4-tuple defined as:
//
// ( qualifier , name , type, default )
//
// Where qualifier is one of ``required`` or ``optional``.
//
// Below are access macros to the different components of a spec
//
# define ZKB_spec_qualifier(spec) BOOST_PP_TUPLE_ELEM(4,0,spec)
# define ZKB_spec_name(spec) BOOST_PP_TUPLE_ELEM(4,1,spec)
# define ZKB_spec_type(spec) BOOST_PP_TUPLE_ELEM(4,2,spec)
# define ZKB_spec_default(spec) BOOST_PP_TUPLE_ELEM(4,3,spec)
//
// Split a sublist into qualifier and arg-list.
// The form for the sublist w is:
//
// [optional|required] (x,y ..)
//
// ZKB_sublist_qualifier(w) will return 'optional' or 'required'
// ZKB_sublist_args(w) will return (x,y ..)
//
# define ZKB_sublist_required(args)
# define ZKB_sublist_optional(args)
# define ZKB_sublist_split_required required,
# define ZKB_sublist_split_optional optional,
# define ZKB_sublist_split(sub) \
BOOST_PP_CAT(ZKB_sublist_split_, sub)
# define ZKB_sublist_qualifier(sub) \
BOOST_PP_SPLIT(0, ZKB_sublist_split(sub))
# define ZKB_sublist_args(sub) \
BOOST_PP_SPLIT(1, ZKB_sublist_split(sub))
# define ZKB_sublist(sub) \
[ ZKB_sublist_qualifier(sub) : ZKB_sublist_args(sub) ]
//
// Iteration through n-ary tuples seqs
//
# define ZKB_for_each_head_aux2(x,y) (x,y), ~
# define ZKB_for_each_head_aux3(x,y,z) (x,y,z), ~
# define ZKB_for_each_head_aux4(x,y,z,u) (x,y,z,u), ~
# define ZKB_for_each_head(n,x) \
BOOST_PP_SPLIT(0, BOOST_PP_CAT(ZKB_for_each_head_aux,n) x)
# define ZKB_for_each_pred_aux_ZKB_END_SENTINEL
# define ZKB_for_each_pred_aux_check(x) \
BOOST_PP_NOT(BOOST_PP_IS_EMPTY(BOOST_PP_CAT(ZKB_for_each_pred_aux_, x))), ~
# define ZKB_for_each_pred_aux2(x,y) ZKB_for_each_pred_aux_check(x)
# define ZKB_for_each_pred_aux3(x,y,z) ZKB_for_each_pred_aux_check(x)
# define ZKB_for_each_pred_aux4(x,y,z,u) ZKB_for_each_pred_aux_check(x)
# define ZKB_for_each_pred_aux0(n,x) BOOST_PP_CAT(ZKB_for_each_pred_aux,n) x
# define ZKB_for_each_pred(r, state) \
BOOST_PP_SPLIT( \
0 \
, ZKB_for_each_pred_aux0( \
BOOST_PP_TUPLE_ELEM(5,3,state) \
, BOOST_PP_TUPLE_ELEM(5,0,state) \
) \
)
# define ZKB_for_each_op(r, state) \
( \
BOOST_PP_TUPLE_EAT(BOOST_PP_TUPLE_ELEM(5,3,state)) \
BOOST_PP_TUPLE_ELEM(5,0,state) \
, BOOST_PP_TUPLE_ELEM(5,1,state) \
, BOOST_PP_TUPLE_ELEM(5,2,state) \
, BOOST_PP_TUPLE_ELEM(5,3,state) \
, BOOST_PP_INC(BOOST_PP_TUPLE_ELEM(5,4,state)) \
)
# define ZKB_for_each_macro(r, state) \
BOOST_PP_TUPLE_ELEM(5,2,state)( \
r \
, BOOST_PP_TUPLE_ELEM(5,4,state) \
, ZKB_for_each_head( \
BOOST_PP_TUPLE_ELEM(5,3,state) \
, BOOST_PP_TUPLE_ELEM(5,0,state) \
) \
, BOOST_PP_TUPLE_ELEM(5,1,state) \
)
# define ZKB_for_each_build_end_sentinel(z,n,text) BOOST_PP_COMMA_IF(n) ZKB_END_SENTINEL
# define ZKB_for_each_build_end_sentinel_tuple(arity) \
( \
BOOST_PP_REPEAT(arity, ZKB_for_each_build_end_sentinel, _) \
)
# define ZKB_for_each_seq(arity, list, data, macro) \
BOOST_PP_FOR( \
(list ZKB_for_each_build_end_sentinel_tuple(arity), data, macro, arity, 0) \
, ZKB_for_each_pred \
, ZKB_for_each_op \
, ZKB_for_each_macro \
)
//
// ZKB_build_parameters
//
// Build a parameters<> specialization. tag_namespace is the namespace
// where the keywords reside. args is a sequence of spec's.
//
# define ZKB_build_parameters_aux(r,tag_namespace,i,elem) \
BOOST_PP_COMMA_IF(i) \
boost::parameter::ZKB_spec_qualifier(elem)< \
tag_namespace::ZKB_spec_name(elem) \
, boost::is_convertible<boost::mpl::_, ZKB_spec_type(elem)> \
>
# define ZKB_build_parameters(tag_namespace, args) \
boost::parameter::parameters< \
BOOST_PP_SEQ_FOR_EACH_I(ZKB_build_parameters_aux, tag_namespace, args) \
>
# define ZKB_formal_args(r, data, i, elem) \
BOOST_PP_COMMA_IF(i) ZKB_spec_type(elem) ZKB_spec_name(elem)
# define ZKB_build_function_declaration(result,name,args) \
result name( \
BOOST_PP_SEQ_FOR_EACH_I(ZKB_formal_args, _, args) \
)
# define ZKB_build_fwd_declaration(result,name,args) \
ZKB_build_function_declaration(result,name,args);
# define ZKB_actual_args_maybe_default_optional(spec) | ZKB_spec_default(spec)
# define ZKB_actual_args_maybe_default_required(spec)
# define ZKB_actual_args_maybe_default(spec) \
BOOST_PP_CAT( \
ZKB_actual_args_maybe_default_ \
, ZKB_spec_qualifier(spec) \
)(spec)
# define ZKB_actual_args(r, data, i, elem) \
BOOST_PP_COMMA_IF(i) \
boost::implicit_cast<ZKB_spec_type(elem)>( \
args[ZKB_spec_name(elem) ZKB_actual_args_maybe_default(elem)] \
)
# define ZKB_build_dispatch(result,name,args_) \
template <class Args> \
result BOOST_PP_CAT(name,_dispatch)(Args const& args) \
{ \
return name( \
BOOST_PP_SEQ_FOR_EACH_I(ZKB_actual_args, _, args_) \
); \
}
# define ZKB_calculate_arity_range_op_required 1
# define ZKB_calculate_arity_range_op_optional 0
# define ZKB_calculate_arity_range_op(s, state, spec) \
BOOST_PP_IF( \
BOOST_PP_CAT(ZKB_calculate_arity_range_op_, ZKB_spec_qualifier(spec)) \
, BOOST_PP_INC(state) \
, state \
)
# define ZKB_calculate_arity_range(args) \
( \
BOOST_PP_SEQ_FOLD_LEFT(ZKB_calculate_arity_range_op, 0, args) \
, BOOST_PP_SEQ_SIZE(args) \
)
# define ZKB_build_forwarding_functions_arity_nullary(n,data) \
inline BOOST_PP_TUPLE_ELEM(2,0,data) BOOST_PP_TUPLE_ELEM(2,1,data)() \
{ \
return BOOST_PP_CAT( \
BOOST_PP_TUPLE_ELEM(2,1,data) \
, _dispatch \
)( \
BOOST_PP_CAT(BOOST_PP_TUPLE_ELEM(2,1,data), _parameters)() \
); \
}
# define ZKB_build_forwarding_functions_arity_nary(n,data) \
template<BOOST_PP_ENUM_PARAMS(n, class A)> \
BOOST_PP_TUPLE_ELEM(2,0,data) BOOST_PP_TUPLE_ELEM(2,1,data)( \
BOOST_PP_ENUM_BINARY_PARAMS(n, A, const& a) \
) \
{ \
return BOOST_PP_CAT( \
BOOST_PP_TUPLE_ELEM(2,1,data) \
, _dispatch \
)( \
BOOST_PP_CAT( \
BOOST_PP_TUPLE_ELEM(2,1,data) \
, _parameters \
)()(BOOST_PP_ENUM_PARAMS(n, a)) \
); \
}
# define ZKB_build_forwarding_functions_arity(z,n,data) \
BOOST_PP_IF( \
n \
, ZKB_build_forwarding_functions_arity_nary \
, ZKB_build_forwarding_functions_arity_nullary \
)(n,data)
# define ZKB_build_forwarding_functions0(result,name,arity_tuple) \
BOOST_PP_REPEAT_FROM_TO( \
BOOST_PP_TUPLE_ELEM(2,0,arity_tuple) \
, BOOST_PP_INC(BOOST_PP_TUPLE_ELEM(2,1,arity_tuple)) \
, ZKB_build_forwarding_functions_arity \
, (result,name) \
)
# define ZKB_build_forwarding_functions(result,name,args) \
ZKB_build_forwarding_functions0(result,name,ZKB_calculate_arity_range(args))
# define ZKB_build_meta_arg(r,data,i,spec) \
BOOST_PP_COMMA_IF(i) ZKB_spec_type(spec) BOOST_PP_CAT(a,i)
# define ZKB_build_meta_is_required_optional 0
# define ZKB_build_meta_is_required_required 1
# define ZKB_build_meta_is_required(spec) \
BOOST_PP_CAT(ZKB_build_meta_is_required_, ZKB_spec_qualifier(spec))
# define ZKB_build_meta_keywords(r,tag_namespace,i,spec) \
BOOST_PP_COMMA_IF(i) boost::mpl::pair< \
boost::mpl::bool_<ZKB_build_meta_is_required(spec)> \
, tag_namespace::ZKB_spec_name(spec) \
>
# define ZKB_build_meta_types(r,data,spec) , ZKB_spec_type(spec)
# define ZKB_build_meta_default(tag_namespace,spec) \
static ZKB_spec_type(spec) default_(tag_namespace::ZKB_spec_name(spec)) \
{ \
return ZKB_spec_default(spec); \
}
# define ZKB_build_meta_defaults(r,tag_namespace,spec) \
BOOST_PP_IF( \
ZKB_build_meta_is_required(spec) \
, BOOST_PP_TUPLE_EAT(2) \
, ZKB_build_meta_default \
)(tag_namespace,spec)
# define ZKB_build_meta(result,name,meta_name,tag_namespace,args) \
struct meta_name \
{ \
result operator()(BOOST_PP_SEQ_FOR_EACH_I(ZKB_build_meta_arg, ~, args)) const \
{ \
return name(BOOST_PP_ENUM_PARAMS(BOOST_PP_SEQ_SIZE(args), a)); \
} \
\
typedef BOOST_PP_CAT(boost::mpl::vector, BOOST_PP_SEQ_SIZE(args))< \
BOOST_PP_SEQ_FOR_EACH_I(ZKB_build_meta_keywords, tag_namespace, args) \
> keywords; \
\
typedef BOOST_PP_CAT(boost::mpl::vector, BOOST_PP_INC(BOOST_PP_SEQ_SIZE(args)))< \
result BOOST_PP_SEQ_FOR_EACH(ZKB_build_meta_types, ~, args) \
> signature; \
\
BOOST_PP_SEQ_FOR_EACH(ZKB_build_meta_defaults, tag_namespace, args) \
};
# define ZKB_FUNCTION_IMPL_AUX(result,name,meta_name,args,tag_namespace,with_fwd_declaration) \
BOOST_PP_IF( \
with_fwd_declaration \
, ZKB_build_fwd_declaration \
, BOOST_PP_TUPLE_EAT(3) \
)(result,name,args) \
typedef ZKB_build_parameters(tag_namespace,args) BOOST_PP_CAT(name,_parameters); \
ZKB_build_dispatch(result,name,args) \
ZKB_build_forwarding_functions(result,name,args) \
ZKB_build_meta(result,name,meta_name,tag_namespace,args) \
ZKB_build_function_declaration(result,name,args)
# define ZKB_FUNCTION_IMPL(result,name,meta_name,args,tag_namespace,with_fwd_declaration) \
ZKB_FUNCTION_IMPL_AUX( \
result \
, name \
, meta_name \
, ZKB_flatten_arg_spec(args) \
, tag_namespace \
, with_fwd_declaration \
)
# define ZKB_FUNCTION(result,name,meta_name,tag_namespace,args) \
ZKB_FUNCTION_IMPL(result,name,meta_name,args,tag_namespace,1)
# define ZKB_MEMBER(class_,result,name,meta_name,tag_namespace,args) \
ZKB_FUNCTION_IMPL(result,name,meta_name,args,tag_namespace,0)
//
// ZKB_flatten_arg_spec
//
// Flattens an argument list into normalized 4 arity tuple sequence form:
//
// (qualifier, name, type, default)
//
// Example:
//
// (required (x, int) (y, float))
// (optional (z, int, 0))
//
// Is converted to:
//
// ((required, x, int, ~)) ((required, y, float, ~)) ((optional, z, int, 0))
//
// This makes processing much simpler.
//
# define ZKB_qualifier_arity_required 2
# define ZKB_qualifier_arity_optional 3
# define ZKB_qualifier_arity(q) BOOST_PP_CAT(ZKB_qualifier_arity_,q)
# define ZKB_flatten_arg_spec_aux_required(r,n,elem,_) \
(( \
required \
, BOOST_PP_TUPLE_REM(2) elem \
, ~ \
))
# define ZKB_flatten_arg_spec_aux_optional(r,n,elem,_) \
(( \
optional \
, BOOST_PP_TUPLE_REM(3) elem \
))
# define ZKB_flatten_arg_spec_aux0(z,data,elem) \
ZKB_for_each_seq( \
ZKB_qualifier_arity(ZKB_sublist_qualifier(elem)) \
, ZKB_sublist_args(elem) \
, ~ \
, BOOST_PP_CAT(ZKB_flatten_arg_spec_aux_, ZKB_sublist_qualifier(elem)) \
)
# define ZKB_flatten_arg_spec(args) \
BOOST_PP_SEQ_FOR_EACH(ZKB_flatten_arg_spec_aux0, _, args)
// ?_FUNCTION() generates
//
// void f(int value, char const* name, float scale);
//
// template<class Args>
// void f_dispatch(Args const& args)
// {
// f(args[value], args[name], args[scale | 20.f]);
// }
//
// template<class A0>
// void f(A0 const& a0)
// {
// f_dispatch(f_parameters()(a0));
// }
//
// template<class A0, class A1>
// void f(A0 const& a0, A1 const& a1)
// {
// f_dispatch(f_parameters()(a0,a1));
// }
//
// template<class A0, class A1, class A2>
// void f(A0 const& a0, A1 const& a1, A2 const& a2)
// {
// f_dispatch(f_parameters()(a0,a1,a2));
// }
//
// void f(int value, char const* name, float scale)
//
// ---------------------------------------------------------------------------
//
// _MEMBER() generates
//
// template<class Args>
// void f_dispatch(Args const& args)
// {
// f(args[value], args[name], args[scale | 20.f]);
// }
//
// template<class A0>
// void f(A0 const& a0)
// {
// f_dispatch(f_parameters()(a0));
// }
//
// template<class A0, class A1>
// void f(A0 const& a0, A1 const& a1)
// {
// f_dispatch(f_parameters()(a0,a1));
// }
//
// template<class A0, class A1, class A2>
// void f(A0 const& a0, A1 const& a1, A2 const& a2)
// {
// f_dispatch(f_parameters()(a0,a1,a2));
// }
//
// void f(int value, char const* name, float scale)
//
// ---------------------------------------------------------------------------
//
// _CONSTRUCTOR() generates
//
// template<class A0>
// type(A0 const& a0)
// {
// this->init_dispatch(f_parameters()(a0));
// }
//
// template<class A0, class A1>
// type(A0 const& a0, A1 const& a1)
// {
// this->init_dispatch(f_parameters()(a0,a1));
// }
//
// template<class Args>
// void init_dispatch(Args const& args)
// {
// this->init(args[value], args[name], args[scale | 20.f]);
// }
//
// private:
// void init(int value, char const* name, float scale)
//
// *** OR ***
//
// template<class A0>
// type(A0 const& a0)
// : base(
// f_parameters()(a0)[value]
// , f_parameters()(a0)[name]
// , f_parameters()(a0)[scale | 20.f]
// )
// {}
//
// template<class A0, class A1>
// type(A0 const& a0, A1 const& a1)
// : base(
// f_parameters()(a0,a1)[value]
// , f_parameters()(a0,a1)[name]
// , f_parameters()(a0,a1)[scale | 20.f]
// )
// {}
#endif // BOOST_PARAMETER_FUNCTION_051130_HPP

View File

@@ -0,0 +1,606 @@
// Copyright 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 BOOST_PARAMETER_GENERAL_051210_HPP
# define BOOST_PARAMETER_GENERAL_051210_HPP
# include <boost/mpl/vector.hpp>
# include <boost/mpl/fold.hpp>
# include <boost/mpl/prior.hpp>
# include <boost/mpl/shift_right.hpp>
# include <boost/mpl/shift_left.hpp>
# include <boost/mpl/bitand.hpp>
# include <boost/mpl/pair.hpp>
# include <boost/mpl/size.hpp>
# include <boost/mpl/push_back.hpp>
# include <boost/mpl/or.hpp>
# include <boost/mpl/count_if.hpp>
# include <boost/mpl/transform.hpp>
# include <boost/mpl/front.hpp>
# include <boost/mpl/iterator_range.hpp>
# include <boost/mpl/next.hpp>
# include <boost/mpl/begin_end.hpp>
# include <boost/mpl/not.hpp>
# include <boost/type.hpp>
# include <boost/python/def.hpp>
# include <boost/parameter/python/aux_/invoker.hpp>
# include <boost/parameter/aux_/maybe.hpp>
namespace boost { namespace parameter { namespace python {
PyObject* init_sentinel()
{
static PyTypeObject sentinel_type = {
PyObject_HEAD_INIT(NULL)
0, /* ob_size */
"Boost.Parameter.Unspecified", /* tp_name */
PyType_Type.tp_basicsize, /* tp_basicsize */
0, /* tp_itemsize */
0, /* tp_dealloc */
0, /* tp_print */
0, /* tp_getattr */
0, /* tp_setattr */
0, /* tp_compare */
0, /* tp_repr */
0, /* tp_as_number */
0, /* tp_as_sequence */
0, /* tp_as_mapping */
0, /* tp_hash */
0, /* tp_call */
0, /* tp_str */
0, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT, /* tp_flags */
0, /* tp_doc */
};
assert(PyType_Ready(&sentinel_type) == 0);
return boost::python::upcast<PyObject>(&sentinel_type);
}
inline boost::python::handle<>& sentinel_value()
{
static boost::python::handle<> x;
return x;
}
struct empty_tag_to_python
{
empty_tag_to_python()
{
boost::python::to_python_converter<
boost::parameter::aux::empty_maybe_tag, empty_tag_to_python
>();
sentinel_value() = boost::python::handle<>(init_sentinel());
}
static PyObject* convert(boost::parameter::aux::empty_maybe_tag)
{
return boost::python::xincref(sentinel_value().get());
}
};
}}} // namespace boost::parameter::python
namespace boost { namespace python
{
// Converts a Python value to a maybe<T>
template <class T>
struct arg_from_python<parameter::aux::maybe<T> >
: arg_from_python<T>
{
arg_from_python(PyObject* p)
: arg_from_python<T>(p)
, empty(false)
{
if (parameter::python::sentinel_value().get() == p)
{
empty = true;
}
}
bool convertible() const
{
if (empty) return true;
return arg_from_python<T>::convertible();
}
boost::parameter::aux::maybe<T> operator()()
{
if (empty)
{
return boost::parameter::aux::maybe<T>();
}
else
{
return boost::parameter::aux::maybe<T>(
arg_from_python<T>::operator()()
);
}
}
bool empty;
};
}} // namespace boost::python
namespace boost { namespace parameter { namespace python {
namespace aux
{
template <class K>
struct is_optional
: mpl::not_<
mpl::or_<typename K::required, typename K::optimized_default>
>
{};
template <class K, class Required, class Optimized, class T>
struct arg_spec
{
typedef K keyword;
typedef Required required;
typedef T type;
typedef Optimized optimized_default;
};
template <class K, class T, class Optimized = mpl::false_>
struct make_arg_spec_impl
{
typedef arg_spec<
typename K::first, typename K::second, Optimized, T
> type;
};
template <class K, class T>
struct make_arg_spec_impl<K, T, typename K::third>
{
typedef arg_spec<
typename K::first, typename K::second, typename K::third, T
> type;
};
template <class K, class T>
struct make_arg_spec
: make_arg_spec_impl<K, T>
{
};
template <class Spec, class State>
struct combinations_op
{
typedef typename State::second bits;
typedef typename State::first result0;
typedef typename mpl::if_<
mpl::or_<
typename Spec::required
, typename Spec::optimized_default
, mpl::bitand_<bits, mpl::long_<1> >
>
, typename mpl::push_back<result0, Spec>::type
, result0
>::type result;
typedef typename mpl::if_<
mpl::or_<
typename Spec::required
, typename Spec::optimized_default
>
, bits
, typename mpl::shift_right<bits, mpl::long_<1> >::type
>::type next_bits;
typedef mpl::pair<
result
, next_bits
> type;
};
// Used as start value in the recursive arg() composition below.
struct no_keywords
{
template <class T>
T const& operator,(T const& x) const
{
return x;
}
};
template <class K>
char const* keyword_name(K*)
{
return K::keyword();
}
template <class Def, class F, class Iter, class End, class Keywords>
void def_combination_aux0(
Def def, F f, Iter, End, Keywords const& keywords, mpl::false_)
{
typedef typename mpl::deref<Iter>::type spec;
typedef typename spec::keyword kw;
def_combination_aux(
def, f, typename mpl::next<Iter>::type(), End()
, (
keywords, boost::python::arg(keyword_name((kw*)0))
)
);
}
template <class Def, class F, class Iter, class End, class Keywords>
void def_combination_aux0(
Def def, F f, Iter, End, Keywords const& keywords, mpl::true_)
{
typedef typename mpl::deref<Iter>::type spec;
typedef typename spec::keyword kw;
def_combination_aux(
def, f, typename mpl::next<Iter>::type(), End()
, (
keywords, boost::python::arg(kw::keyword())
= boost::parameter::aux::empty_maybe_tag()
)
);
}
inline void initialize_converter()
{
static empty_tag_to_python cv;
}
template <class Def, class F, class Iter, class End, class Keywords>
void def_combination_aux(
Def def, F f, Iter, End, Keywords const& keywords)
{
typedef typename mpl::deref<Iter>::type spec;
initialize_converter();
typedef typename mpl::and_<
typename spec::optimized_default
, mpl::not_<typename spec::required>
>::type optimized_default;
def_combination_aux0(
def, f, Iter(), End(), keywords, optimized_default()
);
}
template <class Def, class F, class End, class Keywords>
void def_combination_aux(
Def def, F f, End, End, Keywords const& keywords)
{
def(f, keywords);
}
template <class Def, class F, class End>
void def_combination_aux(
Def def, F f, End, End, no_keywords const&)
{
def(f);
}
template <
class Def, class Specs, class Bits, class Invoker
>
void def_combination(
Def def, Specs*, Bits, Invoker*)
{
typedef typename mpl::fold<
Specs
, mpl::pair<mpl::vector0<>, Bits>
, combinations_op<mpl::_2, mpl::_1>
>::type combination0;
typedef typename combination0::first combination;
typedef typename mpl::apply_wrap1<
Invoker, combination
>::type invoker;
def_combination_aux(
def
, &invoker::execute
, typename mpl::begin<combination>::type()
, typename mpl::end<combination>::type()
, no_keywords()
);
}
template <
class Def, class Specs, class Bits, class End, class Invoker
>
void def_combinations(
Def def, Specs*, Bits, End, Invoker*)
{
def_combination(def, (Specs*)0, Bits(), (Invoker*)0);
def_combinations(
def
, (Specs*)0
, mpl::long_<Bits::value + 1>()
, End()
, (Invoker*)0
);
}
template <
class Def, class Specs, class End, class Invoker
>
void def_combinations(
Def, Specs*, End, End, Invoker*)
{}
template <class Class>
struct def_class
{
def_class(Class& cl, char const* name)
: cl(cl)
, name(name)
{}
template <class F>
void operator()(F f) const
{
cl.def(name, f);
}
template <class F, class Keywords>
void operator()(F f, Keywords const& keywords) const
{
cl.def(name, f, keywords);
}
Class& cl;
char const* name;
};
template <class Class>
struct def_init
{
def_init(Class& cl)
: cl(cl)
{}
template <class F>
void operator()(F f) const
{
cl.def(
"__init__"
, boost::python::make_constructor(f)
);
}
template <class F, class Keywords>
void operator()(F f, Keywords const& keywords) const
{
cl.def(
"__init__"
, boost::python::make_constructor(
f, boost::python::default_call_policies(), keywords
)
);
}
Class& cl;
};
struct def_function
{
def_function(char const* name)
: name(name)
{}
template <class F>
void operator()(F f) const
{
boost::python::def(name, f);
}
template <class F, class Keywords>
void operator()(F f, Keywords const& keywords) const
{
boost::python::def(name, f, keywords);
}
char const* name;
};
} // namespace aux
template <class M, class Signature>
void def(char const* name, Signature)
{
typedef mpl::iterator_range<
typename mpl::next<
typename mpl::begin<Signature>::type
>::type
, typename mpl::end<Signature>::type
> arg_types;
typedef typename mpl::transform<
typename M::keywords
, arg_types
, aux::make_arg_spec<mpl::_1, mpl::_2>
>::type arg_specs;
typedef typename mpl::count_if<
arg_specs
, aux::is_optional<mpl::_1>
>::type optional_arity;
typedef typename mpl::front<Signature>::type result_type;
typedef typename mpl::shift_left<mpl::long_<1>, optional_arity>::type upper;
aux::def_combinations(
aux::def_function(name)
, (arg_specs*)0
, mpl::long_<0>()
, mpl::long_<upper::value>()
, (aux::make_invoker<M, result_type>*)0
);
}
template <class M, class Class, class Signature>
void def(Class& cl, char const* name, Signature)
{
typedef mpl::iterator_range<
typename mpl::next<
typename mpl::begin<Signature>::type
>::type
, typename mpl::end<Signature>::type
> arg_types;
typedef typename mpl::transform<
typename M::keywords
, arg_types
, aux::make_arg_spec<mpl::_1, mpl::_2>
>::type arg_specs;
typedef typename mpl::count_if<
arg_specs
, aux::is_optional<mpl::_1>
>::type optional_arity;
typedef typename mpl::front<Signature>::type result_type;
typedef typename mpl::shift_left<mpl::long_<1>, optional_arity>::type upper;
aux::def_combinations(
aux::def_class<Class>(cl, name)
, (arg_specs*)0
, mpl::long_<0>()
, mpl::long_<upper::value>()
, (aux::make_invoker<M, result_type>*)0
);
}
namespace aux
{
template <class K>
struct keyword
{
typedef K type;
};
template <class K>
struct keyword<K*>
: keyword<K>
{};
template <class K>
struct required
{
typedef mpl::true_ type;
};
template <class K>
struct required<K*>
{
typedef mpl::false_ type;
};
template <class K>
struct optimized
{
typedef mpl::true_ type;
};
template <class K>
struct optimized<K**>
{
typedef mpl::false_ type;
};
template <class K, class T>
struct make_kw_spec
{
typedef arg_spec<
typename keyword<K>::type
, typename required<K>::type
, typename optimized<K>::type
, T
> type;
};
} // namespace aux
template <class Keywords, class Signature>
struct init
: boost::python::def_visitor<init<Keywords, Signature> >
{
template <class Class>
void visit(Class& cl) const
{
typedef typename mpl::transform<
Keywords
, Signature
, aux::make_kw_spec<mpl::_1, mpl::_2>
>::type arg_specs;
typedef typename mpl::count_if<
arg_specs
, aux::is_optional<mpl::_1>
>::type optional_arity;
typedef typename mpl::shift_left<mpl::long_<1>, optional_arity>::type upper;
aux::def_combinations(
aux::def_init<Class>(cl)
, (arg_specs*)0
, mpl::long_<0>()
, mpl::long_<upper::value>()
, (aux::make_init_invoker<typename Class::wrapped_type>*)0
);
}
};
template <class Keywords, class Signature>
struct call
: boost::python::def_visitor<call<Keywords, Signature> >
{
template <class Class>
void visit(Class& cl) const
{
typedef mpl::iterator_range<
typename mpl::next<
typename mpl::begin<Signature>::type
>::type
, typename mpl::end<Signature>::type
> arg_types;
typedef typename mpl::transform<
Keywords
, arg_types
, aux::make_kw_spec<mpl::_1, mpl::_2>
>::type arg_specs;
typedef typename mpl::count_if<
arg_specs
, aux::is_optional<mpl::_1>
>::type optional_arity;
typedef typename mpl::front<Signature>::type result_type;
typedef typename mpl::shift_left<mpl::long_<1>, optional_arity>::type upper;
aux::def_combinations(
aux::def_class<Class>(cl, "__call__")
, (arg_specs*)0
, mpl::long_<0>()
, mpl::long_<upper::value>()
, (aux::make_call_invoker<typename Class::wrapped_type, result_type>*)0
);
}
};
}}} // namespace boost::parameter::python
#endif // BOOST_PARAMETER_GENERAL_051210_HPP

View File

@@ -0,0 +1,94 @@
// Copyright 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 BOOST_PARAMETER_MAKE_FUNCTION_051130_HPP
# define BOOST_PARAMETER_MAKE_FUNCTION_051130_HPP
#include <boost/mpl/next.hpp>
#include <boost/mpl/deref.hpp>
#include <boost/mpl/begin_end.hpp>
#include <boost/python/args.hpp>
#include <boost/python/make_function.hpp>
#include <boost/python/default_call_policies.hpp>
namespace boost { namespace parameter { namespace python {
namespace detail
{
// Used as start value in the recursive arg() composition below.
struct no_keywords
{
template <class T>
T const& operator,(T const& x) const
{
return x;
}
};
template <class T, class Iter, class End, class Keywords, class K>
boost::python::object make_function_aux0(
T* p, Iter, End e, Keywords const& keywords, mpl::pair<mpl::true_,K>)
{
return make_function_aux(
p, typename mpl::next<Iter>::type(), e
, (
keywords, boost::python::arg(K::keyword())
)
);
}
template <class T, class Iter, class End, class Keywords, class K>
boost::python::object make_function_aux0(
T* p, Iter, End e, Keywords const& keywords, mpl::pair<mpl::false_,K>)
{
return make_function_aux(
p, typename mpl::next<Iter>::type(), e
, (
keywords, boost::python::arg(K::keyword()) = T::default_(K())
)
);
}
template <class T, class Iter, class End, class Keywords>
boost::python::object make_function_aux(
T* p, Iter i, End e, Keywords const& keywords)
{
return make_function_aux0(
p, i, e, keywords, typename mpl::deref<Iter>::type()
);
}
template <class T, class End, class Keywords>
boost::python::object make_function_aux(
T*, End, End, Keywords const& keywords)
{
return boost::python::make_function(
T()
, boost::python::default_call_policies()
, keywords
, typename T::signature()
);
}
} // namespace detail
template <class T>
boost::python::object make_function()
{
typedef typename T::keywords keywords;
return detail::make_function_aux(
(T*)0
, typename mpl::begin<keywords>::type()
, typename mpl::end<keywords>::type()
, detail::no_keywords()
);
}
}}} // namespace boost::parameter::python
#endif // BOOST_PARAMETER_MAKE_FUNCTION_051130_HPP

View File

@@ -1,12 +1,9 @@
<!-- 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>.
<a href="doc/index.html">doc/html/index.html</a>.
</body>
</html>

View File

@@ -10,7 +10,9 @@ test-suite "parameter"
[ run sfinae.cpp ]
[ run macros.cpp ]
[ run unnamed.cpp ]
[ run earwicker.cpp ]
[ run tutorial.cpp ]
[ run mpl.cpp ]
[ run efficiency.cpp : : : : : release ]
[ compile unwrap_cv_reference.cpp ]
[ compile-fail duplicates.cpp ]

View File

@@ -1,11 +1,18 @@
# Boost Parameter Library test Jamfile
project boost/parameter
: default-build <warnings>off
;
test-suite "parameter"
: [ run basics.cpp ]
[ run sfinae.cpp ]
[ run macros.cpp ]
[ run unnamed.cpp ]
[ run tutorial.cpp ]
[ run earwicker.cpp ]
[ run mpl.cpp ]
[ run efficiency.cpp : : : <variant>release ]
[ compile unwrap_cv_reference.cpp ]
[ compile-fail duplicates.cpp ]
;

View File

@@ -6,8 +6,14 @@
#ifndef BASICS_050424_HPP
#define BASICS_050424_HPP
#include <boost/static_assert.hpp>
#include <boost/parameter/keyword.hpp>
#include <boost/parameter/parameters.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/assert.hpp>
#include <boost/mpl/assert.hpp>
namespace test {
@@ -69,13 +75,13 @@ struct values_t
|| 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));
BOOST_MPL_ASSERT((boost::is_same<Index,Index_>));
BOOST_MPL_ASSERT((boost::is_same<Value,Value_>));
BOOST_MPL_ASSERT((boost::is_same<Name,Name_>));
#endif
assert(equal(n, n_));
assert(equal(v, v_));
assert(equal(i, i_));
BOOST_ASSERT(equal(n, n_));
BOOST_ASSERT(equal(v, v_));
BOOST_ASSERT(equal(i, i_));
}
Name const& n;

56
test/earwicker.cpp Executable file
View File

@@ -0,0 +1,56 @@
// 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)
#include <boost/parameter.hpp>
#include <boost/type_traits/is_convertible.hpp>
#include <boost/mpl/placeholders.hpp>
#include <iostream>
namespace test {
BOOST_PARAMETER_KEYWORD(tag, x)
BOOST_PARAMETER_KEYWORD(tag, y)
BOOST_PARAMETER_KEYWORD(tag, z)
using namespace boost::parameter;
using namespace boost::mpl::placeholders;
struct f_parameters // vc6 is happier with inheritance than with a typedef
: parameters<
optional<tag::x,boost::is_convertible<_,int> >
, optional<tag::y,boost::is_convertible<_,int> >
, optional<tag::z,boost::is_convertible<_,int> >
>
{};
#ifdef BOOST_NO_VOID_RETURNS
BOOST_PARAMETER_FUN(int, f, 0, 3, f_parameters)
#else
BOOST_PARAMETER_FUN(void, f, 0, 3, f_parameters)
#endif
{
std::cout << "x = " << p[x | -1] << std::endl;
std::cout << "y = " << p[y | -2] << std::endl;
std::cout << "z = " << p[z | -3] << std::endl;
std::cout << "================" << std::endl;
#ifdef BOOST_NO_VOID_RETURNS
return 0;
#endif
}
}
int main()
{
using namespace test;
f(x = 1, y = 2, z = 3);
f(x = 1);
f(y = 2);
f(z = 3);
f(z = 3, x = 1);
}

View File

@@ -45,11 +45,7 @@ namespace test
struct plain_weight_running_total
{
plain_weight_running_total()
#if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
: sum(T())
#else
: sum()
#endif
: sum(0)
{}
void operator()(T w)
@@ -68,11 +64,7 @@ namespace test
struct named_param_weight_running_total
{
named_param_weight_running_total()
#if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
: sum(T())
#else
: sum()
#endif
: sum(0)
{}
template <class ArgumentPack>
@@ -93,7 +85,7 @@ namespace test
// Call objects of the given Accumulator type repeatedly with x as
// an argument.
template <class Accumulator, class Arg>
void hammer(Arg const& x, long const repeats)
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
@@ -120,7 +112,7 @@ namespace test
Accumulator a[number_of_accumulators];
for (long iteration = 0; iteration < repeats; ++iteration)
for (long iteration = 0; iteration < 1000000; ++iteration)
{
for (Accumulator* ap = a; ap < a + number_of_accumulators; ++ap)
{
@@ -139,19 +131,19 @@ namespace test
// 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, long const repeats)
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, repeats);
hammer<Accumulator>(x, repeats);
hammer<Accumulator>(x);
hammer<Accumulator>(x);
// Now start a timer
boost::timer time;
hammer<Accumulator>(x, repeats); // This time, we'll measure
hammer<Accumulator>(x); // This time, we'll measure
return time.elapsed();
}
}
@@ -159,32 +151,16 @@ namespace test
int main()
{
using namespace test;
// first decide how many repetitions to measure
long repeats = 100;
double measured = 0;
while (measured < 1.0 && repeats <= 10000000)
{
repeats *= 10;
boost::timer time;
hammer<plain_weight_running_total<double> >(.1, repeats);
hammer<named_param_weight_running_total<double> >(
(weight = .1, value = .2), repeats);
measured = time.elapsed();
}
std::cout
<< "plain time: "
<< measure<plain_weight_running_total<double> >(.1, repeats)
<< 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), repeats
(weight = .1, value = .2)
)
<< std::endl;

88
test/mpl.cpp Executable file
View File

@@ -0,0 +1,88 @@
// Copyright David Abrahams 2006. 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 "basics.hpp"
#include <boost/mpl/list.hpp>
#include <boost/mpl/for_each.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/mpl/size.hpp>
#include <boost/type_traits/add_pointer.hpp>
# include <boost/type_traits/is_same.hpp>
# include <boost/mpl/find.hpp>
# include <boost/mpl/end.hpp>
namespace test
{
namespace mpl = boost::mpl;
template <class Set>
struct assert_in_set
{
template <class T>
void operator()(T*)
{
#if 1 // mpl::set is too unreliable in this release.
typedef typename mpl::find<Set,T>::type pos;
typedef typename mpl::end<Set>::type not_found;
BOOST_MPL_ASSERT_NOT((boost::is_same<pos, not_found>));
#else
BOOST_MPL_ASSERT((mpl::has_key<Set,T>));
#endif
}
};
template<class Expected, class Params>
void f_impl(Params const& p BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(Expected))
{
BOOST_MPL_ASSERT_RELATION(
mpl::size<Expected>::value
, ==
, mpl::size<Params>::value
);
mpl::for_each<Params, boost::add_pointer<mpl::_1> >(assert_in_set<Expected>());
}
template<class Expected, class Tester, class Name, class Value, class Index>
void f(Tester const& t, const Name& name_,
const Value& value_, const Index& index_ BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(Expected))
{
f_impl<Expected>(f_parameters()(t, name_, value_, index_));
}
template<class Expected, class Tester, class Name, class Value>
void f(Tester const& t, const Name& name_, const Value& value_ BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(Expected))
{
f_impl<Expected>(f_parameters()(t, name_, value_));
}
template<class Expected, class Tester, class Name>
void f(Tester const& t, const Name& name_ BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(Expected))
{
f_impl<Expected>(f_parameters()(t, name_));
}
void run()
{
typedef test::tag::tester tester_;
typedef test::tag::name name_;
typedef test::tag::value value_;
typedef test::tag::index index_;
f<mpl::list4<tester_,name_,value_,index_> >(1, 2, 3, 4);
f<mpl::list3<tester_,name_,index_> >(1, 2, index = 3);
f<mpl::list3<tester_,name_,index_> >(1, index = 2, name = 3);
f<mpl::list2<name_,value_> >(name = 3, value = 4);
}
}
int main()
{
test::run();
return 0;
}

38
test/python/Jamfile Executable file
View File

@@ -0,0 +1,38 @@
subproject libs/parameter/test/python ;
SEARCH on python.jam = $(BOOST_BUILD_PATH) ;
include python.jam ;
STATS_ROOT ?= $(BOOST_ROOT) ;
extension parameter
: simple.cpp
<template>@boost/libs/python/build/extension
;
boost-python-runtest test1
: test_simple.py
<pyd>parameter
;
extension general
: general.cpp
<template>@boost/libs/python/build/extension
;
boost-python-runtest test2
: test_general.py
<pyd>general
;
extension accumulator_set
: accumulator.cpp
<template>@boost/libs/python/build/extension
: <include>$(STATS_ROOT)
;
boost-python-runtest test3
: test_accumulator.py
<pyd>accumulator_set
;

97
test/python/accumulator.cpp Executable file
View File

@@ -0,0 +1,97 @@
// Copyright 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)
#include <iostream>
#include <boost/python.hpp>
#include <boost/parameter/python/general.hpp>
#include <boost/accumulators/accumulators.hpp>
#include <boost/accumulators/statistics/stats.hpp>
#include <boost/accumulators/statistics/count.hpp>
#include <boost/accumulators/statistics/min.hpp>
#include <boost/accumulators/statistics/mean.hpp>
#include <boost/accumulators/statistics/sum.hpp>
#include <boost/accumulators/statistics/weighted_mean.hpp>
#include <boost/accumulators/statistics/moment.hpp>
#include <boost/accumulators/statistics/order.hpp>
#include <boost/accumulators/statistics/order_variate.hpp>
#include <boost/accumulators/statistics/with_error.hpp>
#include <boost/accumulators/framework/parameters/weights.hpp>
#include <boost/accumulators/statistics/variates/covariate.hpp>
using namespace boost;
using namespace boost::accumulators;
typedef accumulator_set<
double
, stats<tag::order_variate<int, tag::covariate1> >
> accumulator_type;
template<typename Range>
python::list listify_range(Range const &range)
{
python::list l;
typedef typename boost::range_result_iterator<Range>::type iterator;
iterator begin = range.begin();
iterator end = range.end();
for(; begin != end; ++begin)
l.append(*begin);
return l;
}
python::list listify_covariate1(accumulator_type const& acc)
{
return listify_range(order_variate<int, tag::covariate1>(acc));
}
namespace boost { namespace accumulators { namespace tag
{
char const* keyword_name(sample*)
{
return "sample";
}
char const* keyword_name(covariate1*)
{
return "covariate1";
}
}}} // namespace boost::accumulators::tag
namespace boost { namespace accumulators { namespace detail
{
char const* keyword_name(cache_size_tag*)
{
return "cache_size";
}
}}} // namespace boost::accumulators::detail
BOOST_PYTHON_MODULE(accumulator_set)
{
using namespace boost::python;
namespace py = boost::parameter::python;
class_<accumulator_type>("accumulator_set", no_init)
.def(
py::init<
mpl::vector1<
accumulators::detail::cache_size_tag
>
, mpl::vector1<unsigned>
>()
)
.def(
py::call<
mpl::vector2<
tag::sample
, tag::covariate1
>
, mpl::vector3<void, double, int>
>()
);
def("covariate1", listify_covariate1);
}

100
test/python/general.cpp Executable file
View File

@@ -0,0 +1,100 @@
// Copyright 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)
#include <boost/python.hpp>
#include <boost/parameter/python/general.hpp>
#include <boost/parameter/parameters.hpp>
namespace mpl = boost::mpl;
BOOST_PARAMETER_KEYWORD(tag, x)
BOOST_PARAMETER_KEYWORD(tag, y)
BOOST_PARAMETER_KEYWORD(tag, z)
struct tag::x
{
static char const* keyword()
{
return "x";
}
};
struct tag::y
{
static char const* keyword()
{
return "y";
}
};
struct tag::z
{
static char const* keyword()
{
return "z";
}
};
typedef boost::parameter::parameters<
tag::x
, tag::y
> f_parameters;
template <class Args>
float f_impl(Args const& args)
{
return args[x | 1] / args[y | 1];
}
template <class A0>
float f(A0 const& a0)
{
return f_impl(f_parameters()(a0));
}
template <class A0, class A1>
float f(A0 const& a0, A1 const& a1)
{
return f_impl(f_parameters()(a0,a1));
}
template <class A0, class A1, class A2>
float f(A0 const& a0, A1 const& a1, A2 const& a2)
{
return f_impl(f_parameters()(a0,a1,a2));
}
struct meta
{
typedef mpl::vector3<
mpl::pair<tag::x, mpl::true_>
, mpl::pair<tag::y, mpl::false_>
, mpl::pair<tag::z, mpl::false_>
> keywords;
template <class R, class A0>
R operator()(boost::type<R>, A0 const& a0)
{
return f(a0);
}
template <class R, class A0, class A1>
R operator()(boost::type<R>, A0 const& a0, A1 const& a1)
{
return f(a0,a1);
}
template <class R, class A0, class A1, class A2>
R operator()(boost::type<R>, A0 const& a0, A1 const& a1, A2 const& a2)
{
return f(a0,a1,a2);
}
};
BOOST_PYTHON_MODULE(general)
{
boost::parameter::python::def<meta>("f", mpl::vector4<float,float,float,float>());
}

26
test/python/simple.cpp Executable file
View File

@@ -0,0 +1,26 @@
// Copyright 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)
#include <boost/python.hpp>
#include <iostream>
#include "simple.hpp"
int add(int x, int y, int z, int u)
{
return x + y + z + u;
}
void print(int value, char const* name, float scale)
{
std::cout << "value = " << value << "\n";
std::cout << "name = " << name << "\n";
std::cout << "scale = " << scale << "\n";
}
BOOST_PYTHON_MODULE(parameter)
{
def("add", boost::parameter::python::make_function<add_meta>());
def("echo", boost::parameter::python::make_function<print_meta>());
}

42
test/python/simple.hpp Executable file
View File

@@ -0,0 +1,42 @@
// Copyright 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 BOOST_PARAMETER_SIMPLE_051130_HPP
# define BOOST_PARAMETER_SIMPLE_051130_HPP
# include <boost/parameter/python/function.hpp>
# include <boost/parameter/python/make_function.hpp>
ZKB_KEYWORD(tag, x)
ZKB_KEYWORD(tag, y)
ZKB_KEYWORD(tag, z)
ZKB_KEYWORD(tag, u)
ZKB_FUNCTION(int, add, add_meta, tag,
(required
(x, int)
(y, int)
)
(optional
(z, int, 0)
(u, int, 0)
)
);
ZKB_KEYWORD(tag, value)
ZKB_KEYWORD(tag, name)
ZKB_KEYWORD(tag, scale)
ZKB_FUNCTION(void, print, print_meta, tag,
(required
(value, int)
)
(optional
(name, char const*, "unnamed")
(scale, float, 1.f)
)
);
#endif // BOOST_PARAMETER_SIMPLE_051130_HPP

View File

@@ -0,0 +1,39 @@
'''
>>> import accumulator_set
>>> acc = accumulator_set.accumulator_set(cache_size = 4)
>>> acc(2.1, covariate1 = 21)
>>> acc(1.1, covariate1 = 11)
>>> acc(2.1, covariate1 = 21)
>>> acc(1.1, covariate1 = 11)
>>> accumulator_set.covariate1(acc)
[21, 21, 11, 11]
>>> acc(21.1, covariate1 = 211)
>>> acc(11.1, covariate1 = 111)
>>> acc(21.1, covariate1 = 211)
>>> acc(11.1, covariate1 = 111)
>>> accumulator_set.covariate1(acc)
[211, 211, 111, 111]
>>> acc(42.1, covariate1 = 421)
>>> acc(41.1, covariate1 = 411)
>>> acc(42.1, covariate1 = 421)
>>> acc(41.1, covariate1 = 411)
>>> accumulator_set.covariate1(acc)
[421, 421, 411, 411]
>>> acc(32.1, covariate1 = 321)
>>> acc(31.1, covariate1 = 311)
>>> acc(32.1, covariate1 = 321)
>>> acc(31.1, covariate1 = 311)
>>> accumulator_set.covariate1(acc)
[421, 421, 411, 411]
'''
def run(args = None):
if args is not None:
import sys
sys.argv = args
import doctest, test_accumulator
return doctest.testmod(test_accumulator)
if __name__ == '__main__':
import sys
sys.exit(run()[0])

View File

@@ -0,0 +1,25 @@
r'''>>> import general
>>> general.f(1)
1.0
>>> general.f(x=2)
2.0
>>> general.f(1,y=2)
0.5
>>> general.f(x=4,z=2)
4.0
>>> general.f(y=2,x=4)
2.0
>>> general.f(z=0,y=2,x=4)
2.0
'''
def run(args = None):
if args is not None:
import sys
sys.argv = args
import doctest, test_general
return doctest.testmod(test_general)
if __name__ == '__main__':
import sys
sys.exit(run()[0])

View File

@@ -0,0 +1,21 @@
r'''>>> import parameter
>>> parameter.add(1,2)
3
>>> parameter.add(x=1,y=2)
3
>>> parameter.add(1,2,z=3)
6
>>> parameter.add(x=1,y=2,z=3,u=4)
10
'''
def run(args = None):
if args is not None:
import sys
sys.argv = args
import doctest, test_simple
return doctest.testmod(test_simple)
if __name__ == '__main__':
import sys
sys.exit(run()[0])

View File

@@ -5,10 +5,9 @@
#include <boost/parameter.hpp>
#include <boost/parameter/match.hpp>
#include <cassert>
#include <boost/assert.hpp>
#include <string>
#include <boost/type_traits/is_convertible.hpp>
#include <iostream>
#ifndef BOOST_NO_SFINAE
# include <boost/utility/enable_if.hpp>
@@ -35,16 +34,19 @@ namespace test
>
{};
template <class T> struct not_implemented;
// The use of assert_equal_string is just a nasty workaround for a
// vc++ 6 ICE.
void assert_equal_string(std::string x, std::string y)
{
BOOST_ASSERT(x == y);
}
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);
BOOST_ASSERT(v == 3.f);
assert_equal_string(p[name | "bar"], "foo");
}
void f()

View File

@@ -3,6 +3,7 @@
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#include <iostream>
#include <ostream>
#include <boost/parameter/keyword.hpp>
namespace graphs