Compare commits

..

1 Commits

Author SHA1 Message Date
Beman Dawes
b116b8da99 Branch at revision 46530
[SVN r46531]
2008-06-19 18:57:10 +00:00
47 changed files with 1041 additions and 2272 deletions

View File

@@ -1,17 +0,0 @@
.. -*-rst-*-
.. Copyright David Abrahams 2009. 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)
To build the html::
bjam html
To test the code in this documentation:
.. parsed-literal::
python ../../../tools/litre/tool.py `pwd`/index.rst --dump_dir=../test/literate
cd ../test/literate
bjam

File diff suppressed because it is too large Load Diff

View File

@@ -3,12 +3,12 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.7: http://docutils.sourceforge.net/" />
<meta name="generator" content="Docutils 0.5: http://docutils.sourceforge.net/" />
<title>The Boost Parameter Library Python Binding Documentation</title>
<meta name="authors" content="David Abrahams Daniel Wallin" />
<meta name="organization" content="BoostPro Computing" />
<meta name="date" content="2009-01-29" />
<meta name="copyright" content="Copyright David Abrahams, Daniel Wallin 2005-2009. 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)" />
<meta name="authors" content="Daniel Wallin" />
<meta name="organization" content="Boost Consulting" />
<meta name="date" content="2006-12-14" />
<meta name="copyright" content="Copyright David Abrahams, Daniel Wallin 2005. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)" />
<link rel="stylesheet" href="rst.css" type="text/css" />
</head>
<body>
@@ -19,19 +19,18 @@
<col class="docinfo-content" />
<tbody valign="top">
<tr><th class="docinfo-name">Authors:</th>
<td>David Abrahams
<br />Daniel Wallin</td></tr>
<td>Daniel Wallin</td></tr>
<tr><th class="docinfo-name">Contact:</th>
<td><a class="first reference external" href="mailto:dave&#64;boost-consulting.com">dave&#64;boost-consulting.com</a>, <a class="last reference external" href="mailto:daniel&#64;boostpro.com">daniel&#64;boostpro.com</a></td></tr>
<td><a class="first last reference" href="mailto:dalwan01&#64;student.umu.se">dalwan01&#64;student.umu.se</a></td></tr>
<tr><th class="docinfo-name">Organization:</th>
<td><a class="first last reference external" href="http://www.boostpro.com">BoostPro Computing</a></td></tr>
<td><a class="first last reference" href="http://www.boost-consulting.com">Boost Consulting</a></td></tr>
<tr><th class="docinfo-name">Date:</th>
<td>2009-01-29</td></tr>
<td>2006-12-14</td></tr>
<tr><th class="docinfo-name">Copyright:</th>
<td>Copyright David Abrahams, Daniel Wallin
2005-2009. Distributed under the Boost Software License,
2005. Distributed under the Boost Software License,
Version 1.0. (See accompanying file LICENSE_1_0.txt
or copy at <a class="reference external" href="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</a>)</td></tr>
or copy at <a class="reference" href="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</a>)</td></tr>
</tbody>
</table>
<div class="abstract topic">
@@ -39,26 +38,26 @@ or copy at <a class="reference external" href="http://www.boost.org/LICENSE_1_0.
<p>Makes it possible to bind Boost.Parameter-enabled
functions, operators and constructors to Python.</p>
</div>
<p><a class="reference external" href="../../../../index.htm"><img alt="Boost" src="../../../../boost.png" /></a></p>
<div class="contents topic" id="contents">
<p class="topic-title first">Contents</p>
<p><a class="reference" href="../../../../index.htm"><img alt="Boost" src="../../../../boost.png" /></a></p>
<div class="contents topic">
<p class="topic-title first"><a id="contents" name="contents">Contents</a></p>
<ul class="simple">
<li><a class="reference internal" href="#introduction" id="id7">Introduction</a></li>
<li><a class="reference internal" href="#tutorial" id="id8">Tutorial</a></li>
<li><a class="reference internal" href="#concept-parameterspec" id="id9">concept <span class="concept">ParameterSpec</span></a></li>
<li><a class="reference internal" href="#special-keywords" id="id10"><em>special</em> keywords</a></li>
<li><a class="reference internal" href="#class-template-init" id="id11">class template <tt class="docutils literal">init</tt></a></li>
<li><a class="reference internal" href="#class-template-call" id="id12">class template <tt class="docutils literal">call</tt></a></li>
<li><a class="reference internal" href="#class-template-function" id="id13">class template <tt class="docutils literal">function</tt></a></li>
<li><a class="reference internal" href="#function-template-def" id="id14">function template <tt class="docutils literal">def</tt></a></li>
<li><a class="reference internal" href="#portability" id="id15">Portability</a></li>
<li><a class="reference" href="#introduction" id="id7" name="id7">Introduction</a></li>
<li><a class="reference" href="#tutorial" id="id8" name="id8">Tutorial</a></li>
<li><a class="reference" href="#concept-parameterspec" id="id9" name="id9">concept <span class="concept">ParameterSpec</span></a></li>
<li><a class="reference" href="#special-keywords" id="id10" name="id10"><em>special</em> keywords</a></li>
<li><a class="reference" href="#class-template-init" id="id11" name="id11">class template <tt class="docutils literal"><span class="pre">init</span></tt></a></li>
<li><a class="reference" href="#class-template-call" id="id12" name="id12">class template <tt class="docutils literal"><span class="pre">call</span></tt></a></li>
<li><a class="reference" href="#class-template-function" id="id13" name="id13">class template <tt class="docutils literal"><span class="pre">function</span></tt></a></li>
<li><a class="reference" href="#function-template-def" id="id14" name="id14">function template <tt class="docutils literal"><span class="pre">def</span></tt></a></li>
<li><a class="reference" href="#portability" id="id15" name="id15">Portability</a></li>
</ul>
</div>
<div class="section" id="introduction">
<h1><a class="toc-backref" href="#id7">Introduction</a></h1>
<p><tt class="docutils literal">boost/parameter/python.hpp</tt> introduces a group of <a class="reference external" href="../../../python/doc/v2/def_visitor.html"><tt class="docutils literal">def_visitors</tt></a> that can
<div class="section">
<h1><a class="toc-backref" href="#id7" id="introduction" name="introduction">Introduction</a></h1>
<p><tt class="docutils literal"><span class="pre">boost/parameter/python.hpp</span></tt> introduces a group of <a class="reference" href="../../../python/doc/v2/def_visitor.html"><tt class="docutils literal"><span class="pre">def_visitors</span></tt></a> that can
be used to easily expose Boost.Parameter-enabled member functions to Python with
Boost.Python. It also provides a function template <tt class="docutils literal">def()</tt> that can be used
Boost.Python. It also provides a function template <tt class="docutils literal"><span class="pre">def()</span></tt> that can be used
to expose Boost.Parameter-enabled free functions.</p>
<p>When binding a Boost.Parameter enabled function, the keyword tags
must be specified. Additionally, because Boost.Parameter enabled
@@ -71,8 +70,8 @@ types. Additionally, ``boost::parameter::python::function`` and
``boost::parameter::python::def`` requires a class with forwarding
overloads. We will take a closer look at how this is done in the
tutorial section below. -->
<p>The keyword tags and associated argument types are specified as an <a class="reference external" href="../../../mpl/doc/refmanual/sequences.html">MPL
Sequence</a>, using the function type syntax described in <a class="reference internal" href="#concept-parameterspec"><span class="concept">ParameterSpec</span></a>
<p>The keyword tags and associated argument types are specified as an <a class="reference" href="../../../mpl/doc/refmanual/sequences.html">MPL
Sequence</a>, using the function type syntax described in <a class="reference" href="#concept-parameterspec"><span class="concept">ParameterSpec</span></a>
below. Additionally, <tt class="docutils literal"><span class="pre">boost::parameter::python::function</span></tt> and
<tt class="docutils literal"><span class="pre">boost::parameter::python::def</span></tt> requires a class with forwarding overloads.
We will take a closer look at how this is done in the tutorial section below.</p>
@@ -81,11 +80,11 @@ We will take a closer look at how this is done in the tutorial section below.</p
<!-- else are we going to do other than pass these sequences to -->
<!-- function? -->
</div>
<div class="section" id="tutorial">
<h1><a class="toc-backref" href="#id8">Tutorial</a></h1>
<div class="section">
<h1><a class="toc-backref" href="#id8" id="tutorial" name="tutorial">Tutorial</a></h1>
<p>In this section we will outline the steps needed to bind a simple
Boost.Parameter-enabled member function to Python. Knowledge of the
Boost.Parameter <a class="reference external" href="index.html">macros</a> are required to understand this section.</p>
Boost.Parameter <a class="reference" href="index.html">macros</a> are required to understand this section.</p>
<p>The class and member function we are interested in binding looks
like this:</p>
<pre class="literal-block">
@@ -119,10 +118,10 @@ assert(title == "foo");
assert(height == 20);
assert(width == 400);
''') -->
<p>It defines a set of overloaded member functions called <tt class="docutils literal">open</tt> with one
<p>It defines a set of overloaded member functions called <tt class="docutils literal"><span class="pre">open</span></tt> with one
required parameter and two optional ones. To bind this member function to
Python we use the binding utility <tt class="docutils literal"><span class="pre">boost::parameter::python::function</span></tt>.
<tt class="docutils literal"><span class="pre">boost::parameter::python::function</span></tt> is a <a class="reference external" href="../../../python/doc/v2/def_visitor.html"><tt class="docutils literal">def_visitor</tt></a> that we'll instantiate
<tt class="docutils literal"><span class="pre">boost::parameter::python::function</span></tt> is a <a class="reference" href="../../../python/doc/v2/def_visitor.html"><tt class="docutils literal"><span class="pre">def_visitor</span></tt></a> that we'll instantiate
and pass to <tt class="docutils literal"><span class="pre">boost::python::class_::def()</span></tt>.</p>
<p>To use <tt class="docutils literal"><span class="pre">boost::parameter::python::function</span></tt> we first need to define
a class with forwarding overloads. This is needed because <tt class="docutils literal"><span class="pre">window::open()</span></tt>
@@ -152,7 +151,7 @@ needs to take three parameters as well.</p>
<p class="last">We only need one overload in the forwarding class, despite the
fact that there are two optional parameters. There are special
circumstances when several overload are needed; see
<a class="reference internal" href="#special-keywords">special keywords</a>.</p>
<a class="reference" href="#special-keywords">special keywords</a>.</p>
</div>
<p>Next we'll define the module and export the class:</p>
<pre class="literal-block">
@@ -186,12 +185,12 @@ BOOST_PYTHON_MODULE(my_module)
) -->
<!-- @del jam_prefix[:] -->
<p><tt class="docutils literal"><span class="pre">py::function</span></tt> is passed two parameters. The first one is the class with
forwarding overloads that we defined earlier. The second one is an <a class="reference external" href="../../../mpl/doc/refmanual/sequences.html">MPL
forwarding overloads that we defined earlier. The second one is an <a class="reference" href="../../../mpl/doc/refmanual/sequences.html">MPL
Sequence</a> with the keyword tag types and argument types for the function
specified as function types. The pointer syntax used in <tt class="docutils literal"><span class="pre">tag::width*</span></tt> and
<tt class="docutils literal"><span class="pre">tag::height*</span></tt> means that the parameter is optional. The first element of
the <a class="reference external" href="../../../mpl/doc/refmanual/sequences.html">MPL Sequence</a> is the return type of the function, in this case <tt class="docutils literal">void</tt>,
which is passed as the first argument to <tt class="docutils literal">operator()</tt> in the forwarding
the <a class="reference" href="../../../mpl/doc/refmanual/sequences.html">MPL Sequence</a> is the return type of the function, in this case <tt class="docutils literal"><span class="pre">void</span></tt>,
which is passed as the first argument to <tt class="docutils literal"><span class="pre">operator()</span></tt> in the forwarding
class.</p>
<!-- The
pointer syntax means that the parameter is optional, so in this case
@@ -243,29 +242,29 @@ users of broken compilers will have to give us function pointer
types instead). -->
</div>
<hr class="docutils" />
<div class="section" id="concept-parameterspec">
<h1><a class="toc-backref" href="#id9">concept <span class="concept">ParameterSpec</span></a></h1>
<p>A <span class="concept">ParameterSpec</span> is a function type <tt class="docutils literal">K(T)</tt> that describes both the keyword tag,
<tt class="docutils literal">K</tt>, and the argument type, <tt class="docutils literal">T</tt>, for a parameter.</p>
<p><tt class="docutils literal">K</tt> is either:</p>
<div class="section">
<h1><a class="toc-backref" href="#id9" id="concept-parameterspec" name="concept-parameterspec">concept <span class="concept">ParameterSpec</span></a></h1>
<p>A <span class="concept">ParameterSpec</span> is a function type <tt class="docutils literal"><span class="pre">K(T)</span></tt> that describes both the keyword tag,
<tt class="docutils literal"><span class="pre">K</span></tt>, and the argument type, <tt class="docutils literal"><span class="pre">T</span></tt>, for a parameter.</p>
<p><tt class="docutils literal"><span class="pre">K</span></tt> is either:</p>
<ul class="simple">
<li>A <em>required</em> keyword of the form <tt class="docutils literal">Tag</tt></li>
<li><strong>or</strong>, an <em>optional</em> keyword of the form <tt class="docutils literal">Tag*</tt></li>
<li><strong>or</strong>, a <em>special</em> keyword of the form <tt class="docutils literal">Tag**</tt></li>
<li>A <em>required</em> keyword of the form <tt class="docutils literal"><span class="pre">Tag</span></tt></li>
<li><strong>or</strong>, an <em>optional</em> keyword of the form <tt class="docutils literal"><span class="pre">Tag*</span></tt></li>
<li><strong>or</strong>, a <em>special</em> keyword of the form <tt class="docutils literal"><span class="pre">Tag**</span></tt></li>
</ul>
<p>where <tt class="docutils literal">Tag</tt> is a keyword tag type, as used in a specialization
of <a class="reference external" href="../../../parameter/doc/html/reference.html#keyword"><tt class="docutils literal"><span class="pre">boost::parameter::keyword</span></tt></a>.</p>
<p>The <strong>arity range</strong> for an <a class="reference external" href="../../../mpl/doc/refmanual/sequences.html">MPL Sequence</a> of <span class="concept">ParameterSpec</span>'s is
<p>where <tt class="docutils literal"><span class="pre">Tag</span></tt> is a keyword tag type, as used in a specialization
of <a class="reference" href="../../../parameter/doc/html/reference.html#keyword"><tt class="docutils literal"><span class="pre">boost::parameter::keyword</span></tt></a>.</p>
<p>The <strong>arity range</strong> for an <a class="reference" href="../../../mpl/doc/refmanual/sequences.html">MPL Sequence</a> of <span class="concept">ParameterSpec</span>'s is
defined as the closed range:</p>
<pre class="literal-block">
[ mpl::size&lt;S&gt; - number of <em>special</em> keyword tags in <tt class="docutils literal">S</tt>, mpl::size&lt;S&gt; ]
[ mpl::size&lt;S&gt; - number of <em>special</em> keyword tags in <tt class="docutils literal"><span class="pre">S</span></tt>, mpl::size&lt;S&gt; ]
</pre>
<p>For example, the <strong>arity range</strong> of <tt class="docutils literal"><span class="pre">mpl::vector2&lt;x(int),y(int)&gt;</span></tt> is <tt class="docutils literal">[2,2]</tt>,
the <strong>arity range</strong> of <tt class="docutils literal"><span class="pre">mpl::vector2&lt;x(int),y*(int)&gt;</span></tt> is <tt class="docutils literal">[2,2]</tt> and the
<strong>arity range</strong> of <tt class="docutils literal"><span class="pre">mpl::vector2&lt;x(int),y**(int)&gt;</span></tt> is <tt class="docutils literal">[1,2]</tt>.</p>
<p>For example, the <strong>arity range</strong> of <tt class="docutils literal"><span class="pre">mpl::vector2&lt;x(int),y(int)&gt;</span></tt> is <tt class="docutils literal"><span class="pre">[2,2]</span></tt>,
the <strong>arity range</strong> of <tt class="docutils literal"><span class="pre">mpl::vector2&lt;x(int),y*(int)&gt;</span></tt> is <tt class="docutils literal"><span class="pre">[2,2]</span></tt> and the
<strong>arity range</strong> of <tt class="docutils literal"><span class="pre">mpl::vector2&lt;x(int),y**(int)&gt;</span></tt> is <tt class="docutils literal"><span class="pre">[1,2]</span></tt>.</p>
</div>
<div class="section" id="special-keywords">
<h1><a class="toc-backref" href="#id10"><em>special</em> keywords</a></h1>
<div class="section">
<h1><a class="toc-backref" href="#id10" id="special-keywords" name="special-keywords"><em>special</em> keywords</a></h1>
<p>Sometimes it is desirable to have a default value for a parameter that differ
in type from the parameter. This technique is useful for doing simple tag-dispatching
based on the presence of a parameter. For example:</p>
@@ -319,20 +318,20 @@ int main()
}''') -->
<!-- @build() -->
<!-- .. _example: index.html#dispatching-based-on-the-presence-of-a-default -->
<p>In the above example the type of the default for <tt class="docutils literal">color</tt> is <tt class="docutils literal"><span class="pre">mpl::false_</span></tt>, a
<p>In the above example the type of the default for <tt class="docutils literal"><span class="pre">color</span></tt> is <tt class="docutils literal"><span class="pre">mpl::false_</span></tt>, a
type that is distinct from any color map that the user might supply.</p>
<p>When binding the case outlined above, the default type for <tt class="docutils literal">color</tt> will not
be convertible to the parameter type. Therefore we need to tag the <tt class="docutils literal">color</tt>
<p>When binding the case outlined above, the default type for <tt class="docutils literal"><span class="pre">color</span></tt> will not
be convertible to the parameter type. Therefore we need to tag the <tt class="docutils literal"><span class="pre">color</span></tt>
keyword as a <em>special</em> keyword. This is done by specifying the tag as
<tt class="docutils literal"><span class="pre">tag::color**</span></tt> when binding the function (see <a class="reference internal" href="#concept-parameterspec">concept ParameterSpec</a> for
<tt class="docutils literal"><span class="pre">tag::color**</span></tt> when binding the function (see <a class="reference" href="#concept-parameterspec">concept ParameterSpec</a> for
more details on the tagging). By doing this we tell the binding functions that
it needs to generate two overloads, one with the <tt class="docutils literal">color</tt> parameter present
it needs to generate two overloads, one with the <tt class="docutils literal"><span class="pre">color</span></tt> parameter present
and one without. Had there been two <em>special</em> keywords, four overloads would
need to be generated. The number of generated overloads is equal to 2<sup>N</sup>, where <tt class="docutils literal">N</tt> is the number of <em>special</em> keywords.</p>
need to be generated. The number of generated overloads is equal to 2<sup>N</sup>, where <tt class="docutils literal"><span class="pre">N</span></tt> is the number of <em>special</em> keywords.</p>
</div>
<hr class="docutils" />
<div class="section" id="class-template-init">
<h1><a class="toc-backref" href="#id11">class template <tt class="docutils literal">init</tt></a></h1>
<div class="section">
<h1><a class="toc-backref" href="#id11" id="class-template-init" name="class-template-init">class template <tt class="docutils literal"><span class="pre">init</span></tt></a></h1>
<p>Defines a named parameter enabled constructor.</p>
<pre class="literal-block">
template &lt;class ParameterSpecs&gt;
@@ -346,14 +345,14 @@ struct init : python::def_visitor&lt;init&lt;ParameterSpecs&gt; &gt;
};
</pre>
<!-- @ignore() -->
<div class="section" id="init-requirements">
<h2><tt class="docutils literal">init</tt> requirements</h2>
<div class="section">
<h2><a id="init-requirements" name="init-requirements"><tt class="docutils literal"><span class="pre">init</span></tt> requirements</a></h2>
<ul>
<li><p class="first"><tt class="docutils literal">ParameterSpecs</tt> is an <a class="reference external" href="../../../mpl/doc/refmanual/sequences.html">MPL sequence</a> where each element is a
<li><p class="first"><tt class="docutils literal"><span class="pre">ParameterSpecs</span></tt> is an <a class="reference" href="../../../mpl/doc/refmanual/sequences.html">MPL sequence</a> where each element is a
model of <span class="concept">ParameterSpec</span>.</p>
</li>
<li><p class="first">For every <tt class="docutils literal">N</tt> in <tt class="docutils literal">[U,V]</tt>, where <tt class="docutils literal">[U,V]</tt> is the <strong>arity
range</strong> of <tt class="docutils literal">ParameterSpecs</tt>, <tt class="docutils literal">Class</tt> must support these
<li><p class="first">For every <tt class="docutils literal"><span class="pre">N</span></tt> in <tt class="docutils literal"><span class="pre">[U,V]</span></tt>, where <tt class="docutils literal"><span class="pre">[U,V]</span></tt> is the <strong>arity
range</strong> of <tt class="docutils literal"><span class="pre">ParameterSpecs</span></tt>, <tt class="docutils literal"><span class="pre">Class</span></tt> must support these
expressions:</p>
<table border="1" class="docutils">
<colgroup>
@@ -371,11 +370,11 @@ expressions:</p>
</tr>
</thead>
<tbody valign="top">
<tr><td><p class="first last"><tt class="docutils literal">Class(a0, …, aN)</tt></p>
<tr><td><p class="first last"><tt class="docutils literal"><span class="pre">Class(a0,</span> <span class="pre">…,</span> <span class="pre">aN)</span></tt></p>
</td>
<td><p class="first last">-</p>
</td>
<td><p class="first last"><tt class="docutils literal">a0</tt><tt class="docutils literal">aN</tt> are tagged arguments.</p>
<td><p class="first last"><tt class="docutils literal"><span class="pre">a0</span></tt><tt class="docutils literal"><span class="pre">aN</span></tt> are tagged arguments.</p>
</td>
</tr>
</tbody>
@@ -383,13 +382,13 @@ expressions:</p>
</li>
</ul>
</div>
<div class="section" id="template-class-callpolicies-operator-callpolicies-const">
<h2><tt class="docutils literal">template &lt;class CallPolicies&gt; <span class="pre">operator[](CallPolicies</span> const&amp;)</tt></h2>
<p>Returns a <tt class="docutils literal">def_visitor</tt> equivalent to <tt class="docutils literal">*this</tt>, except that it
<div class="section">
<h2><a id="template-class-callpolicies-operator-callpolicies-const" name="template-class-callpolicies-operator-callpolicies-const"><tt class="docutils literal"><span class="pre">template</span> <span class="pre">&lt;class</span> <span class="pre">CallPolicies&gt;</span> <span class="pre">operator[](CallPolicies</span> <span class="pre">const&amp;)</span></tt></a></h2>
<p>Returns a <tt class="docutils literal"><span class="pre">def_visitor</span></tt> equivalent to <tt class="docutils literal"><span class="pre">*this</span></tt>, except that it
uses CallPolicies when creating the binding.</p>
</div>
<div class="section" id="example">
<h2>Example</h2>
<div class="section">
<h2><a id="example" name="example">Example</a></h2>
<pre class="literal-block">
#include &lt;boost/parameter/keyword.hpp&gt;
#include &lt;boost/parameter/preprocessor.hpp&gt;
@@ -447,9 +446,9 @@ assert(args[y | 1] == 1);
</div>
</div>
<hr class="docutils" />
<div class="section" id="class-template-call">
<h1><a class="toc-backref" href="#id12">class template <tt class="docutils literal">call</tt></a></h1>
<p>Defines a <tt class="docutils literal">__call__</tt> operator, mapped to <tt class="docutils literal">operator()</tt> in C++.</p>
<div class="section">
<h1><a class="toc-backref" href="#id12" id="class-template-call" name="class-template-call">class template <tt class="docutils literal"><span class="pre">call</span></tt></a></h1>
<p>Defines a <tt class="docutils literal"><span class="pre">__call__</span></tt> operator, mapped to <tt class="docutils literal"><span class="pre">operator()</span></tt> in C++.</p>
<pre class="literal-block">
template &lt;class ParameterSpecs&gt;
struct call : python::def_visitor&lt;call&lt;ParameterSpecs&gt; &gt;
@@ -462,15 +461,15 @@ struct call : python::def_visitor&lt;call&lt;ParameterSpecs&gt; &gt;
};
</pre>
<!-- @ignore() -->
<div class="section" id="call-requirements">
<h2><tt class="docutils literal">call</tt> requirements</h2>
<div class="section">
<h2><a id="call-requirements" name="call-requirements"><tt class="docutils literal"><span class="pre">call</span></tt> requirements</a></h2>
<ul>
<li><p class="first"><tt class="docutils literal">ParameterSpecs</tt> is an <a class="reference external" href="../../../mpl/doc/refmanual/sequences.html">MPL sequence</a> where each element
<li><p class="first"><tt class="docutils literal"><span class="pre">ParameterSpecs</span></tt> is an <a class="reference" href="../../../mpl/doc/refmanual/sequences.html">MPL sequence</a> where each element
except the first models <span class="concept">ParameterSpec</span>. The first element
is the result type of <tt class="docutils literal"><span class="pre">c(…)</span></tt>.</p>
</li>
<li><p class="first"><tt class="docutils literal">Class</tt> must support these expressions, where <tt class="docutils literal">c</tt> is an
instance of <tt class="docutils literal">Class</tt>:</p>
<li><p class="first"><tt class="docutils literal"><span class="pre">Class</span></tt> must support these expressions, where <tt class="docutils literal"><span class="pre">c</span></tt> is an
instance of <tt class="docutils literal"><span class="pre">Class</span></tt>:</p>
<table border="1" class="docutils">
<colgroup>
<col width="24%" />
@@ -487,26 +486,26 @@ instance of <tt class="docutils literal">Class</tt>:</p>
</tr>
</thead>
<tbody valign="top">
<tr><td><p class="first last"><tt class="docutils literal">c(a0, …, aN)</tt></p>
<tr><td><p class="first last"><tt class="docutils literal"><span class="pre">c(a0,</span> <span class="pre">…,</span> <span class="pre">aN)</span></tt></p>
</td>
<td><p class="first last">Convertible to <tt class="docutils literal">R</tt></p>
<td><p class="first last">Convertible to <tt class="docutils literal"><span class="pre">R</span></tt></p>
</td>
<td><p class="first last"><tt class="docutils literal">a0</tt><tt class="docutils literal">aN</tt> are tagged arguments.</p>
<td><p class="first last"><tt class="docutils literal"><span class="pre">a0</span></tt><tt class="docutils literal"><span class="pre">aN</span></tt> are tagged arguments.</p>
</td>
</tr>
</tbody>
</table>
<p>For every <tt class="docutils literal">N</tt> in <tt class="docutils literal">[U,V]</tt>, where <tt class="docutils literal">[U,V]</tt> is the <strong>arity range</strong> of <tt class="docutils literal">ParameterSpecs</tt>.</p>
<p>For every <tt class="docutils literal"><span class="pre">N</span></tt> in <tt class="docutils literal"><span class="pre">[U,V]</span></tt>, where <tt class="docutils literal"><span class="pre">[U,V]</span></tt> is the <strong>arity range</strong> of <tt class="docutils literal"><span class="pre">ParameterSpecs</span></tt>.</p>
</li>
</ul>
</div>
<div class="section" id="id3">
<h2><tt class="docutils literal">template &lt;class CallPolicies&gt; <span class="pre">operator[](CallPolicies</span> const&amp;)</tt></h2>
<p>Returns a <tt class="docutils literal">def_visitor</tt> equivalent to <tt class="docutils literal">*this</tt>, except that it
<div class="section">
<h2><a id="id3" name="id3"><tt class="docutils literal"><span class="pre">template</span> <span class="pre">&lt;class</span> <span class="pre">CallPolicies&gt;</span> <span class="pre">operator[](CallPolicies</span> <span class="pre">const&amp;)</span></tt></a></h2>
<p>Returns a <tt class="docutils literal"><span class="pre">def_visitor</span></tt> equivalent to <tt class="docutils literal"><span class="pre">*this</span></tt>, except that it
uses CallPolicies when creating the binding.</p>
</div>
<div class="section" id="id4">
<h2>Example</h2>
<div class="section">
<h2><a id="id4" name="id4">Example</a></h2>
<pre class="literal-block">
#include &lt;boost/parameter/keyword.hpp&gt;
#include &lt;boost/parameter/preprocessor.hpp&gt;
@@ -574,8 +573,8 @@ return 0;
</div>
</div>
<hr class="docutils" />
<div class="section" id="class-template-function">
<h1><a class="toc-backref" href="#id13">class template <tt class="docutils literal">function</tt></a></h1>
<div class="section">
<h1><a class="toc-backref" href="#id13" id="class-template-function" name="class-template-function">class template <tt class="docutils literal"><span class="pre">function</span></tt></a></h1>
<p>Defines a named parameter enabled member function.</p>
<pre class="literal-block">
template &lt;class Fwd, class ParameterSpecs&gt;
@@ -586,15 +585,15 @@ struct function : python::def_visitor&lt;function&lt;Fwd, ParameterSpecs&gt; &gt
};
</pre>
<!-- @ignore() -->
<div class="section" id="function-requirements">
<h2><tt class="docutils literal">function</tt> requirements</h2>
<div class="section">
<h2><a id="function-requirements" name="function-requirements"><tt class="docutils literal"><span class="pre">function</span></tt> requirements</a></h2>
<ul>
<li><p class="first"><tt class="docutils literal">ParameterSpecs</tt> is an <a class="reference external" href="../../../mpl/doc/refmanual/sequences.html">MPL sequence</a> where each element
<li><p class="first"><tt class="docutils literal"><span class="pre">ParameterSpecs</span></tt> is an <a class="reference" href="../../../mpl/doc/refmanual/sequences.html">MPL sequence</a> where each element
except the first models <span class="concept">ParameterSpec</span>. The first element
is the result type of <tt class="docutils literal"><span class="pre">c.f(…)</span></tt>, where <tt class="docutils literal">f</tt> is the member
is the result type of <tt class="docutils literal"><span class="pre">c.f(…)</span></tt>, where <tt class="docutils literal"><span class="pre">f</span></tt> is the member
function.</p>
</li>
<li><p class="first">An instance of <tt class="docutils literal">Fwd</tt> must support this expression:</p>
<li><p class="first">An instance of <tt class="docutils literal"><span class="pre">Fwd</span></tt> must support this expression:</p>
<table border="1" class="docutils">
<colgroup>
<col width="39%" />
@@ -611,24 +610,24 @@ function.</p>
</tr>
</thead>
<tbody valign="top">
<tr><td><p class="first last"><tt class="docutils literal"><span class="pre">fwd(boost::type&lt;R&gt;(),</span> self, a0, …, aN)</tt></p>
<tr><td><p class="first last"><tt class="docutils literal"><span class="pre">fwd(boost::type&lt;R&gt;(),</span> <span class="pre">self,</span> <span class="pre">a0,</span> <span class="pre">…,</span> <span class="pre">aN)</span></tt></p>
</td>
<td><p class="first last">Convertible to <tt class="docutils literal">R</tt></p>
<td><p class="first last">Convertible to <tt class="docutils literal"><span class="pre">R</span></tt></p>
</td>
<td><p class="first last"><tt class="docutils literal">self</tt> is a reference to the object on which
the function should be invoked. <tt class="docutils literal">a0</tt><tt class="docutils literal">aN</tt>
<td><p class="first last"><tt class="docutils literal"><span class="pre">self</span></tt> is a reference to the object on which
the function should be invoked. <tt class="docutils literal"><span class="pre">a0</span></tt><tt class="docutils literal"><span class="pre">aN</span></tt>
are tagged arguments.</p>
</td>
</tr>
</tbody>
</table>
<p>For every <tt class="docutils literal">N</tt> in <tt class="docutils literal">[U,V]</tt>, where <tt class="docutils literal">[U,V]</tt> is the <strong>arity range</strong> of <tt class="docutils literal">ParameterSpecs</tt>.</p>
<p>For every <tt class="docutils literal"><span class="pre">N</span></tt> in <tt class="docutils literal"><span class="pre">[U,V]</span></tt>, where <tt class="docutils literal"><span class="pre">[U,V]</span></tt> is the <strong>arity range</strong> of <tt class="docutils literal"><span class="pre">ParameterSpecs</span></tt>.</p>
</li>
</ul>
</div>
<div class="section" id="id5">
<h2>Example</h2>
<p>This example exports a member function <tt class="docutils literal">f(int x, int y = …)</tt> to Python. The
<div class="section">
<h2><a id="id5" name="id5">Example</a></h2>
<p>This example exports a member function <tt class="docutils literal"><span class="pre">f(int</span> <span class="pre">x,</span> <span class="pre">int</span> <span class="pre">y</span> <span class="pre">=</span> <span class="pre">…)</span></tt> to Python. The
sequence of <span class="concept">ParameterSpec</span>'s <tt class="docutils literal"><span class="pre">mpl::vector2&lt;tag::x(int),</span> <span class="pre">tag::y*(int)&gt;</span></tt> has
an <strong>arity range</strong> of [2,2], so we only need one forwarding overload.</p>
<pre class="literal-block">
@@ -690,22 +689,22 @@ assert(y == 1);
</div>
</div>
<hr class="docutils" />
<div class="section" id="function-template-def">
<h1><a class="toc-backref" href="#id14">function template <tt class="docutils literal">def</tt></a></h1>
<div class="section">
<h1><a class="toc-backref" href="#id14" id="function-template-def" name="function-template-def">function template <tt class="docutils literal"><span class="pre">def</span></tt></a></h1>
<p>Defines a named parameter enabled free function in the current Python scope.</p>
<pre class="literal-block">
template &lt;class Fwd, class ParameterSpecs&gt;
void def(char const* name);
</pre>
<!-- @ignore() -->
<div class="section" id="def-requirements">
<h2><tt class="docutils literal">def</tt> requirements</h2>
<div class="section">
<h2><a id="def-requirements" name="def-requirements"><tt class="docutils literal"><span class="pre">def</span></tt> requirements</a></h2>
<ul>
<li><p class="first"><tt class="docutils literal">ParameterSpecs</tt> is an <a class="reference external" href="../../../mpl/doc/refmanual/sequences.html">MPL sequence</a> where each element
<li><p class="first"><tt class="docutils literal"><span class="pre">ParameterSpecs</span></tt> is an <a class="reference" href="../../../mpl/doc/refmanual/sequences.html">MPL sequence</a> where each element
except the first models <span class="concept">ParameterSpec</span>. The first element
is the result type of <tt class="docutils literal"><span class="pre">f(…)</span></tt>, where <tt class="docutils literal">f</tt> is the function.</p>
is the result type of <tt class="docutils literal"><span class="pre">f(…)</span></tt>, where <tt class="docutils literal"><span class="pre">f</span></tt> is the function.</p>
</li>
<li><p class="first">An instance of <tt class="docutils literal">Fwd</tt> must support this expression:</p>
<li><p class="first">An instance of <tt class="docutils literal"><span class="pre">Fwd</span></tt> must support this expression:</p>
<table border="1" class="docutils">
<colgroup>
<col width="39%" />
@@ -722,22 +721,22 @@ is the result type of <tt class="docutils literal"><span class="pre">f(…)</spa
</tr>
</thead>
<tbody valign="top">
<tr><td><p class="first last"><tt class="docutils literal"><span class="pre">fwd(boost::type&lt;R&gt;(),</span> a0, …, aN)</tt></p>
<tr><td><p class="first last"><tt class="docutils literal"><span class="pre">fwd(boost::type&lt;R&gt;(),</span> <span class="pre">a0,</span> <span class="pre">…,</span> <span class="pre">aN)</span></tt></p>
</td>
<td><p class="first last">Convertible to <tt class="docutils literal">R</tt></p>
<td><p class="first last">Convertible to <tt class="docutils literal"><span class="pre">R</span></tt></p>
</td>
<td><p class="first last"><tt class="docutils literal">a0</tt><tt class="docutils literal">aN</tt> are tagged arguments.</p>
<td><p class="first last"><tt class="docutils literal"><span class="pre">a0</span></tt><tt class="docutils literal"><span class="pre">aN</span></tt> are tagged arguments.</p>
</td>
</tr>
</tbody>
</table>
<p>For every <tt class="docutils literal">N</tt> in <tt class="docutils literal">[U,V]</tt>, where <tt class="docutils literal">[U,V]</tt> is the <strong>arity range</strong> of <tt class="docutils literal">ParameterSpecs</tt>.</p>
<p>For every <tt class="docutils literal"><span class="pre">N</span></tt> in <tt class="docutils literal"><span class="pre">[U,V]</span></tt>, where <tt class="docutils literal"><span class="pre">[U,V]</span></tt> is the <strong>arity range</strong> of <tt class="docutils literal"><span class="pre">ParameterSpecs</span></tt>.</p>
</li>
</ul>
</div>
<div class="section" id="id6">
<h2>Example</h2>
<p>This example exports a function <tt class="docutils literal">f(int x, int y = …)</tt> to Python. The
<div class="section">
<h2><a id="id6" name="id6">Example</a></h2>
<p>This example exports a function <tt class="docutils literal"><span class="pre">f(int</span> <span class="pre">x,</span> <span class="pre">int</span> <span class="pre">y</span> <span class="pre">=</span> <span class="pre">…)</span></tt> to Python. The
sequence of <span class="concept">ParameterSpec</span>'s <tt class="docutils literal"><span class="pre">mpl::vector2&lt;tag::x(int),</span> <span class="pre">tag::y*(int)&gt;</span></tt> has
an <strong>arity range</strong> of [2,2], so we only need one forwarding overload.</p>
<pre class="literal-block">
@@ -772,16 +771,16 @@ BOOST_PYTHON_MODULE(…)
<!-- again, the undefined ``fwd`` identifier. -->
</div>
</div>
<div class="section" id="portability">
<h1><a class="toc-backref" href="#id15">Portability</a></h1>
<div class="section">
<h1><a class="toc-backref" href="#id15" id="portability" name="portability">Portability</a></h1>
<p>The Boost.Parameter Python binding library requires <em>partial template
specialization</em>.</p>
</div>
</div>
<div class="footer">
<hr class="footer" />
Generated on: 2011-11-08 21:40 UTC.
Generated by <a class="reference external" href="http://docutils.sourceforge.net/">Docutils</a> from <a class="reference external" href="http://docutils.sourceforge.net/rst.html">reStructuredText</a> source.
Generated on: 2007-01-03 16:40 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>

File diff suppressed because it is too large Load Diff

View File

@@ -71,27 +71,22 @@ __ ../../../../index.htm
-------------------------------------
:Authors: David Abrahams, Daniel Wallin
:Contact: dave@boost-consulting.com, daniel@boostpro.com
:organization: `BoostPro Computing`_
:date: $Date: 2005/07/17 19:53:01 $
:Contact: dave@boost-consulting.com, dalwan01@student.umu.se
:Organization: `Boost Consulting`_
:Date: $Date: 2005/07/18 20:34:31 $
:copyright: Copyright David Abrahams, Daniel Wallin
2005-2009. Distributed under the Boost Software License,
:Copyright: Copyright David Abrahams, Daniel Wallin 2005.
Distributed under the Boost Software License,
Version 1.0. (See accompanying file LICENSE_1_0.txt
or copy at http://www.boost.org/LICENSE_1_0.txt)
.. _`BoostPro Computing`: http://www.boostpro.com
.. _`Boost Consulting`: http://www.boost-consulting.com
.. _concepts: http://www.boost.org/more/generic_programming.html#concept
-------------------------------------
[Note: this tutorial does not cover all details of the library. Please see also the `reference documentation`__\ ]
__ reference.html
.. contents:: **Table of Contents**
:depth: 2
.. role:: concept
:class: concept
@@ -356,8 +351,8 @@ shown in the table below.
.. _`IncidenceGraph`: ../../../graph/doc/IncidenceGraph.html
.. _`VertexListGraph`: ../../../graph/doc/VertexListGraph.html
.. _`DFSVisitor`: ../../../graph/doc/DFSVisitor.html
.. _`ReadWritePropertyMap`: ../../../property_map/doc/ReadWritePropertyMap.html
.. _`ReadablePropertyMap`: ../../../property_map/doc/ReadablePropertyMap.html
.. _`ReadWritePropertyMap`: ../../../property_map/ReadWritePropertyMap.html
.. _`ReadablePropertyMap`: ../../../property_map/ReadablePropertyMap.html
Don't be intimidated by the information in the second and third
columns above. For the purposes of this exercise, you don't need
@@ -856,44 +851,6 @@ in parentheses *and preceded by an asterix*, as follows:
.. parsed-literal::
// We first need to define a few metafunction that we use in the
// predicates below.
template <class G>
struct traversal_category
{
typedef typename boost::graph_traits<G>::traversal_category type;
};
template <class G>
struct vertex_descriptor
{
typedef typename boost::graph_traits<G>::vertex_descriptor type;
};
template <class G>
struct value_type
{
typedef typename boost::property_traits<G>::value_type type;
};
template <class G>
struct key_type
{
typedef typename boost::property_traits<G>::key_type type;
};
template<class Size, class IndexMap>
boost::iterator_property_map<
boost::default_color_type\*, IndexMap
, boost::default_color_type, boost::default_color_type&
>
default_color_map(Size num_vertices, IndexMap const& index_map)
{
std::vector<boost::default_color_type> colors(num_vertices);
return &colors[0];
}
BOOST_PARAMETER_FUNCTION(
(void), depth_first_search, graphs
@@ -901,10 +858,12 @@ in parentheses *and preceded by an asterix*, as follows:
(graph
, **\ \*(boost::mpl::and_<
boost::is_convertible<
traversal_category<_>, boost::incidence_graph_tag
boost::graph_traits<_>::traversal_category
, boost::incidence_graph_tag
>
, boost::is_convertible<
traversal_category<_>, boost::vertex_list_graph_tag
boost::graph_traits<_>::traversal_category
, boost::vertex_list_graph_tag
>
>)** ))
@@ -912,21 +871,25 @@ in parentheses *and preceded by an asterix*, as follows:
(visitor, \*, boost::dfs_visitor<>()) // not checkable
(root_vertex
, (vertex_descriptor<graphs::graph::_>)
, (typename boost::graph_traits<graphs::graph::_>::vertex_descriptor)
, \*vertices(graph).first)
(index_map
, **\ \*(boost::mpl::and_<
boost::is_integral<value_type<_> >
boost::is_integral<
boost::property_traits<_>::value_type
>
, boost::is_same<
vertex_descriptor<graphs::graph::_>, key_type<_>
typename boost::graph_traits<graphs::graph::_>::vertex_descriptor
, boost::property_traits<_>::key_type
>
>)**
, get(boost::vertex_index,graph))
(in_out(color_map)
, **\ \*(boost::is_same<
vertex_descriptor<graphs::graph::_>, key_type<_>
typename boost::graph_traits<graphs::graph::_>::vertex_descriptor
, boost::property_traits<_>::key_type
>)**
, default_color_map(num_vertices(graph), index_map) )
)
@@ -934,8 +897,6 @@ in parentheses *and preceded by an asterix*, as follows:
.. @example.prepend('''
#include <boost/parameter.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/depth_first_search.hpp>
BOOST_PARAMETER_NAME((_graph, graphs) graph)
BOOST_PARAMETER_NAME((_visitor, graphs) visitor)
@@ -944,37 +905,38 @@ in parentheses *and preceded by an asterix*, as follows:
BOOST_PARAMETER_NAME((_color_map, graphs) color_map)
using boost::mpl::_;
''')
namespace boost
{
struct incidence_graph_tag {};
struct vertex_list_graph_tag {};
int vertex_index = 0;
template <class T>
struct graph_traits
{
typedef int traversal_category;
typedef int vertex_descriptor;
};
template <class T>
struct property_traits
{
typedef int value_type;
typedef int key_type;
};
template <class T = int>
struct dfs_visitor
{};
}''')
.. @example.append('''
{}
int main()
{
typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::directedS> G;
enum {u, v, w, x, y, z, N};
typedef std::pair<int, int> E;
E edges[] = {E(u, v), E(u, x), E(x, v), E(y, x), E(v, y), E(w, y),
E(w,z), E(z, z)};
G g(edges, edges + sizeof(edges) / sizeof(E), N);
depth_first_search(g);
depth_first_search(g, _root_vertex = (int)x);
}
''')
{}''')
.. @test('compile')
Note the use of the nested `tag::_`. This is a shortcut for::
value_type<boost::mpl::_2, tag>
.. @ignore()
Intended to be used to access preceding arguments types in the
predicates.
__ ../../../mpl/doc/refmanual/metafunction.html
We acknowledge that this signature is pretty hairy looking.
@@ -1145,7 +1107,7 @@ be used within the body of a class::
struct callable2
{
BOOST_PARAMETER_CONST_MEMBER_FUNCTION(
(void), call, tag, (required (arg1,(int))(arg2,(int))))
(void), operator(), tag, (required (arg1,(int))(arg2,(int))))
{
std::cout << arg1 << ", " << arg2 << std::endl;
}
@@ -1153,9 +1115,7 @@ be used within the body of a class::
.. @example.prepend('''
#include <boost/parameter.hpp>
#include <iostream>
using namespace boost::parameter;
''')
#include <iostream>''')
.. @test('compile')
@@ -1166,7 +1126,7 @@ arguments on to a separate implementation function::
struct callable2
{
BOOST_PARAMETER_CONST_MEMBER_FUNCTION(
(void), call, tag, (required (arg1,(int))(arg2,(int))))
(void), operator(), tag, (required (arg1,(int))(arg2,(int))))
{
call_impl(arg1,arg2);
}
@@ -1178,40 +1138,10 @@ arguments on to a separate implementation function::
#include <boost/parameter.hpp>
BOOST_PARAMETER_NAME(arg1)
BOOST_PARAMETER_NAME(arg2)
using namespace boost::parameter;
''')
BOOST_PARAMETER_NAME(arg2)''')
.. @test('compile')
Static Member Functions
=======================
To expose a static member function, simply insert the keyword
``static``” before the function name:
.. parsed-literal::
BOOST_PARAMETER_NAME(arg1)
struct somebody
{
BOOST_PARAMETER_MEMBER_FUNCTION(
(void), **static** f, tag, (optional (arg1,(int),0)))
{
std::cout << arg1 << std::endl;
}
};
.. @example.prepend('''
#include <boost/parameter.hpp>
#include <iostream>
using namespace boost::parameter;
''')
.. @test('compile')
------------------------------
Parameter-Enabled Constructors
------------------------------
@@ -1404,10 +1334,10 @@ separately)::
using boost::mpl::_;
typedef parameter::parameters<
required<tag::class_type, boost::is_class<_> >
, parameter::optional<tag::base_list, mpl::is_sequence<_> >
, parameter::optional<tag::held_type>
, parameter::optional<tag::copyable>
required<tag::class_type, is_class<_> >
, optional<tag::base_list, mpl::is_sequence<_> >
, optional<tag::held_type>
, optional<tag::copyable>
> class_signature;
}}
@@ -1416,7 +1346,6 @@ separately)::
#include <boost/parameter.hpp>
#include <boost/mpl/is_sequence.hpp>
#include <boost/noncopyable.hpp>
#include <boost/type_traits/is_class.hpp>
#include <memory>
using namespace boost::parameter;
@@ -1443,13 +1372,12 @@ separately)::
Argument Packs and Parameter Extraction
---------------------------------------
Next, within the body of ``class_`` , we use the |ParameterSpec|\ 's
nested ``::bind< … >`` template to bundle the actual arguments into an
|ArgumentPack|_ type, and then use the library's ``value_type< … >``
metafunction to extract “logical parameters”. ``value_type< … >`` is
a lot like ``binding< … >``, but no reference is added to the actual
argument type. Note that defaults are specified by passing it an
optional third argument::
Next, within the body of ``class_`` , we use the |ParameterSpec|\
's nested ``::bind< … >`` template to bundle the actual arguments
into an |ArgumentPack|_ type, and then use the library's ``binding<
… >`` metafunction to extract “logical parameters”. Note that
defaults are specified by supplying an optional third argument to
``binding< … >``::
namespace boost { namespace python {
@@ -1467,16 +1395,16 @@ optional third argument::
args;
// Extract first logical parameter.
typedef typename parameter::value_type<
typedef typename parameter::binding<
args, tag::class_type>::type class_type;
typedef typename parameter::value_type<
typedef typename parameter::binding<
args, tag::base_list, bases<> >::type base_list;
typedef typename parameter::value_type<
typedef typename parameter::binding<
args, tag::held_type, class_type>::type held_type;
typedef typename parameter::value_type<
typedef typename parameter::binding<
args, tag::copyable, void>::type copyable;
};
@@ -1578,12 +1506,12 @@ parameters deducible::
typedef parameter::parameters<
required<tag::class_type, is_class<_> >
, parameter::optional<
, optional<
deduced<tag::base_list>
, is_base_and_derived<detail::bases_base,_>
>
, parameter::optional<
, optional<
deduced<tag::held_type>
, mpl::not_<
mpl::or_<
@@ -1593,12 +1521,11 @@ parameters deducible::
>
>
, parameter::optional<deduced<tag::copyable>, is_same<noncopyable,_> >
, optional<deduced<tag::copyable>, is_same<noncopyable,_> >
> class_signature;
.. @example.prepend('''
#include <boost/type_traits/is_class.hpp>
namespace boost { namespace python {''')
.. @example.append('''
@@ -1616,16 +1543,16 @@ parameters deducible::
args;
// Extract first logical parameter.
typedef typename parameter::value_type<
typedef typename parameter::binding<
args, tag::class_type>::type class_type;
typedef typename parameter::value_type<
typedef typename parameter::binding<
args, tag::base_list, bases<> >::type base_list;
typedef typename parameter::value_type<
typedef typename parameter::binding<
args, tag::held_type, class_type>::type held_type;
typedef typename parameter::value_type<
typedef typename parameter::binding<
args, tag::copyable, void>::type copyable;
};
@@ -1846,13 +1773,15 @@ function template and allow *it* to do type deduction::
Occasionally one needs to deduce argument types without an extra
layer of function call. For example, suppose we wanted to return
twice the value of the ``index`` parameter? In that
case we can use the ``value_type< … >`` metafunction introduced
case we can use the ``binding< … >`` metafunction introduced
`earlier`__::
BOOST_PARAMETER_NAME(index)
template <class ArgumentPack>
typename parameter::value_type<ArgumentPack, tag::index, int>::type
typename remove_reference<
typename parameter::binding<ArgumentPack, tag::index, int>::type
>::type
twice_index(ArgumentPack const& args)
{
return 2 * args[_index|42];
@@ -1866,20 +1795,39 @@ case we can use the ``value_type< … >`` metafunction introduced
#include <cassert>
namespace parameter = boost::parameter;
''')
using boost::remove_reference;''')
Note that the ``remove_reference< … >`` dance is necessary because
``binding< … >`` will return a reference type when the argument
is bound in the argument pack. If we don't strip the reference we
end up returning a reference to the temporary created in the ``2 * …``
expression. A convenient shortcut would be to use the ``value_type< … >``
metafunction:
.. parsed-literal::
template <class ArgumentPack>
typename **parameter::value_type<ArgumentPack, tag::index, int>**::type
twice_index(ArgumentPack const& args)
{
return 2 * args[_index|42];
}
.. @example.wrap('namespace with_value_type {', '''
int six = twice_index(_index = 3);
}''')
.. TODO: binding<> returns a reference. We should use value_type<> here.
.. @example.append('''
int main()
{
assert(six == 6);
assert(with_value_type::six == 6);
}''')
.. @test('run', howmany='all')
Note that if we had used ``binding< … >`` rather than ``value_type< …
>``, we would end up returning a reference to the temporary created in
the ``2 * …`` expression.
__ binding_intro_
Lazy Default Computation
@@ -1935,10 +1883,12 @@ object.
.. parsed-literal::
using boost::bind;
using boost::ref;
typename parameter::binding<
ArgumentPack, tag::s3, std::string
>::type s3 = args[_s3
**|| boost::bind(std::plus<std::string>(), boost::ref(s1), boost::ref(s2))** ];
>::type s3 = args[_s3 **|| bind(std::plus<std::string>(), ref(s1), ref(s2))** ];
.. @example.prepend('''
#include <boost/bind.hpp>

View File

@@ -2,13 +2,13 @@
The Boost Parameter Library Python Binding Documentation
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
:Authors: David Abrahams, Daniel Wallin
:Contact: dave@boost-consulting.com, daniel@boostpro.com
:organization: `BoostPro Computing`_
:Authors: Daniel Wallin
:Contact: dalwan01@student.umu.se
:organization: `Boost Consulting`_
:date: $Date$
:copyright: Copyright David Abrahams, Daniel Wallin
2005-2009. Distributed under the Boost Software License,
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)
@@ -22,7 +22,7 @@
__ ../../../../index.htm
.. _`BoostPro Computing`: http://www.boostpro.com
.. _`Boost Consulting`: http://www.boost-consulting.com
.. role:: class

View File

@@ -3,12 +3,12 @@
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
:Authors: David Abrahams, Daniel Wallin
:Contact: dave@boost-consulting.com, daniel@boostpro.com
:organization: `BoostPro Computing`_
:Contact: dave@boost-consulting.com, dalwan01@student.umu.se
:organization: `Boost Consulting`_
:date: $Date: 2005/07/17 19:53:01 $
:copyright: Copyright David Abrahams, Daniel Wallin
2005-2009. Distributed under the Boost Software License,
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)
@@ -19,7 +19,7 @@
__ ../../../../index.htm
.. _`BoostPro Computing`: http://www.boostpro.com
.. _`Boost Consulting`: http://www.boost-consulting.com
//////////////////////////////////////////////////////////////////////////////
@@ -803,8 +803,8 @@ Expands to:
return ##\ *tag-name*;
}
typedef *unspecified* _;
typedef *unspecified* _1;
typedef *implementation defined* _;
typedef *implementation defined* _1;
};
}
@@ -824,8 +824,8 @@ Expands to:
return ##\ *name*;
}
typedef *unspecified* _;
typedef *unspecified* _1;
typedef *implementation defined* _;
typedef *implementation defined* _1;
};
}
@@ -970,7 +970,7 @@ already ``#defined``.
__ ../../../../boost/parameter/config.hpp
:Default Value: ``8``
:Default Value: ``5``
Tutorial
========

View File

@@ -11,7 +11,7 @@
#include <boost/parameter/aux_/default.hpp>
#include <boost/parameter/aux_/parameter_requirements.hpp>
#include <boost/parameter/aux_/yesno.hpp>
#include <boost/parameter/aux_/is_maybe.hpp>
#include <boost/parameter/aux_/maybe.hpp>
#include <boost/parameter/config.hpp>
#include <boost/mpl/apply.hpp>
@@ -22,11 +22,12 @@
#include <boost/type_traits/add_reference.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/type_traits/is_base_and_derived.hpp>
#include <boost/preprocessor/repetition/enum_params.hpp>
#include <boost/preprocessor/repetition/enum_binary_params.hpp>
#include <boost/preprocessor/facilities/intercept.hpp>
namespace boost { namespace parameter {
namespace boost { namespace parameter {
// Forward declaration for aux::arg_list, below.
template<class T> struct keyword;
@@ -46,7 +47,7 @@ struct lambda_tag;
// declarations to build member function overload sets that can
// match against keywords.
//
// MPL sequence support
struct arg_list_tag;
@@ -83,14 +84,14 @@ struct empty_arg_list
template <class KW>
static no_tag has_key(KW*);
#endif
#if BOOST_WORKAROUND(BOOST_MSVC, <= 1300) \
|| (BOOST_WORKAROUND(__GNUC__, < 3)) \
|| BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
// The overload set technique doesn't work with these older
// compilers, so they need some explicit handholding.
// A metafunction class that, given a keyword, returns the type
// of the base sublist whose get() function can produce the
// value for that key
@@ -159,6 +160,11 @@ no_tag operator*(empty_arg_list, KW*);
template <class KW, class T>
struct tagged_argument;
template <class T>
struct is_maybe
: is_base_and_derived<maybe_base, T>
{};
template <class T>
struct get_reference
{
@@ -206,9 +212,9 @@ struct arg_list : Next
// Create a new list by prepending arg to a copy of tail. Used
// when incrementally building this structure with the comma
// operator.
arg_list(TaggedArg head, Next const& tail)
arg_list(TaggedArg arg, Next const& tail)
: Next(tail)
, arg(head)
, arg(arg)
{}
// A metafunction class that, given a keyword and a default
@@ -236,8 +242,8 @@ struct arg_list : Next
// 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)
# define BOOST_PARAMETER_CALL_HAS_KEY(next, key) next::has_key((key*)0)
# endif
BOOST_MPL_ASSERT_MSG(
@@ -252,7 +258,7 @@ struct arg_list : Next
// specific arguments by name
//
// Helpers that handle the case when TaggedArg is
// Helpers that handle the case when TaggedArg is
// empty<T>.
template <class D>
reference get_default(D const&, mpl::false_) const
@@ -332,7 +338,7 @@ struct arg_list : Next
template <class Default>
reference get(default_<key_type,Default> const& d) const
{
return get_default(d, holds_maybe());
return get_default(d, holds_maybe());
}
template <class Default>
@@ -340,7 +346,7 @@ struct arg_list : Next
{
return arg.value;
}
#else
reference operator[](keyword<key_type> const&) const
@@ -395,7 +401,7 @@ struct arg_list : Next
// Comma operator to compose argument list without using parameters<>.
// Useful for argument lists with undetermined length.
template <class KW, class T2>
arg_list<tagged_argument<KW, T2>, self>
arg_list<tagged_argument<KW, T2>, self>
operator,(tagged_argument<KW,T2> x) const
{
return arg_list<tagged_argument<KW,T2>, self>(x, *this);
@@ -409,7 +415,7 @@ struct arg_list : Next
#if BOOST_WORKAROUND(BOOST_MSVC, <= 1300) // ETI workaround
template <> struct arg_list<int,int> {};
#endif
#endif
// MPL sequence support
template <class ArgumentPack>
@@ -419,7 +425,7 @@ struct arg_list_iterator
// The incremented iterator
typedef arg_list_iterator<typename ArgumentPack::tail_type> next;
// dereferencing yields the key type
typedef typename ArgumentPack::key_type type;
};

View File

@@ -40,11 +40,11 @@ struct use_default_tag {};
// X(something, *(predicate))
// X(something, (int))
template <class T, class Args>
template <class T>
struct cast;
template <class Args>
struct cast<void*, Args>
template <>
struct cast<void*>
{
static use_default_tag execute(use_default_tag)
{
@@ -73,39 +73,27 @@ struct cast<void*, Args>
typedef void* voidstar;
template <class T, class Args>
struct cast<voidstar(T), Args>
: cast<void*, Args>
template <class T>
struct cast<voidstar(T)>
: cast<void*>
{
};
#else
template <class T, class Args>
struct cast<void*(T), Args>
: cast<void*, Args>
template <class T>
struct cast<void*(T)>
: cast<void*>
{
};
#endif
// This is a hack used in cast<> to turn the user supplied type,
// which may or may not be a placeholder expression into one, so
// that it will be properly evaluated by mpl::apply.
template <class T, class Dummy = mpl::_1>
struct as_placeholder_expr
template <class T>
struct cast<void(T)>
{
typedef T type;
};
template <class T, class Args>
struct cast<void(T), Args>
{
typedef typename mpl::apply2<
as_placeholder_expr<T>, Args, Args>::type type0;
typedef typename boost::add_reference<
typename boost::remove_const<type0>::type
typename boost::remove_const<T>::type
>::type reference;
static use_default_tag execute(use_default_tag)
@@ -118,7 +106,7 @@ struct cast<void(T), Args>
return use_default_tag();
}
static type0 execute(type0 value)
static T execute(T value)
{
return value;
}
@@ -130,9 +118,9 @@ struct cast<void(T), Args>
}
};
# define BOOST_PARAMETER_FUNCTION_CAST(value, predicate, args) \
boost::parameter::aux::cast<void predicate, args>::remove_const( \
boost::parameter::aux::cast<void predicate, args>::execute(value) \
# define BOOST_PARAMETER_FUNCTION_CAST(value, predicate) \
boost::parameter::aux::cast<void predicate>::remove_const( \
boost::parameter::aux::cast<void predicate>::execute(value) \
)
# endif

View File

@@ -1,26 +0,0 @@
// Copyright Daniel Wallin, David Abrahams 2010. 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_IS_MAYBE_050329_HPP
#define BOOST_PARAMETER_IS_MAYBE_050329_HPP
#include <boost/type_traits/is_base_and_derived.hpp>
namespace boost {
namespace parameter {
namespace aux {
struct maybe_base {};
template <class T>
struct is_maybe
: is_base_and_derived<maybe_base, T>
{};
} // namespace aux
} // namespace parameter
} // namespace boost
#endif // BOOST_PARAMETER_IS_MAYBE_050329_HPP

View File

@@ -2,41 +2,21 @@
// 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)
//
// 2009.10.21 TDS remove depenency on boost::python::detail::referent_storage
//
#ifndef BOOST_PARAMETER_MAYBE_091021_HPP
# define BOOST_PARAMETER_MAYBE_091021_HPP
#ifndef BOOST_PARAMETER_MAYBE_060211_HPP
# define BOOST_PARAMETER_MAYBE_060211_HPP
# include <boost/mpl/if.hpp>
# include <boost/mpl/identity.hpp>
# include <boost/type_traits/is_reference.hpp>
# include <boost/type_traits/add_reference.hpp>
# include <boost/optional.hpp>
# include <boost/aligned_storage.hpp>
# include <boost/python/detail/referent_storage.hpp>
# include <boost/type_traits/remove_cv.hpp>
# include <boost/type_traits/add_const.hpp>
# include <boost/parameter/aux_/is_maybe.hpp>
namespace boost { namespace parameter { namespace aux {
template <class T> struct referent_size;
template <class T>
struct referent_size<T&>
{
BOOST_STATIC_CONSTANT(std::size_t, value = sizeof(T));
};
// A metafunction returning a POD type which can store U, where T ==
// U&. If T is not a reference type, returns a POD which can store T.
template <class T>
struct referent_storage
{
typedef typename boost::aligned_storage<
referent_size<T>::value
>::type type;
};
struct maybe_base {};
template <class T>
struct maybe : maybe_base
@@ -44,17 +24,17 @@ struct maybe : maybe_base
typedef typename add_reference<
# if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
T const
# else
# else
typename add_const<T>::type
# endif
# endif
>::type reference;
typedef typename remove_cv<
BOOST_DEDUCED_TYPENAME remove_reference<reference>::type
>::type non_cv_value;
explicit maybe(T value_)
: value(value_)
explicit maybe(T value)
: value(value)
, constructed(false)
{}
@@ -68,28 +48,28 @@ struct maybe : maybe_base
this->destroy();
}
reference construct(reference value_) const
reference construct(reference value) const
{
return value_;
return value;
}
template <class U>
reference construct2(U const& value_) const
reference construct2(U const& value) const
{
new (m_storage.address()) non_cv_value(value_);
new (m_storage.bytes) non_cv_value(value);
constructed = true;
return *(non_cv_value*)m_storage.address();
return *(non_cv_value*)m_storage.bytes;
}
template <class U>
reference construct(U const& value_) const
reference construct(U const& value) const
{
return this->construct2(value_);
return this->construct2(value);
}
void destroy()
{
((non_cv_value*)m_storage.address())->~non_cv_value();
((non_cv_value*)m_storage.bytes)->~non_cv_value();
}
typedef reference(maybe<T>::*safe_bool)() const;
@@ -107,9 +87,7 @@ struct maybe : maybe_base
private:
boost::optional<T> value;
mutable bool constructed;
mutable typename referent_storage<
mutable typename boost::python::detail::referent_storage<
reference
>::type m_storage;
};

View File

@@ -7,7 +7,7 @@
#define BOOST_PARAMETER_CONFIG_050403_HPP
#ifndef BOOST_PARAMETER_MAX_ARITY
# define BOOST_PARAMETER_MAX_ARITY 8
# define BOOST_PARAMETER_MAX_ARITY 5
#endif
#endif // BOOST_PARAMETER_CONFIG_050403_HPP

View File

@@ -27,7 +27,7 @@ namespace boost { namespace parameter { namespace aux {
// Tag type passed to MPL lambda.
struct lambda_tag;
struct name_tag_base
struct name_tag_base
{};
template <class Tag>
@@ -46,7 +46,7 @@ namespace boost { namespace mpl {
template <class T>
struct lambda<
T
, typename boost::enable_if<
, typename enable_if<
parameter::aux::is_name_tag<T>, parameter::aux::lambda_tag
>::type
>

View File

@@ -16,7 +16,6 @@
# include <boost/preprocessor/repetition/repeat_from_to.hpp>
# include <boost/preprocessor/comparison/equal.hpp>
# include <boost/preprocessor/control/if.hpp>
# include <boost/preprocessor/control/iif.hpp>
# include <boost/preprocessor/control/expr_if.hpp>
# include <boost/preprocessor/repetition/enum_params.hpp>
# include <boost/preprocessor/repetition/enum_binary_params.hpp>
@@ -27,7 +26,6 @@
# include <boost/preprocessor/tuple/elem.hpp>
# include <boost/preprocessor/tuple/eat.hpp>
# include <boost/preprocessor/seq/fold_left.hpp>
# include <boost/preprocessor/seq/push_back.hpp>
# include <boost/preprocessor/seq/size.hpp>
# include <boost/preprocessor/seq/enum.hpp>
# include <boost/preprocessor/seq/push_back.hpp>
@@ -363,7 +361,7 @@ struct funptr_predicate<void**>
# define BOOST_PARAMETER_FUNCTION_FWD_MATCH_Z(z, name, parameters, n) \
, typename boost::parameter::aux::match< \
parameters, BOOST_PP_ENUM_PARAMS(n, ParameterArgumentType) \
>::type = parameters()
>::type boost_parameter_enabler_argument = parameters()
# else
# define BOOST_PARAMETER_FUNCTION_FWD_MATCH_Z(z, name, parameters, n)
# endif
@@ -701,7 +699,6 @@ struct funptr_predicate<void**>
) \
] \
, BOOST_PARAMETER_FN_ARG_PRED(arg) \
, Args \
)
# define BOOST_PARAMETER_FUNCTION_DEFAULT_FUNCTION_BODY(name, n, split_args, tag_namespace) \
@@ -729,7 +726,6 @@ struct funptr_predicate<void**>
BOOST_PARAMETER_FUNCTION_CAST( \
boost::parameter::aux::as_lvalue(BOOST_PARAMETER_FN_ARG_DEFAULT(arg), 0L) \
, BOOST_PARAMETER_FN_ARG_PRED(arg) \
, Args \
)
# define BOOST_PARAMETER_FUNCTION_DEFAULT_EVAL_DEFAULT_BODY(name, n, split_args, tag_ns, const_) \
@@ -845,7 +841,6 @@ struct funptr_predicate<void**>
boost::parameter::keyword<tag_ns::BOOST_PARAMETER_FN_ARG_KEYWORD(arg)>::instance \
] \
, BOOST_PARAMETER_FN_ARG_PRED(arg) \
, Args \
)
// Generates the function template that recives a ArgumentPack, and then

View File

@@ -9,8 +9,6 @@ import python ;
project boost/parameter
: default-build <warnings>off
;
build-project literate ;
test-suite "parameter"
: [ run basics.cpp ]

View File

@@ -1,33 +0,0 @@
import testing ;
run extracting-parameter-types0.cpp ;
run extracting-parameter-types1.cpp ;
compile template-keywords0.cpp ;
compile template-keywords1.cpp ;
compile top-level0.cpp ;
compile headers-and-namespaces0.cpp ;
compile predicate-requirements0.cpp ;
compile handling-out-parameters0.cpp ;
compile writing-the-function0.cpp ;
run building-argumentpacks0.cpp ;
compile defining-the-keywords0.cpp ;
compile defining-the-keywords1.cpp ;
compile exercising-the-code-so-far0.cpp ;
run lazy-default-computation0.cpp ;
run lazy-default-computation1.cpp ;
run namespaces0.cpp ;
run namespaces1.cpp ;
run namespaces2.cpp ;
run namespaces3.cpp ;
compile optional-parameters0.cpp ;
compile static-member-functions0.cpp ;
run parameter-enabled-constructors0.cpp ;
compile required-parameters0.cpp ;
compile class-template-skeleton0.cpp ;
compile deduced-template-parameters0.cpp ;
compile deduced-parameters0.cpp ;
compile default-expression-evaluation0.cpp ;
compile parameter-enabled-member-functions0.cpp ;
compile parameter-enabled-member-functions1.cpp ;
run fine-grained-name-control0.cpp ;

View File

@@ -1,6 +0,0 @@
These tests were extracted from the Boost.Parameter documentation
with:
python ../../../../tools/litre/tool.py \
../../../../libs/parameter/doc/index.rst \
--dump_dir=.

View File

@@ -1,53 +0,0 @@
#line 1744 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
#include <boost/parameter.hpp>
#include <iostream>
#line 1733 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
BOOST_PARAMETER_NAME(index)
template <class ArgumentPack>
int print_index(ArgumentPack const& args)
{
std::cout << "index = " << args[_index] << std::endl;
return 0;
}
int x = print_index(_index = 3); // prints "index = 3"
#line 1752 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
BOOST_PARAMETER_NAME(name)
template <class ArgumentPack>
int print_name_and_index(ArgumentPack const& args)
{
std::cout << "name = " << args[_name] << "; ";
return print_index(args);
}
int y = print_name_and_index((_index = 3, _name = "jones"));
#line 1787 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
namespace parameter = boost::parameter;
using parameter::required;
using parameter::optional;
using boost::is_convertible;
using boost::mpl::_;
#line 1773 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
parameter::parameters<
required<tag::name, is_convertible<_,char const*> >
, optional<tag::index, is_convertible<_,int> >
> spec;
char const sam[] = "sam";
int twelve = 12;
int z0 = print_name_and_index( spec(sam, twelve) );
int z1 = print_name_and_index(
spec(_index=12, _name="sam")
);
#line 1794 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
int main()
{}

View File

@@ -1,18 +0,0 @@
#line 1387 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
#include <boost/parameter.hpp>
#line 1373 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
namespace boost { namespace python {
template <
class A0
, class A1 = parameter::void_
, class A2 = parameter::void_
, class A3 = parameter::void_
>
struct class_
{
};
}}

View File

@@ -1,80 +0,0 @@
#line 1062 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
#include <boost/parameter.hpp>
BOOST_PARAMETER_NAME(name)
BOOST_PARAMETER_NAME(func)
BOOST_PARAMETER_NAME(docstring)
BOOST_PARAMETER_NAME(keywords)
BOOST_PARAMETER_NAME(policies)
struct default_call_policies
{};
struct no_keywords
{};
struct keywords
{};
template <class T>
struct is_keyword_expression
: boost::mpl::false_
{};
template <>
struct is_keyword_expression<keywords>
: boost::mpl::true_
{};
default_call_policies some_policies;
void f()
{}
#line 1029 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
namespace mpl = boost::mpl;
BOOST_PARAMETER_FUNCTION(
(void), def, tag,
(required (name,(char const*)) (func,*) ) // nondeduced
(deduced
(optional
(docstring, (char const*), "")
(keywords
, *(is_keyword_expression<mpl::_>) // see 5
, no_keywords())
(policies
, *(mpl::not_<
mpl::or_<
boost::is_convertible<mpl::_, char const*>
, is_keyword_expression<mpl::_> // see 5
>
>)
, default_call_policies()
)
)
)
)
{
}
#line 1111 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
int main()
{
#line 1108 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
def("f", &f, some_policies, "Documentation for f");
def("f", &f, "Documentation for f", some_policies);
#line 1121 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
def(
"f", &f
, _policies = some_policies, "Documentation for f");
#line 1124 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
}

View File

@@ -1,111 +0,0 @@
#line 1557 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
#include <boost/parameter.hpp>
#include <boost/mpl/is_sequence.hpp>
#include <boost/noncopyable.hpp>
#include <memory>
using namespace boost::parameter;
using boost::mpl::_;
namespace boost { namespace python {
BOOST_PARAMETER_TEMPLATE_KEYWORD(class_type)
BOOST_PARAMETER_TEMPLATE_KEYWORD(base_list)
BOOST_PARAMETER_TEMPLATE_KEYWORD(held_type)
BOOST_PARAMETER_TEMPLATE_KEYWORD(copyable)
}}
#line 1546 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
namespace boost { namespace python {
namespace detail { struct bases_base {}; }
template <class A0 = void, class A1 = void, class A2 = void >
struct bases : detail::bases_base
{};
}}
#line 1600 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
#include <boost/type_traits/is_class.hpp>
namespace boost { namespace python {
#line 1578 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
typedef parameter::parameters<
required<tag::class_type, is_class<_> >
, parameter::optional<
deduced<tag::base_list>
, is_base_and_derived<detail::bases_base,_>
>
, parameter::optional<
deduced<tag::held_type>
, mpl::not_<
mpl::or_<
is_base_and_derived<detail::bases_base,_>
, is_same<noncopyable,_>
>
>
>
, parameter::optional<deduced<tag::copyable>, is_same<noncopyable,_> >
> class_signature;
#line 1604 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
template <
class A0
, class A1 = parameter::void_
, class A2 = parameter::void_
, class A3 = parameter::void_
>
struct class_
{
// Create ArgumentPack
typedef typename
class_signature::bind<A0,A1,A2,A3>::type
args;
// Extract first logical parameter.
typedef typename parameter::value_type<
args, tag::class_type>::type class_type;
typedef typename parameter::value_type<
args, tag::base_list, bases<> >::type base_list;
typedef typename parameter::value_type<
args, tag::held_type, class_type>::type held_type;
typedef typename parameter::value_type<
args, tag::copyable, void>::type copyable;
};
}}
#line 1644 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
struct B {};
struct D {};
using boost::python::bases;
#line 1640 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
typedef boost::python::class_<B, boost::noncopyable> c1;
typedef boost::python::class_<D, std::auto_ptr<D>, bases<B> > c2;
#line 1650 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
BOOST_MPL_ASSERT((boost::is_same<c1::class_type, B>));
BOOST_MPL_ASSERT((boost::is_same<c1::base_list, bases<> >));
BOOST_MPL_ASSERT((boost::is_same<c1::held_type, B>));
BOOST_MPL_ASSERT((
boost::is_same<c1::copyable, boost::noncopyable>
));
BOOST_MPL_ASSERT((boost::is_same<c2::class_type, D>));
BOOST_MPL_ASSERT((boost::is_same<c2::base_list, bases<B> >));
BOOST_MPL_ASSERT((
boost::is_same<c2::held_type, std::auto_ptr<D> >
));
BOOST_MPL_ASSERT((boost::is_same<c2::copyable, void>));

View File

@@ -1,41 +0,0 @@
#line 730 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
#include <boost/parameter.hpp>
#include <iostream>
BOOST_PARAMETER_NAME(graph)
BOOST_PARAMETER_NAME(visitor)
BOOST_PARAMETER_NAME(root_vertex)
BOOST_PARAMETER_NAME(index_map)
BOOST_PARAMETER_NAME(color_map)
#line 702 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
#include <boost/graph/depth_first_search.hpp> // for dfs_visitor
BOOST_PARAMETER_FUNCTION(
(void), depth_first_search, tag
, (required
(graph, *)
(visitor, *)
(root_vertex, *)
(index_map, *)
(color_map, *)
)
)
{
std::cout << "graph=" << graph << std::endl;
std::cout << "visitor=" << visitor << std::endl;
std::cout << "root_vertex=" << root_vertex << std::endl;
std::cout << "index_map=" << index_map << std::endl;
std::cout << "color_map=" << color_map << std::endl;
}
int main()
{
depth_first_search(1, 2, 3, 4, 5);
depth_first_search(
"1", '2', _color_map = '5',
_index_map = "4", _root_vertex = "3");
}

View File

@@ -1,11 +0,0 @@
#line 397 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
#include <boost/parameter/name.hpp>
namespace graphs
{
BOOST_PARAMETER_NAME(graph) // Note: no semicolon
BOOST_PARAMETER_NAME(visitor)
BOOST_PARAMETER_NAME(root_vertex)
BOOST_PARAMETER_NAME(index_map)
BOOST_PARAMETER_NAME(color_map)
}

View File

@@ -1,15 +0,0 @@
#line 424 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
#include <boost/parameter/keyword.hpp>
#line 413 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
namespace graphs
{
namespace tag { struct graph; } // keyword tag type
namespace // unnamed
{
// A reference to the keyword object
boost::parameter::keyword<tag::graph>& _graph
= boost::parameter::keyword<tag::graph>::get();
}
}

View File

@@ -1,101 +0,0 @@
#line 1415 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
#include <boost/parameter.hpp>
#include <boost/mpl/is_sequence.hpp>
#include <boost/noncopyable.hpp>
#include <boost/type_traits/is_class.hpp>
#include <memory>
using namespace boost::parameter;
namespace boost { namespace python {
BOOST_PARAMETER_TEMPLATE_KEYWORD(class_type)
BOOST_PARAMETER_TEMPLATE_KEYWORD(base_list)
BOOST_PARAMETER_TEMPLATE_KEYWORD(held_type)
BOOST_PARAMETER_TEMPLATE_KEYWORD(copyable)
template <class B = int>
struct bases
{};
}}
#line 1402 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
namespace boost { namespace python {
using boost::mpl::_;
typedef parameter::parameters<
required<tag::class_type, boost::is_class<_> >
, parameter::optional<tag::base_list, mpl::is_sequence<_> >
, parameter::optional<tag::held_type>
, parameter::optional<tag::copyable>
> class_signature;
}}
#line 1454 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
namespace boost { namespace python {
template <
class A0
, class A1 = parameter::void_
, class A2 = parameter::void_
, class A3 = parameter::void_
>
struct class_
{
// Create ArgumentPack
typedef typename
class_signature::bind<A0,A1,A2,A3>::type
args;
// Extract first logical parameter.
typedef typename parameter::value_type<
args, tag::class_type>::type class_type;
typedef typename parameter::value_type<
args, tag::base_list, bases<> >::type base_list;
typedef typename parameter::value_type<
args, tag::held_type, class_type>::type held_type;
typedef typename parameter::value_type<
args, tag::copyable, void>::type copyable;
};
}}
#line 1 "None"
using boost::python::class_type;
using boost::python::copyable;
using boost::python::held_type;
using boost::python::base_list;
using boost::python::bases;
struct B {};
struct D {};
#line 1495 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
typedef boost::python::class_<
class_type<B>, copyable<boost::noncopyable>
> c1;
typedef boost::python::class_<
D, held_type<std::auto_ptr<D> >, base_list<bases<B> >
> c2;
#line 1515 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
BOOST_MPL_ASSERT((boost::is_same<c1::class_type, B>));
BOOST_MPL_ASSERT((boost::is_same<c1::base_list, bases<> >));
BOOST_MPL_ASSERT((boost::is_same<c1::held_type, B>));
BOOST_MPL_ASSERT((
boost::is_same<c1::copyable, boost::noncopyable>
));
BOOST_MPL_ASSERT((boost::is_same<c2::class_type, D>));
BOOST_MPL_ASSERT((boost::is_same<c2::base_list, bases<B> >));
BOOST_MPL_ASSERT((
boost::is_same<c2::held_type, std::auto_ptr<D> >
));
BOOST_MPL_ASSERT((boost::is_same<c2::copyable, void>));

View File

@@ -1,31 +0,0 @@
#line 1830 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
#include <boost/parameter.hpp>
#include <cassert>
#line 1813 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
BOOST_PARAMETER_NAME(name)
BOOST_PARAMETER_NAME(index)
template <class Name, class Index>
int deduce_arg_types_impl(Name& name, Index& index)
{
Name& n2 = name; // we know the types
Index& i2 = index;
return index;
}
template <class ArgumentPack>
int deduce_arg_types(ArgumentPack const& args)
{
return deduce_arg_types_impl(args[_name], args[_index|42]);
}
#line 1834 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
int a1 = deduce_arg_types((_name = "foo"));
int a2 = deduce_arg_types((_name = "foo", _index = 3));
int main()
{
assert(a1 == 42);
assert(a2 == 3);
}

View File

@@ -1,24 +0,0 @@
#line 1863 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
#include <boost/parameter.hpp>
#include <boost/type_traits/remove_reference.hpp>
#include <cassert>
namespace parameter = boost::parameter;
#line 1852 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
BOOST_PARAMETER_NAME(index)
template <class ArgumentPack>
typename parameter::value_type<ArgumentPack, tag::index, int>::type
twice_index(ArgumentPack const& args)
{
return 2 * args[_index|42];
}
int six = twice_index(_index = 3);
#line 1871 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
int main()
{
assert(six == 6);
}

View File

@@ -1,18 +0,0 @@
#line 1703 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
#include <boost/parameter.hpp>
#line 1693 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
BOOST_PARAMETER_NAME((pass_foo, keywords) foo)
BOOST_PARAMETER_FUNCTION(
(int), f,
keywords, (required (foo, *)))
{
return foo + 1;
}
int x = f(pass_foo = 41);
#line 1704 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
int main()
{}

View File

@@ -1,33 +0,0 @@
#line 620 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
#include <boost/parameter.hpp>
namespace boost
{
int vertex_index = 0;
template <class T = int>
struct dfs_visitor
{};
}
BOOST_PARAMETER_NAME(graph)
BOOST_PARAMETER_NAME(visitor)
BOOST_PARAMETER_NAME(root_vertex)
BOOST_PARAMETER_NAME(index_map)
BOOST_PARAMETER_NAME(color_map)
BOOST_PARAMETER_FUNCTION((void), f, tag,
(required (graph, *))
#line 612 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
(optional
(visitor, *, boost::dfs_visitor<>())
(root_vertex, *, *vertices(graph).first)
(index_map, *, get(boost::vertex_index,graph))
(in_out(color_map), *,
default_color_map(num_vertices(graph), index_map) )
)
#line 642 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
) {}

View File

@@ -1,5 +0,0 @@
#line 274 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
#include <boost/parameter/keyword.hpp>
#line 283 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
using boost::parameter::keyword;

View File

@@ -1,27 +0,0 @@
#line 1911 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
#include <boost/parameter.hpp>
#include <string>
namespace parameter = boost::parameter;
#line 1894 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
BOOST_PARAMETER_NAME(s1)
BOOST_PARAMETER_NAME(s2)
BOOST_PARAMETER_NAME(s3)
template <class ArgumentPack>
std::string f(ArgumentPack const& args)
{
std::string const& s1 = args[_s1];
std::string const& s2 = args[_s2];
typename parameter::binding<
ArgumentPack,tag::s3,std::string
>::type s3 = args[_s3|(s1+s2)]; // always constructs s1+s2
return s3;
}
std::string x = f((_s1="hello,", _s2=" world", _s3="hi world"));
#line 1917 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
int main()
{}

View File

@@ -1,33 +0,0 @@
#line 1943 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
#include <boost/bind.hpp>
#include <boost/ref.hpp>
#include <boost/parameter.hpp>
#include <string>
#include <functional>
namespace parameter = boost::parameter;
BOOST_PARAMETER_NAME(s1)
BOOST_PARAMETER_NAME(s2)
BOOST_PARAMETER_NAME(s3)
template <class ArgumentPack>
std::string f(ArgumentPack const& args)
{
std::string const& s1 = args[_s1];
std::string const& s2 = args[_s2];
#line 1938 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
typename parameter::binding<
ArgumentPack, tag::s3, std::string
>::type s3 = args[_s3
|| boost::bind(std::plus<std::string>(), boost::ref(s1), boost::ref(s2)) ];
#line 1962 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
return s3;
}
std::string x = f((_s1="hello,", _s2=" world", _s3="hi world"));
int main()
{}

View File

@@ -1,25 +0,0 @@
#line 2082 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
#line 2085 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
#include <boost/parameter.hpp>
#include <iostream>
#line 2071 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
namespace lib
{
BOOST_PARAMETER_NAME(name)
BOOST_PARAMETER_NAME(index)
BOOST_PARAMETER_FUNCTION(
(int), f, tag,
(optional (name,*,"bob")(index,(int),1))
)
{
std::cout << name << ":" << index << std::endl;
return index;
}
}
#line 2098 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
int x = lib::f(lib::_name = "jill", lib::_index = 1);
#line 2102 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
int main() {}

View File

@@ -1,28 +0,0 @@
#line 2100 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
#line 2085 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
#include <boost/parameter.hpp>
#include <iostream>
#line 2071 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
namespace lib
{
BOOST_PARAMETER_NAME(name)
BOOST_PARAMETER_NAME(index)
BOOST_PARAMETER_FUNCTION(
(int), f, tag,
(optional (name,*,"bob")(index,(int),1))
)
{
std::cout << name << ":" << index << std::endl;
return index;
}
}
#line 2111 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
using lib::_name;
using lib::_index;
int x = lib::f(_name = "jill", _index = 1);
#line 2120 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
int main() {}

View File

@@ -1,26 +0,0 @@
#line 2114 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
#line 2085 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
#include <boost/parameter.hpp>
#include <iostream>
#line 2071 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
namespace lib
{
BOOST_PARAMETER_NAME(name)
BOOST_PARAMETER_NAME(index)
BOOST_PARAMETER_FUNCTION(
(int), f, tag,
(optional (name,*,"bob")(index,(int),1))
)
{
std::cout << name << ":" << index << std::endl;
return index;
}
}
#line 2128 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
using namespace lib;
int x = f(_name = "jill", _index = 3);
#line 2134 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
int main() {}

View File

@@ -1,29 +0,0 @@
#line 2161 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
#include <boost/parameter.hpp>
#include <iostream>
#line 2143 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
namespace lib
{
namespace keywords
{
BOOST_PARAMETER_NAME(name)
BOOST_PARAMETER_NAME(index)
}
BOOST_PARAMETER_FUNCTION(
(int), f, keywords::tag,
(optional (name,*,"bob")(index,(int),1))
)
{
std::cout << name << ":" << index << std::endl;
return index;
}
}
#line 2170 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
using namespace lib::keywords;
int y = lib::f(_name = "bob", _index = 2);
#line 2172 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
int main() {}

View File

@@ -1,31 +0,0 @@
#line 571 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
#include <boost/parameter.hpp>
namespace boost
{
int vertex_index = 0;
template <class T = int>
struct dfs_visitor
{};
}
BOOST_PARAMETER_NAME(graph)
BOOST_PARAMETER_NAME(visitor)
BOOST_PARAMETER_NAME(root_vertex)
BOOST_PARAMETER_NAME(index_map)
BOOST_PARAMETER_NAME(color_map)
BOOST_PARAMETER_FUNCTION((void), f, tag,
(required (graph, *))
#line 563 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
(optional (visitor, *, boost::dfs_visitor<>())
(root_vertex, *, *vertices(graph).first)
(index_map, *, get(boost::vertex_index,graph))
(in_out(color_map), *,
default_color_map(num_vertices(graph), index_map) )
)
#line 592 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
) {}

View File

@@ -1,37 +0,0 @@
#line 1248 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
#include <boost/parameter.hpp>
#include <iostream>
#line 1234 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
BOOST_PARAMETER_NAME(name)
BOOST_PARAMETER_NAME(index)
struct myclass_impl
{
template <class ArgumentPack>
myclass_impl(ArgumentPack const& args)
{
std::cout << "name = " << args[_name]
<< "; index = " << args[_index | 42]
<< std::endl;
}
};
#line 1261 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
struct myclass : myclass_impl
{
BOOST_PARAMETER_CONSTRUCTOR(
myclass, (myclass_impl), tag
, (required (name,*)) (optional (index,*))) // no semicolon
};
#line 1275 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
int main() {
#line 1272 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
myclass x("bob", 3); // positional
myclass y(_index = 12, _name = "sally"); // named
myclass z("june"); // positional/defaulted
#line 1275 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
}

View File

@@ -1,17 +0,0 @@
#line 1154 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
#include <boost/parameter.hpp>
#include <iostream>
using namespace boost::parameter;
#line 1142 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
BOOST_PARAMETER_NAME(arg1)
BOOST_PARAMETER_NAME(arg2)
struct callable2
{
BOOST_PARAMETER_CONST_MEMBER_FUNCTION(
(void), call, tag, (required (arg1,(int))(arg2,(int))))
{
std::cout << arg1 << ", " << arg2 << std::endl;
}
};

View File

@@ -1,18 +0,0 @@
#line 1177 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
#include <boost/parameter.hpp>
BOOST_PARAMETER_NAME(arg1)
BOOST_PARAMETER_NAME(arg2)
using namespace boost::parameter;
#line 1166 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
struct callable2
{
BOOST_PARAMETER_CONST_MEMBER_FUNCTION(
(void), call, tag, (required (arg1,(int))(arg2,(int))))
{
call_impl(arg1,arg2);
}
private:
void call_impl(int, int); // implemented elsewhere.
};

View File

@@ -1,106 +0,0 @@
#line 935 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
#include <boost/parameter.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/depth_first_search.hpp>
BOOST_PARAMETER_NAME((_graph, graphs) graph)
BOOST_PARAMETER_NAME((_visitor, graphs) visitor)
BOOST_PARAMETER_NAME((_root_vertex, graphs) root_vertex)
BOOST_PARAMETER_NAME((_index_map, graphs) index_map)
BOOST_PARAMETER_NAME((_color_map, graphs) color_map)
using boost::mpl::_;
#line 859 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
// We first need to define a few metafunction that we use in the
// predicates below.
template <class G>
struct traversal_category
{
typedef typename boost::graph_traits<G>::traversal_category type;
};
template <class G>
struct vertex_descriptor
{
typedef typename boost::graph_traits<G>::vertex_descriptor type;
};
template <class G>
struct value_type
{
typedef typename boost::property_traits<G>::value_type type;
};
template <class G>
struct key_type
{
typedef typename boost::property_traits<G>::key_type type;
};
template<class Size, class IndexMap>
boost::iterator_property_map<
boost::default_color_type*, IndexMap
, boost::default_color_type, boost::default_color_type&
>
default_color_map(Size num_vertices, IndexMap const& index_map)
{
std::vector<boost::default_color_type> colors(num_vertices);
return &colors[0];
}
BOOST_PARAMETER_FUNCTION(
(void), depth_first_search, graphs
, (required
(graph
, *(boost::mpl::and_<
boost::is_convertible<
traversal_category<_>, boost::incidence_graph_tag
>
, boost::is_convertible<
traversal_category<_>, boost::vertex_list_graph_tag
>
>) ))
(optional
(visitor, *, boost::dfs_visitor<>()) // not checkable
(root_vertex
, (vertex_descriptor<graphs::graph::_>)
, *vertices(graph).first)
(index_map
, *(boost::mpl::and_<
boost::is_integral<value_type<_> >
, boost::is_same<
vertex_descriptor<graphs::graph::_>, key_type<_>
>
>)
, get(boost::vertex_index,graph))
(in_out(color_map)
, *(boost::is_same<
vertex_descriptor<graphs::graph::_>, key_type<_>
>)
, default_color_map(num_vertices(graph), index_map) )
)
)
#line 949 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
{}
int main()
{
typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::directedS> G;
enum {u, v, w, x, y, z, N};
typedef std::pair<int, int> E;
E edges[] = {E(u, v), E(u, x), E(x, v), E(y, x), E(v, y), E(w, y),
E(w,z), E(z, z)};
G g(edges, edges + sizeof(edges) / sizeof(E), N);
depth_first_search(g);
depth_first_search(g, _root_vertex = (int)x);
}

View File

@@ -1,12 +0,0 @@
#line 540 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
#include <boost/parameter.hpp>
BOOST_PARAMETER_NAME(graph)
BOOST_PARAMETER_FUNCTION((void), f, tag,
#line 531 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
(required (graph, *) )
#line 547 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
) {}

View File

@@ -1,16 +0,0 @@
#line 1206 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
#include <boost/parameter.hpp>
#include <iostream>
using namespace boost::parameter;
#line 1195 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
BOOST_PARAMETER_NAME(arg1)
struct somebody
{
BOOST_PARAMETER_MEMBER_FUNCTION(
(void), static f, tag, (optional (arg1,(int),0)))
{
std::cout << arg1 << std::endl;
}
};

View File

@@ -1,12 +0,0 @@
#line 1337 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
#include <boost/parameter.hpp>
#line 1329 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
namespace boost { namespace python {
BOOST_PARAMETER_TEMPLATE_KEYWORD(class_type)
BOOST_PARAMETER_TEMPLATE_KEYWORD(base_list)
BOOST_PARAMETER_TEMPLATE_KEYWORD(held_type)
BOOST_PARAMETER_TEMPLATE_KEYWORD(copyable)
}}

View File

@@ -1,13 +0,0 @@
#line 1353 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
#include <boost/parameter.hpp>
#line 1344 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
namespace boost { namespace python {
namespace tag { struct class_type; } // keyword tag type
template <class T>
struct class_type
: parameter::template_keyword<tag::class_type,T>
{};
}}

View File

@@ -1,40 +0,0 @@
#line 35 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
#include <boost/parameter.hpp>
namespace test
{
BOOST_PARAMETER_NAME(title)
BOOST_PARAMETER_NAME(width)
BOOST_PARAMETER_NAME(titlebar)
BOOST_PARAMETER_FUNCTION(
(int), new_window, tag, (required (title,*)(width,*)(titlebar,*)))
{
return 0;
}
BOOST_PARAMETER_TEMPLATE_KEYWORD(deleter)
BOOST_PARAMETER_TEMPLATE_KEYWORD(copy_policy)
template <class T> struct Deallocate {};
struct DeepCopy {};
namespace parameter = boost::parameter;
struct Foo {};
template <class T, class A0, class A1>
struct smart_ptr
{
smart_ptr(Foo*);
};
}
using namespace test;
int x =
#line 19
new_window("alert", _width=10, _titlebar=false);
smart_ptr<
Foo
, deleter<Deallocate<Foo> >
, copy_policy<DeepCopy> > p(new Foo);

View File

@@ -1,45 +0,0 @@
#line 472 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
#include <boost/parameter/name.hpp>
BOOST_PARAMETER_NAME(graph)
BOOST_PARAMETER_NAME(visitor)
BOOST_PARAMETER_NAME(root_vertex)
BOOST_PARAMETER_NAME(index_map)
BOOST_PARAMETER_NAME(color_map)
namespace boost {
template <class T = int>
struct dfs_visitor
{};
int vertex_index = 0;
}
#line 446 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
#include <boost/parameter/preprocessor.hpp>
namespace graphs
{
BOOST_PARAMETER_FUNCTION(
(void), // 1. parenthesized return type
depth_first_search, // 2. name of the function template
tag, // 3. namespace of tag types
(required (graph, *) ) // 4. one required parameter, and
(optional // four optional parameters, with defaults
(visitor, *, boost::dfs_visitor<>())
(root_vertex, *, *vertices(graph).first)
(index_map, *, get(boost::vertex_index,graph))
(in_out(color_map), *,
default_color_map(num_vertices(graph), index_map) )
)
)
{
// ... body of function goes here...
// use graph, visitor, index_map, and color_map
}
}