mirror of
https://github.com/boostorg/parameter.git
synced 2026-01-22 05:22:31 +00:00
Compare commits
120 Commits
svn-branch
...
boost-1.69
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5d3e39325e | ||
|
|
058b1394f5 | ||
|
|
de183a3b75 | ||
|
|
28a8f75d83 | ||
|
|
2e9b937082 | ||
|
|
61d476d4b6 | ||
|
|
02a59d2091 | ||
|
|
007a24b76c | ||
|
|
672ae1c0ce | ||
|
|
f7829bd91c | ||
|
|
3736a0581e | ||
|
|
6f747e9869 | ||
|
|
b31fc2bb17 | ||
|
|
247536c841 | ||
|
|
fd4a18d490 | ||
|
|
a2da4c32f5 | ||
|
|
a3b5ce8a93 | ||
|
|
612563e0fe | ||
|
|
904e2f5020 | ||
|
|
c303922fe9 | ||
|
|
9a8ad86fd7 | ||
|
|
0461c0a070 | ||
|
|
6ad2d6b207 | ||
|
|
45eebd0b85 | ||
|
|
d6132a7645 | ||
|
|
3462c3dc06 | ||
|
|
bc19656218 | ||
|
|
09cc5cf219 | ||
|
|
dd466e7d54 | ||
|
|
368205ab37 | ||
|
|
9821c1a5f9 | ||
|
|
d3a422ba6e | ||
|
|
aaf00c5449 | ||
|
|
a9a4287f4d | ||
|
|
e1f43668e7 | ||
|
|
3b34198a6f | ||
|
|
49ab4faa2b | ||
|
|
54854d4a3a | ||
|
|
45295c87bc | ||
|
|
0dcd40da74 | ||
|
|
a510824ee4 | ||
|
|
7465ba08d3 | ||
|
|
8dca3b7307 | ||
|
|
51a02e0822 | ||
|
|
a07961f561 | ||
|
|
4e26b448e9 | ||
|
|
b5e57e0024 | ||
|
|
b74489d477 | ||
|
|
475001a591 | ||
|
|
f9e0d1c5c3 | ||
|
|
23ed477c44 | ||
|
|
6427d82103 | ||
|
|
436209fa82 | ||
|
|
9d66bd7632 | ||
|
|
bdcbf442bf | ||
|
|
c9cf0ab0f5 | ||
|
|
20301b3da4 | ||
|
|
59e172adb3 | ||
|
|
9f4334c1c1 | ||
|
|
7ff5c4b996 | ||
|
|
1b1499b94c | ||
|
|
3cf03f73ca | ||
|
|
04cea6497d | ||
|
|
e6eda9a776 | ||
|
|
8a404e2d67 | ||
|
|
31f9f620fe | ||
|
|
56ddeddfaf | ||
|
|
fe43dad724 | ||
|
|
ce2d43c1b5 | ||
|
|
86d7201a99 | ||
|
|
ccf40a29c1 | ||
|
|
28ed7b9704 | ||
|
|
6c3ee189d1 | ||
|
|
15048a1d82 | ||
|
|
3852ff760c | ||
|
|
916b4d2c2f | ||
|
|
af9b04e7ad | ||
|
|
894dffe6ff | ||
|
|
c17ea8d26d | ||
|
|
1844c27699 | ||
|
|
9694b76bf2 | ||
|
|
7c9ddf23e0 | ||
|
|
224d313a05 | ||
|
|
47c53efbaa | ||
|
|
57ef2b6ee9 | ||
|
|
297e85c0f1 | ||
|
|
3a59d2cea3 | ||
|
|
58bb633dc0 | ||
|
|
3397bafb4a | ||
|
|
cc256f0bb3 | ||
|
|
e3b060b3e5 | ||
|
|
0791667e33 | ||
|
|
91ffd43483 | ||
|
|
fa751e022e | ||
|
|
1f6c9a3034 | ||
|
|
6c209395aa | ||
|
|
5231f04b27 | ||
|
|
c7258e9c9e | ||
|
|
22a1f905e9 | ||
|
|
0417a36693 | ||
|
|
d42b860b8d | ||
|
|
c5168be5d7 | ||
|
|
c29a75c9df | ||
|
|
e18d621508 | ||
|
|
40399d3505 | ||
|
|
d6db8c6216 | ||
|
|
38817a8bb5 | ||
|
|
646c519dc0 | ||
|
|
cb501f9f38 | ||
|
|
7eb7737095 | ||
|
|
bfc5811fdc | ||
|
|
1f8f44b26c | ||
|
|
6729c38504 | ||
|
|
cf5d2c46f5 | ||
|
|
49e928273d | ||
|
|
00bbfbb20c | ||
|
|
ca120a3f04 | ||
|
|
e2b452c1f4 | ||
|
|
6695f76c5f | ||
|
|
bf25a637c8 |
136
.travis.yml
Normal file
136
.travis.yml
Normal file
@@ -0,0 +1,136 @@
|
||||
# Copyright 2016 Edward Diener
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
|
||||
|
||||
language: cpp
|
||||
|
||||
sudo: false
|
||||
|
||||
python: "2.7"
|
||||
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
- develop
|
||||
- /feature\/.*/
|
||||
|
||||
env:
|
||||
matrix:
|
||||
- BOGUS_JOB=true
|
||||
|
||||
matrix:
|
||||
|
||||
exclude:
|
||||
- env: BOGUS_JOB=true
|
||||
|
||||
include:
|
||||
- os: linux
|
||||
compiler: g++
|
||||
env: TOOLSET=gcc COMPILER=g++ CXXSTD=03,11
|
||||
|
||||
- os: linux
|
||||
compiler: g++-4.4
|
||||
env: TOOLSET=gcc COMPILER=g++-4.4 CXXSTD=98,0x
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-4.4
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-4.6
|
||||
env: TOOLSET=gcc COMPILER=g++-4.6 CXXSTD=03,0x
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-4.6
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-5
|
||||
env: TOOLSET=gcc COMPILER=g++-5 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-5
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-6
|
||||
env: TOOLSET=gcc COMPILER=g++-6 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-6
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
dist: trusty
|
||||
compiler: g++-7
|
||||
env: TOOLSET=gcc COMPILER=g++-7 CXXSTD=03,11,14,17
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-7
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-8
|
||||
env: TOOLSET=gcc COMPILER=g++-8 CXXSTD=03,11,14,17
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-8
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: clang++
|
||||
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- libstdc++-5-dev
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-libc++
|
||||
env: TOOLSET=clang COMPILER=clang++-libc++ CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- libc++-dev
|
||||
|
||||
- os: osx
|
||||
compiler: clang++
|
||||
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z
|
||||
|
||||
install:
|
||||
- BOOST_BRANCH=develop && [ "$TRAVIS_BRANCH" == "master" ] && BOOST_BRANCH=master || true
|
||||
- cd ..
|
||||
- git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
|
||||
- cd boost-root
|
||||
- git submodule update --init tools/build
|
||||
- git submodule update --init libs/config
|
||||
- git submodule update --init tools/boostdep
|
||||
- git submodule update --init libs/parameter_python
|
||||
- cp -r $TRAVIS_BUILD_DIR/* libs/parameter
|
||||
- python tools/boostdep/depinst/depinst.py parameter
|
||||
- ./bootstrap.sh
|
||||
- ./b2 headers
|
||||
|
||||
script:
|
||||
- |-
|
||||
echo "using $TOOLSET : : $COMPILER ;" > ~/user-config.jam
|
||||
- ./b2 --verbose-test libs/config/test//config_info toolset=$TOOLSET cxxstd=$CXXSTD || true
|
||||
- ./b2 -j3 libs/parameter/test toolset=$TOOLSET cxxstd=$CXXSTD
|
||||
|
||||
notifications:
|
||||
email:
|
||||
on_success: always
|
||||
37
appveyor.yml
Normal file
37
appveyor.yml
Normal file
@@ -0,0 +1,37 @@
|
||||
# Copyright 2017 Edward Diener
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
|
||||
|
||||
version: 1.0.{build}-{branch}
|
||||
|
||||
shallow_clone: true
|
||||
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
- develop
|
||||
|
||||
environment:
|
||||
matrix:
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
TOOLSET: msvc-9.0,msvc-10.0,msvc-11.0,msvc-12.0,msvc-14.0
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
TOOLSET: msvc-14.1
|
||||
|
||||
install:
|
||||
- cd ..
|
||||
- git clone -b %APPVEYOR_REPO_BRANCH% https://github.com/boostorg/boost.git boost-root
|
||||
- cd boost-root
|
||||
- git submodule update --init tools/build
|
||||
- git submodule update --init libs/config
|
||||
- git submodule update --init tools/boostdep
|
||||
- git submodule update --init libs/parameter_python
|
||||
- xcopy /s /e /q %APPVEYOR_BUILD_FOLDER% libs\parameter
|
||||
- python tools/boostdep/depinst/depinst.py parameter
|
||||
- bootstrap
|
||||
- b2 headers
|
||||
|
||||
build: off
|
||||
|
||||
test_script:
|
||||
- b2 libs/parameter/test toolset=%TOOLSET%
|
||||
12
doc/Jamfile.v2
Executable file → Normal file
12
doc/Jamfile.v2
Executable file → Normal file
@@ -1,12 +1,12 @@
|
||||
# Copyright David Abrahams 2006. Distributed under the Boost
|
||||
# Software License, Version 1.0. (See accompanying
|
||||
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
import docutils ;
|
||||
|
||||
import path ;
|
||||
sources = [ path.glob . : *.rst ] ;
|
||||
sources = [ glob *.rst ] ;
|
||||
bases = $(sources:S=) ;
|
||||
|
||||
|
||||
# This is a path relative to the html/ subdirectory where the
|
||||
# generated output will eventually be moved.
|
||||
stylesheet = "--stylesheet=rst.css" ;
|
||||
@@ -22,3 +22,9 @@ for local b in $(bases)
|
||||
|
||||
alias htmls : $(bases) ;
|
||||
stage html : $(bases) ;
|
||||
|
||||
###############################################################################
|
||||
alias boostdoc ;
|
||||
explicit boostdoc ;
|
||||
alias boostrelease : html ;
|
||||
explicit boostrelease ;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<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.6: http://docutils.sourceforge.net/" />
|
||||
<meta name="generator" content="Docutils 0.7: http://docutils.sourceforge.net/" />
|
||||
<title>The Boost Parameter Library</title>
|
||||
<link rel="stylesheet" href="rst.css" type="text/css" />
|
||||
</head>
|
||||
@@ -37,7 +37,7 @@ can be deduced from their types.</p>
|
||||
</tbody>
|
||||
</table>
|
||||
<!-- @jam_prefix.append('''
|
||||
project test : requirements <include>. <source>/boost//headers ;''') -->
|
||||
project test : requirements <include>. <implicit-dependency>/boost//headers ;''') -->
|
||||
<!-- @example.prepend('''
|
||||
#include <boost/parameter.hpp>
|
||||
|
||||
@@ -122,7 +122,7 @@ or copy at <a class="reference external" href="http://www.boost.org/LICENSE_1_0.
|
||||
</li>
|
||||
<li><a class="reference internal" href="#portability-considerations" id="id38">5 Portability Considerations</a><ul class="auto-toc">
|
||||
<li><a class="reference internal" href="#no-sfinae-support" id="id39">5.1 No SFINAE Support</a></li>
|
||||
<li><a class="reference internal" href="#no-support-for-result-of" id="id40">5.2 No Support for <tt class="docutils literal"><span class="pre">result_of</span></tt></a></li>
|
||||
<li><a class="reference internal" href="#no-support-for-result-of" id="id40">5.2 No Support for <tt class="docutils literal">result_of</tt></a></li>
|
||||
<li><a class="reference internal" href="#compiler-can-t-see-references-in-unnamed-namespace" id="id41">5.3 Compiler Can't See References In Unnamed Namespace</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
@@ -158,8 +158,8 @@ const bool movability = false;
|
||||
window* w = new_window("alert box", movability);
|
||||
</pre>
|
||||
<p class="compound-middle">In the example above we wanted to make an unmoveable window
|
||||
with a default <tt class="docutils literal"><span class="pre">border_width</span></tt>, but instead we got a moveable
|
||||
window with a <tt class="docutils literal"><span class="pre">border_width</span></tt> of zero. To get the desired
|
||||
with a default <tt class="docutils literal">border_width</tt>, but instead we got a moveable
|
||||
window with a <tt class="docutils literal">border_width</tt> of zero. To get the desired
|
||||
effect, we'd need to write:</p>
|
||||
<pre class="compound-last literal-block">
|
||||
window* w = new_window(
|
||||
@@ -201,9 +201,9 @@ window* w = new_window("alert box", <strong>movable_=</strong>false);
|
||||
<p class="compound-first">A <strong>deduced parameter</strong> can be passed in any position <em>without</em>
|
||||
supplying an explicit parameter name. It's not uncommon for a
|
||||
function to have parameters that can be uniquely identified based
|
||||
on the types of arguments passed. The <tt class="docutils literal"><span class="pre">name</span></tt> parameter to
|
||||
<tt class="docutils literal"><span class="pre">new_window</span></tt> is one such example. None of the other arguments,
|
||||
if valid, can reasonably be converted to a <tt class="docutils literal"><span class="pre">char</span> <span class="pre">const*</span></tt>. With
|
||||
on the types of arguments passed. The <tt class="docutils literal">name</tt> parameter to
|
||||
<tt class="docutils literal">new_window</tt> is one such example. None of the other arguments,
|
||||
if valid, can reasonably be converted to a <tt class="docutils literal">char const*</tt>. With
|
||||
a deduced parameter interface, we could pass the window name in
|
||||
<em>any</em> argument position without causing ambiguity:</p>
|
||||
<pre class="compound-middle literal-block">
|
||||
@@ -222,8 +222,8 @@ names.</p>
|
||||
<p class="compound-first">The reasoning we've given for named and deduced parameter
|
||||
interfaces applies equally well to class templates as it does to
|
||||
functions. Using the Parameter library, we can create interfaces
|
||||
that allow template arguments (in this case <tt class="docutils literal"><span class="pre">shared</span></tt> and
|
||||
<tt class="docutils literal"><span class="pre">Client</span></tt>) to be explicitly named, like this:</p>
|
||||
that allow template arguments (in this case <tt class="docutils literal">shared</tt> and
|
||||
<tt class="docutils literal">Client</tt>) to be explicitly named, like this:</p>
|
||||
<pre class="compound-middle literal-block">
|
||||
smart_ptr<<strong>ownership<shared></strong>, <strong>value_type<Client></strong> > p;
|
||||
</pre>
|
||||
@@ -251,7 +251,7 @@ more advanced idioms as well.</p>
|
||||
<h2><a class="toc-backref" href="#id27">2.1 Parameter-Enabled Functions</a></h2>
|
||||
<p>In this section we'll show how the Parameter library can be used to
|
||||
build an expressive interface to the <a class="reference external" href="../../../graph/index.html">Boost Graph library</a>'s
|
||||
<a class="reference external" href="../../../graph/doc/depth_first_search.html"><tt class="docutils literal"><span class="pre">depth_first_search</span></tt></a> algorithm.<a class="footnote-reference" href="#old-interface" id="id3"><sup>1</sup></a></p>
|
||||
<a class="reference external" href="../../../graph/doc/depth_first_search.html"><tt class="docutils literal">depth_first_search</tt></a> algorithm.<a class="footnote-reference" href="#old-interface" id="id3"><sup>1</sup></a></p>
|
||||
<!-- Revisit this
|
||||
|
||||
After laying some groundwork
|
||||
@@ -271,10 +271,10 @@ header named for the component. For example,</p>
|
||||
</pre>
|
||||
<p>will ensure <tt class="docutils literal"><span class="pre">boost::parameter::keyword</span></tt> is known to the
|
||||
compiler. There is also a combined header,
|
||||
<tt class="docutils literal"><span class="pre">boost/parameter.hpp</span></tt>, that includes most of the library's
|
||||
<tt class="docutils literal">boost/parameter.hpp</tt>, that includes most of the library's
|
||||
components. For the the rest of this tutorial, unless we say
|
||||
otherwise, you can use the rule above to figure out which header
|
||||
to <tt class="docutils literal"><span class="pre">#include</span></tt> to access any given component of the library.</p>
|
||||
to <tt class="docutils literal">#include</tt> to access any given component of the library.</p>
|
||||
<!-- @example.append('''
|
||||
using boost::parameter::keyword;
|
||||
''') -->
|
||||
@@ -289,8 +289,8 @@ namespace parameter = boost::parameter;
|
||||
<tt class="docutils literal"><span class="pre">boost::parameter::xxx</span></tt>.</p>
|
||||
</div>
|
||||
<div class="section" id="the-abstract-interface-to-dfs">
|
||||
<h3>2.1.2 The Abstract Interface to <tt class="docutils literal"><span class="pre">depth_first_search</span></tt></h3>
|
||||
<p>The Graph library's <tt class="docutils literal"><span class="pre">depth_first_search</span></tt> algorithm is a generic function accepting
|
||||
<h3>2.1.2 The Abstract Interface to <tt class="docutils literal">depth_first_search</tt></h3>
|
||||
<p>The Graph library's <tt class="docutils literal">depth_first_search</tt> algorithm is a generic function accepting
|
||||
from one to four arguments by reference. If all arguments were
|
||||
required, its signature might be as follows:</p>
|
||||
<pre class="literal-block">
|
||||
@@ -308,7 +308,7 @@ void depth_first_search(
|
||||
<p>However, most of the parameters have a useful default value, as
|
||||
shown in the table below.</p>
|
||||
<table border="1" class="docutils" id="default-expressions">
|
||||
<span id="parameter-table"></span><caption><tt class="docutils literal"><span class="pre">depth_first_search</span></tt> Parameters</caption>
|
||||
<span id="parameter-table"></span><caption><tt class="docutils literal">depth_first_search</tt> Parameters</caption>
|
||||
<colgroup>
|
||||
<col width="17%" />
|
||||
<col width="11%" />
|
||||
@@ -323,41 +323,41 @@ shown in the table below.</p>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody valign="top">
|
||||
<tr><td><tt class="docutils literal"><span class="pre">graph</span></tt></td>
|
||||
<tr><td><tt class="docutils literal">graph</tt></td>
|
||||
<td>in</td>
|
||||
<td>Model of <a class="reference external" href="../../../graph/doc/IncidenceGraph.html"><span class="concept">Incidence Graph</span></a> and
|
||||
<a class="reference external" href="../../../graph/doc/VertexListGraph.html"><span class="concept">Vertex List Graph</span></a></td>
|
||||
<td>none - this argument is required.</td>
|
||||
</tr>
|
||||
<tr><td><tt class="docutils literal"><span class="pre">visitor</span></tt></td>
|
||||
<tr><td><tt class="docutils literal">visitor</tt></td>
|
||||
<td>in</td>
|
||||
<td>Model of <a class="reference external" href="../../../graph/doc/DFSVisitor.html"><span class="concept">DFS Visitor</span></a></td>
|
||||
<td><tt class="docutils literal"><span class="pre">boost::dfs_visitor<>()</span></tt></td>
|
||||
</tr>
|
||||
<tr><td><tt class="docutils literal"><span class="pre">root_vertex</span></tt></td>
|
||||
<tr><td><tt class="docutils literal">root_vertex</tt></td>
|
||||
<td>in</td>
|
||||
<td><tt class="docutils literal"><span class="pre">graph</span></tt>'s vertex descriptor
|
||||
<td><tt class="docutils literal">graph</tt>'s vertex descriptor
|
||||
type.</td>
|
||||
<td><tt class="docutils literal"><span class="pre">*vertices(graph).first</span></tt></td>
|
||||
</tr>
|
||||
<tr><td><tt class="docutils literal"><span class="pre">index_map</span></tt></td>
|
||||
<tr><td><tt class="docutils literal">index_map</tt></td>
|
||||
<td>in</td>
|
||||
<td>Model of <a class="reference external" href="../../../property_map/doc/ReadablePropertyMap.html"><span class="concept">Readable Property Map</span></a>
|
||||
with key type := <tt class="docutils literal"><span class="pre">graph</span></tt>'s
|
||||
with key type := <tt class="docutils literal">graph</tt>'s
|
||||
vertex descriptor and value type
|
||||
an integer type.</td>
|
||||
<td><tt class="docutils literal"><span class="pre">get(boost::vertex_index,graph)</span></tt></td>
|
||||
</tr>
|
||||
<tr><td><tt class="docutils literal"><span class="pre">color_map</span></tt></td>
|
||||
<tr><td><tt class="docutils literal">color_map</tt></td>
|
||||
<td>in/out</td>
|
||||
<td>Model of <a class="reference external" href="../../../property_map/doc/ReadWritePropertyMap.html"><span class="concept">Read/Write Property Map</span></a>
|
||||
with key type := <tt class="docutils literal"><span class="pre">graph</span></tt>'s
|
||||
with key type := <tt class="docutils literal">graph</tt>'s
|
||||
vertex descriptor type.</td>
|
||||
<td>an <tt class="docutils literal"><span class="pre">iterator_property_map</span></tt>
|
||||
<td>an <tt class="docutils literal">iterator_property_map</tt>
|
||||
created from a <tt class="docutils literal"><span class="pre">std::vector</span></tt> of
|
||||
<tt class="docutils literal"><span class="pre">default_color_type</span></tt> of size
|
||||
<tt class="docutils literal"><span class="pre">num_vertices(graph)</span></tt> and using
|
||||
<tt class="docutils literal"><span class="pre">index_map</span></tt> for the index map.</td>
|
||||
<tt class="docutils literal">default_color_type</tt> of size
|
||||
<tt class="docutils literal">num_vertices(graph)</tt> and using
|
||||
<tt class="docutils literal">index_map</tt> for the index map.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -368,15 +368,15 @@ to understand them in detail.</p>
|
||||
<div class="section" id="defining-the-keywords">
|
||||
<h3>2.1.3 Defining the Keywords</h3>
|
||||
<p>The point of this exercise is to make it possible to call
|
||||
<tt class="docutils literal"><span class="pre">depth_first_search</span></tt> with named arguments, leaving out any
|
||||
<tt class="docutils literal">depth_first_search</tt> with named arguments, leaving out any
|
||||
arguments for which the default is appropriate:</p>
|
||||
<pre class="literal-block">
|
||||
graphs::depth_first_search(g, <strong>color_map_=my_color_map</strong>);
|
||||
</pre>
|
||||
<!-- @ignore() -->
|
||||
<p>To make that syntax legal, there needs to be an object called
|
||||
“<tt class="docutils literal"><span class="pre">color_map_</span></tt>” whose assignment operator can accept a
|
||||
<tt class="docutils literal"><span class="pre">my_color_map</span></tt> argument. In this step we'll create one such
|
||||
“<tt class="docutils literal">color_map_</tt>” whose assignment operator can accept a
|
||||
<tt class="docutils literal">my_color_map</tt> argument. In this step we'll create one such
|
||||
<strong>keyword object</strong> for each parameter. Each keyword object will be
|
||||
identified by a unique <strong>keyword tag type</strong>.</p>
|
||||
<!-- Revisit this
|
||||
@@ -387,7 +387,7 @@ we'll define the keyword objects so they're accessible through
|
||||
``graphs``, and we'll hide the tag types away in a nested
|
||||
namespace, ``graphs::tag``. The library provides a convenient
|
||||
macro for that purpose. -->
|
||||
<p>We're going to define our interface in namespace <tt class="docutils literal"><span class="pre">graphs</span></tt>. The
|
||||
<p>We're going to define our interface in namespace <tt class="docutils literal">graphs</tt>. The
|
||||
library provides a convenient macro for defining keyword objects:</p>
|
||||
<pre class="literal-block">
|
||||
#include <boost/parameter/name.hpp>
|
||||
@@ -402,7 +402,7 @@ namespace graphs
|
||||
}
|
||||
</pre>
|
||||
<!-- @test('compile') -->
|
||||
<p>The declaration of the <tt class="docutils literal"><span class="pre">graph</span></tt> keyword you see here is
|
||||
<p>The declaration of the <tt class="docutils literal">graph</tt> keyword you see here is
|
||||
equivalent to:</p>
|
||||
<pre class="literal-block">
|
||||
namespace graphs
|
||||
@@ -420,7 +420,7 @@ namespace graphs
|
||||
<!-- @example.prepend('#include <boost/parameter/keyword.hpp>') -->
|
||||
<!-- @test('compile') -->
|
||||
<p>It defines a <em>keyword tag type</em> named <tt class="docutils literal"><span class="pre">tag::graph</span></tt> and a <em>keyword
|
||||
object</em> reference named <tt class="docutils literal"><span class="pre">_graph</span></tt>.</p>
|
||||
object</em> reference named <tt class="docutils literal">_graph</tt>.</p>
|
||||
<p>This “fancy dance” involving an unnamed namespace and references
|
||||
is all done to avoid violating the One Definition Rule (ODR)<a class="footnote-reference" href="#odr" id="id5"><sup>2</sup></a> when the named parameter interface is used by function
|
||||
templates that are instantiated in multiple translation
|
||||
@@ -430,7 +430,7 @@ units (MSVC6.x users see <a class="reference internal" href="#compiler-can-t-see
|
||||
<h3>2.1.4 Writing the Function</h3>
|
||||
<p>Now that we have our keywords defined, the function template
|
||||
definition follows a simple pattern using the
|
||||
<tt class="docutils literal"><span class="pre">BOOST_PARAMETER_FUNCTION</span></tt> macro:</p>
|
||||
<tt class="docutils literal">BOOST_PARAMETER_FUNCTION</tt> macro:</p>
|
||||
<pre class="literal-block">
|
||||
#include <boost/parameter/preprocessor.hpp>
|
||||
|
||||
@@ -477,7 +477,7 @@ int vertex_index = 0;
|
||||
|
||||
}''') -->
|
||||
<!-- @test('compile') -->
|
||||
<p>The arguments to <tt class="docutils literal"><span class="pre">BOOST_PARAMETER_FUNCTION</span></tt> are:</p>
|
||||
<p>The arguments to <tt class="docutils literal">BOOST_PARAMETER_FUNCTION</tt> are:</p>
|
||||
<ol class="arabic simple">
|
||||
<li>The return type of the resulting function template. Parentheses
|
||||
around the return type prevent any commas it might contain from
|
||||
@@ -494,12 +494,12 @@ match the function's parameter names.</li>
|
||||
parenthesized terms (a <a class="reference external" href="../../../preprocessor/index.html">Boost.Preprocessor</a> <a class="reference external" href="http://boost-consulting.com/mplbook/preprocessor.html#sequences">sequence</a>) describing
|
||||
the function's parameters in the order in which they'd be expected
|
||||
if passed positionally. Any required parameters must come first,
|
||||
but the <tt class="docutils literal"><span class="pre">(required</span> <span class="pre">…</span> <span class="pre">)</span></tt> clause can be omitted when all the
|
||||
but the <tt class="docutils literal">(required … )</tt> clause can be omitted when all the
|
||||
parameters are optional.</p>
|
||||
<div class="section" id="required-parameters">
|
||||
<h4>2.1.5.1 Required Parameters</h4>
|
||||
<div class="compound">
|
||||
<p class="compound-first">Required parameters are given first—nested in a <tt class="docutils literal"><span class="pre">(required</span> <span class="pre">…</span> <span class="pre">)</span></tt>
|
||||
<p class="compound-first">Required parameters are given first—nested in a <tt class="docutils literal">(required … )</tt>
|
||||
clause—as a series of two-element tuples describing each parameter
|
||||
name and any requirements on the argument type. In this case there
|
||||
is only a single required parameter, so there's just a single
|
||||
@@ -507,11 +507,11 @@ tuple:</p>
|
||||
<pre class="compound-middle literal-block">
|
||||
(required <strong>(graph, *)</strong> )
|
||||
</pre>
|
||||
<p class="compound-last">Since <tt class="docutils literal"><span class="pre">depth_first_search</span></tt> doesn't require any particular type
|
||||
for its <tt class="docutils literal"><span class="pre">graph</span></tt> parameter, we use an asterisk to indicate that
|
||||
<p class="compound-last">Since <tt class="docutils literal">depth_first_search</tt> doesn't require any particular type
|
||||
for its <tt class="docutils literal">graph</tt> parameter, we use an asterix to indicate that
|
||||
any type is allowed. Required parameters must always precede any
|
||||
optional parameters in a signature, but if there are <em>no</em>
|
||||
required parameters, the <tt class="docutils literal"><span class="pre">(required</span> <span class="pre">…</span> <span class="pre">)</span></tt> clause can be omitted
|
||||
required parameters, the <tt class="docutils literal">(required … )</tt> clause can be omitted
|
||||
entirely.</p>
|
||||
</div>
|
||||
<!-- @example.prepend('''
|
||||
@@ -527,7 +527,7 @@ BOOST_PARAMETER_FUNCTION((void), f, tag,
|
||||
<div class="section" id="optional-parameters">
|
||||
<h4>2.1.5.2 Optional Parameters</h4>
|
||||
<div class="compound">
|
||||
<p class="compound-first">Optional parameters—nested in an <tt class="docutils literal"><span class="pre">(optional</span> <span class="pre">…</span> <span class="pre">)</span></tt> clause—are given
|
||||
<p class="compound-first">Optional parameters—nested in an <tt class="docutils literal">(optional … )</tt> clause—are given
|
||||
as a series of adjacent <em>three</em>-element tuples describing the
|
||||
parameter name, any requirements on the argument type, <em>and</em> and an
|
||||
expression representing the parameter's default value:</p>
|
||||
@@ -567,13 +567,13 @@ BOOST_PARAMETER_FUNCTION((void), f, tag,
|
||||
<div class="section" id="handling-out-parameters">
|
||||
<h4>2.1.5.3 Handling “Out” Parameters</h4>
|
||||
<div class="compound">
|
||||
<p class="compound-first">Within the function body, a parameter name such as <tt class="docutils literal"><span class="pre">visitor</span></tt> is
|
||||
<p class="compound-first">Within the function body, a parameter name such as <tt class="docutils literal">visitor</tt> is
|
||||
a <em>C++ reference</em>, bound either to an actual argument passed by
|
||||
the caller or to the result of evaluating a default expression.
|
||||
In most cases, parameter types are of the form <tt class="docutils literal"><span class="pre">T</span> <span class="pre">const&</span></tt> for
|
||||
some <tt class="docutils literal"><span class="pre">T</span></tt>. Parameters whose values are expected to be modified,
|
||||
however, must be passed by reference to <em>non</em>-<tt class="docutils literal"><span class="pre">const</span></tt>. To
|
||||
indicate that <tt class="docutils literal"><span class="pre">color_map</span></tt> is both read and written, we wrap
|
||||
In most cases, parameter types are of the form <tt class="docutils literal">T const&</tt> for
|
||||
some <tt class="docutils literal">T</tt>. Parameters whose values are expected to be modified,
|
||||
however, must be passed by reference to <em>non</em>-<tt class="docutils literal">const</tt>. To
|
||||
indicate that <tt class="docutils literal">color_map</tt> is both read and written, we wrap
|
||||
its name in <tt class="docutils literal"><span class="pre">in_out(…)</span></tt>:</p>
|
||||
<pre class="compound-last literal-block">
|
||||
(optional
|
||||
@@ -609,9 +609,9 @@ BOOST_PARAMETER_FUNCTION((void), f, tag,
|
||||
''') -->
|
||||
<!-- @example.append(') {}') -->
|
||||
<!-- @test('compile') -->
|
||||
<p>If <tt class="docutils literal"><span class="pre">color_map</span></tt> were strictly going to be modified but not examined,
|
||||
we could have written <tt class="docutils literal"><span class="pre">out(color_map)</span></tt>. There is no functional
|
||||
difference between <tt class="docutils literal"><span class="pre">out</span></tt> and <tt class="docutils literal"><span class="pre">in_out</span></tt>; the library provides
|
||||
<p>If <tt class="docutils literal">color_map</tt> were strictly going to be modified but not examined,
|
||||
we could have written <tt class="docutils literal">out(color_map)</tt>. There is no functional
|
||||
difference between <tt class="docutils literal">out</tt> and <tt class="docutils literal">in_out</tt>; the library provides
|
||||
both so you can make your interfaces more self-documenting.</p>
|
||||
</div>
|
||||
<div class="section" id="positional-arguments">
|
||||
@@ -624,15 +624,15 @@ call</p>
|
||||
graphs::depth_first_search(x, y);
|
||||
</pre>
|
||||
<!-- @ignore() -->
|
||||
<p><tt class="docutils literal"><span class="pre">x</span></tt> will always be interpreted as a graph and <tt class="docutils literal"><span class="pre">y</span></tt> will always
|
||||
<p><tt class="docutils literal">x</tt> will always be interpreted as a graph and <tt class="docutils literal">y</tt> will always
|
||||
be interpreted as a visitor.</p>
|
||||
</div>
|
||||
<div class="section" id="default-expression-evaluation">
|
||||
<h4>2.1.5.5 Default Expression Evaluation</h4>
|
||||
<div class="compound">
|
||||
<p class="compound-first">Note that in our example, the value of the graph parameter is
|
||||
used in the default expressions for <tt class="docutils literal"><span class="pre">root_vertex</span></tt>,
|
||||
<tt class="docutils literal"><span class="pre">index_map</span></tt> and <tt class="docutils literal"><span class="pre">color_map</span></tt>.</p>
|
||||
used in the default expressions for <tt class="docutils literal">root_vertex</tt>,
|
||||
<tt class="docutils literal">index_map</tt> and <tt class="docutils literal">color_map</tt>.</p>
|
||||
<pre class="compound-middle literal-block">
|
||||
(required (<strong>graph</strong>, *) )
|
||||
(optional
|
||||
@@ -651,7 +651,7 @@ parameters, so you can use any of their values by name.</p>
|
||||
<p class="compound-first">A default expression is never evaluated—or even instantiated—if
|
||||
an actual argument is passed for that parameter. We can actually
|
||||
demonstrate that with our code so far by replacing the body of
|
||||
<tt class="docutils literal"><span class="pre">depth_first_search</span></tt> with something that prints the arguments:</p>
|
||||
<tt class="docutils literal">depth_first_search</tt> with something that prints the arguments:</p>
|
||||
<pre class="compound-middle literal-block">
|
||||
#include <boost/graph/depth_first_search.hpp> // for dfs_visitor
|
||||
|
||||
@@ -677,7 +677,7 @@ int main()
|
||||
}
|
||||
</pre>
|
||||
<p class="compound-last">Despite the fact that default expressions such as
|
||||
<tt class="docutils literal"><span class="pre">vertices(graph).first</span></tt> are ill-formed for the given <tt class="docutils literal"><span class="pre">graph</span></tt>
|
||||
<tt class="docutils literal"><span class="pre">vertices(graph).first</span></tt> are ill-formed for the given <tt class="docutils literal">graph</tt>
|
||||
arguments, both calls will compile, and each one will print
|
||||
exactly the same thing.</p>
|
||||
</div>
|
||||
@@ -704,38 +704,38 @@ BOOST_PARAMETER_NAME(color_map)''') -->
|
||||
<div class="section" id="signature-matching-and-overloading">
|
||||
<h4>2.1.5.6 Signature Matching and Overloading</h4>
|
||||
<p>In fact, the function signature is so general that any call to
|
||||
<tt class="docutils literal"><span class="pre">depth_first_search</span></tt> with fewer than five arguments will match
|
||||
<tt class="docutils literal">depth_first_search</tt> with fewer than five arguments will match
|
||||
our function, provided we pass <em>something</em> for the required
|
||||
<tt class="docutils literal"><span class="pre">graph</span></tt> parameter. That might not seem to be a problem at first;
|
||||
<tt class="docutils literal">graph</tt> parameter. That might not seem to be a problem at first;
|
||||
after all, if the arguments don't match the requirements imposed by
|
||||
the implementation of <tt class="docutils literal"><span class="pre">depth_first_search</span></tt>, a compilation error
|
||||
the implementation of <tt class="docutils literal">depth_first_search</tt>, a compilation error
|
||||
will occur later, when its body is instantiated.</p>
|
||||
<p>There are at least three problems with very general function
|
||||
signatures.</p>
|
||||
<ol class="arabic simple">
|
||||
<li>By the time our <tt class="docutils literal"><span class="pre">depth_first_search</span></tt> is instantiated, it has
|
||||
<li>By the time our <tt class="docutils literal">depth_first_search</tt> is instantiated, it has
|
||||
been selected as the best matching overload. Some other
|
||||
<tt class="docutils literal"><span class="pre">depth_first_search</span></tt> overload might've worked had it been
|
||||
<tt class="docutils literal">depth_first_search</tt> overload might've worked had it been
|
||||
chosen instead. By the time we see a compilation error, there's
|
||||
no chance to change that decision.</li>
|
||||
<li>Even if there are no overloads, error messages generated at
|
||||
instantiation time usually expose users to confusing
|
||||
implementation details. For example, users might see references
|
||||
to names generated by <tt class="docutils literal"><span class="pre">BOOST_PARAMETER_FUNCTION</span></tt> such as
|
||||
to names generated by <tt class="docutils literal">BOOST_PARAMETER_FUNCTION</tt> such as
|
||||
<tt class="docutils literal"><span class="pre">graphs::detail::depth_first_search_with_named_params</span></tt> (or
|
||||
worse—think of the kinds of errors you get from your STL
|
||||
implementation when you make a mistake).<a class="footnote-reference" href="#conceptcpp" id="id7"><sup>4</sup></a></li>
|
||||
<li>The problems with exposing such permissive function template
|
||||
signatures have been the subject of much discussion, especially
|
||||
in the presence of <a class="reference external" href="http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/lwg-defects.html#225">unqualified calls</a>. If all we want is to
|
||||
in the presence of <a class="reference external" href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#225">unqualified calls</a>. If all we want is to
|
||||
avoid unintentional argument-dependent lookup (ADL), we can
|
||||
isolate <tt class="docutils literal"><span class="pre">depth_first_search</span></tt> in a namespace containing no
|
||||
isolate <tt class="docutils literal">depth_first_search</tt> in a namespace containing no
|
||||
types<a class="footnote-reference" href="#using" id="id8"><sup>6</sup></a>, but suppose we <em>want</em> it to found via ADL?</li>
|
||||
</ol>
|
||||
<p>It's usually a good idea to prevent functions from being considered
|
||||
for overload resolution when the passed argument types aren't
|
||||
appropriate. The library already does this when the required
|
||||
<tt class="docutils literal"><span class="pre">graph</span></tt> parameter is not supplied, but we're not likely to see a
|
||||
<tt class="docutils literal">graph</tt> parameter is not supplied, but we're not likely to see a
|
||||
depth first search that doesn't take a graph to operate on.
|
||||
Suppose, instead, that we found a different depth first search
|
||||
algorithm that could work on graphs that don't model
|
||||
@@ -758,12 +758,12 @@ depth_first_search(boost::adjacency_list<>(), 2, "hello");
|
||||
<div class="section" id="adding-type-requirements">
|
||||
<h5>2.1.5.6.1 Adding Type Requirements</h5>
|
||||
<p>We really don't want the compiler to consider the original version
|
||||
of <tt class="docutils literal"><span class="pre">depth_first_search</span></tt> because the <tt class="docutils literal"><span class="pre">root_vertex</span></tt> argument,
|
||||
<tt class="docutils literal"><span class="pre">"hello"</span></tt>, doesn't meet the <a class="reference internal" href="#parameter-table">requirement</a> that it match the
|
||||
<tt class="docutils literal"><span class="pre">graph</span></tt> parameter's vertex descriptor type. Instead, this call
|
||||
of <tt class="docutils literal">depth_first_search</tt> because the <tt class="docutils literal">root_vertex</tt> argument,
|
||||
<tt class="docutils literal">"hello"</tt>, doesn't meet the <a class="reference internal" href="#parameter-table">requirement</a> that it match the
|
||||
<tt class="docutils literal">graph</tt> parameter's vertex descriptor type. Instead, this call
|
||||
should just invoke our new overload. To take the original
|
||||
<tt class="docutils literal"><span class="pre">depth_first_search</span></tt> overload out of contention, we need to tell
|
||||
the library about this requirement by replacing the <tt class="docutils literal"><span class="pre">*</span></tt> element
|
||||
<tt class="docutils literal">depth_first_search</tt> overload out of contention, we need to tell
|
||||
the library about this requirement by replacing the <tt class="docutils literal">*</tt> element
|
||||
of the signature with the required type, in parentheses:</p>
|
||||
<pre class="literal-block">
|
||||
(root_vertex,
|
||||
@@ -771,28 +771,66 @@ of the signature with the required type, in parentheses:</p>
|
||||
*vertices(graph).first)
|
||||
</pre>
|
||||
<!-- @ignore() -->
|
||||
<p>Now the original <tt class="docutils literal"><span class="pre">depth_first_search</span></tt> will only be called when
|
||||
the <tt class="docutils literal"><span class="pre">root_vertex</span></tt> argument can be converted to the graph's vertex
|
||||
<p>Now the original <tt class="docutils literal">depth_first_search</tt> will only be called when
|
||||
the <tt class="docutils literal">root_vertex</tt> argument can be converted to the graph's vertex
|
||||
descriptor type, and our example that <em>was</em> ambiguous will smoothly
|
||||
call the new overload.</p>
|
||||
<div class="note">
|
||||
<p class="first admonition-title">Note</p>
|
||||
<p class="last">The <em>type</em> of the <tt class="docutils literal"><span class="pre">graph</span></tt> argument is available in the
|
||||
signature—and in the function body—as <tt class="docutils literal"><span class="pre">graph_type</span></tt>. In
|
||||
general, to access the type of any parameter <em>foo</em>, write <em>foo</em><tt class="docutils literal"><span class="pre">_type</span></tt>.</p>
|
||||
<p class="last">The <em>type</em> of the <tt class="docutils literal">graph</tt> argument is available in the
|
||||
signature—and in the function body—as <tt class="docutils literal">graph_type</tt>. In
|
||||
general, to access the type of any parameter <em>foo</em>, write <em>foo</em><tt class="docutils literal">_type</tt>.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="predicate-requirements">
|
||||
<h5>2.1.5.6.2 Predicate Requirements</h5>
|
||||
<p>The requirements on other arguments are a bit more interesting than
|
||||
those on <tt class="docutils literal"><span class="pre">root_vertex</span></tt>; they can't be described in terms of simple
|
||||
those on <tt class="docutils literal">root_vertex</tt>; they can't be described in terms of simple
|
||||
type matching. Instead, they must be described in terms of <a class="reference external" href="../../../mpl/doc/refmanual/metafunction.html">MPL
|
||||
Metafunctions</a>. There's no space to give a complete description
|
||||
of metafunctions or of graph library details here, but we'll show
|
||||
you the complete signature with maximal checking, just to give you
|
||||
a feel for how it's done. Each predicate metafunction is enclosed
|
||||
in parentheses <em>and preceded by an asterisk</em>, as follows:</p>
|
||||
in parentheses <em>and preceded by an asterix</em>, as follows:</p>
|
||||
<pre class="literal-block">
|
||||
// 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
|
||||
|
||||
@@ -800,12 +838,10 @@ BOOST_PARAMETER_FUNCTION(
|
||||
(graph
|
||||
, <strong>*(boost::mpl::and_<
|
||||
boost::is_convertible<
|
||||
boost::graph_traits<_>::traversal_category
|
||||
, boost::incidence_graph_tag
|
||||
traversal_category<_>, boost::incidence_graph_tag
|
||||
>
|
||||
, boost::is_convertible<
|
||||
boost::graph_traits<_>::traversal_category
|
||||
, boost::vertex_list_graph_tag
|
||||
traversal_category<_>, boost::vertex_list_graph_tag
|
||||
>
|
||||
>)</strong> ))
|
||||
|
||||
@@ -813,25 +849,21 @@ BOOST_PARAMETER_FUNCTION(
|
||||
(visitor, *, boost::dfs_visitor<>()) // not checkable
|
||||
|
||||
(root_vertex
|
||||
, (typename boost::graph_traits<graphs::graph::_>::vertex_descriptor)
|
||||
, (vertex_descriptor<graphs::graph::_>)
|
||||
, *vertices(graph).first)
|
||||
|
||||
(index_map
|
||||
, <strong>*(boost::mpl::and_<
|
||||
boost::is_integral<
|
||||
boost::property_traits<_>::value_type
|
||||
>
|
||||
boost::is_integral<value_type<_> >
|
||||
, boost::is_same<
|
||||
typename boost::graph_traits<graphs::graph::_>::vertex_descriptor
|
||||
, boost::property_traits<_>::key_type
|
||||
vertex_descriptor<graphs::graph::_>, key_type<_>
|
||||
>
|
||||
>)</strong>
|
||||
, get(boost::vertex_index,graph))
|
||||
|
||||
(in_out(color_map)
|
||||
, <strong>*(boost::is_same<
|
||||
typename boost::graph_traits<graphs::graph::_>::vertex_descriptor
|
||||
, boost::property_traits<_>::key_type
|
||||
vertex_descriptor<graphs::graph::_>, key_type<_>
|
||||
>)</strong>
|
||||
, default_color_map(num_vertices(graph), index_map) )
|
||||
)
|
||||
@@ -839,6 +871,8 @@ BOOST_PARAMETER_FUNCTION(
|
||||
</pre>
|
||||
<!-- @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)
|
||||
@@ -847,35 +881,32 @@ BOOST_PARAMETER_NAME((_index_map, graphs) index_map)
|
||||
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') -->
|
||||
<p>Note the use of the nested <cite>tag::_</cite>. This is a shortcut for:</p>
|
||||
<pre class="literal-block">
|
||||
value_type<boost::mpl::_2, tag>
|
||||
</pre>
|
||||
<!-- @ignore() -->
|
||||
<p>Intended to be used to access preceding arguments types in the
|
||||
predicates.</p>
|
||||
<p>We acknowledge that this signature is pretty hairy looking.
|
||||
Fortunately, it usually isn't necessary to so completely encode the
|
||||
type requirements on arguments to generic functions. However, it
|
||||
@@ -889,7 +920,7 @@ with <a class="reference external" href="http://www.generic-programming.org/soft
|
||||
<h4>2.1.5.7 Deduced Parameters</h4>
|
||||
<p>To illustrate deduced parameter support we'll have to leave behind
|
||||
our example from the Graph library. Instead, consider the example
|
||||
of the <a class="reference external" href="../../../python/doc/v2/def.html"><tt class="docutils literal"><span class="pre">def</span></tt></a> function from <a class="reference external" href="../../../python/doc/index.html">Boost.Python</a>. Its signature is
|
||||
of the <a class="reference external" href="../../../python/doc/v2/def.html"><tt class="docutils literal">def</tt></a> function from <a class="reference external" href="../../../python/doc/index.html">Boost.Python</a>. Its signature is
|
||||
roughly as follows:</p>
|
||||
<pre class="literal-block">
|
||||
template <
|
||||
@@ -910,13 +941,13 @@ void def(
|
||||
this example: although it means something analogous in Boost.Python
|
||||
to what it means in the Parameter library, for the purposes of this
|
||||
exercise you can think of it as being completely different.</p>
|
||||
<p>When calling <tt class="docutils literal"><span class="pre">def</span></tt>, only two arguments are required. The
|
||||
<p>When calling <tt class="docutils literal">def</tt>, only two arguments are required. The
|
||||
association between any additional arguments and their parameters
|
||||
can be determined by the types of the arguments actually passed, so
|
||||
the caller is neither required to remember argument positions or
|
||||
explicitly specify parameter names for those arguments. To
|
||||
generate this interface using <tt class="docutils literal"><span class="pre">BOOST_PARAMETER_FUNCTION</span></tt>, we need
|
||||
only enclose the deduced parameters in a <tt class="docutils literal"><span class="pre">(deduced</span> <span class="pre">…)</span></tt> clause, as
|
||||
generate this interface using <tt class="docutils literal">BOOST_PARAMETER_FUNCTION</tt>, we need
|
||||
only enclose the deduced parameters in a <tt class="docutils literal">(deduced …)</tt> clause, as
|
||||
follows:</p>
|
||||
<pre class="literal-block">
|
||||
namespace mpl = boost::mpl;
|
||||
@@ -987,9 +1018,9 @@ void f()
|
||||
''') -->
|
||||
<div class="admonition-syntax-note admonition">
|
||||
<p class="first admonition-title">Syntax Note</p>
|
||||
<p class="last">A <tt class="docutils literal"><span class="pre">(deduced</span> <span class="pre">…)</span></tt> clause always contains a <tt class="docutils literal"><span class="pre">(required</span> <span class="pre">…)</span></tt>
|
||||
and/or an <tt class="docutils literal"><span class="pre">(optional</span> <span class="pre">…)</span></tt> subclause, and must follow any
|
||||
<tt class="docutils literal"><span class="pre">(required</span> <span class="pre">…)</span></tt> or <tt class="docutils literal"><span class="pre">(optional</span> <span class="pre">…)</span></tt> clauses indicating
|
||||
<p class="last">A <tt class="docutils literal">(deduced …)</tt> clause always contains a <tt class="docutils literal">(required …)</tt>
|
||||
and/or an <tt class="docutils literal">(optional …)</tt> subclause, and must follow any
|
||||
<tt class="docutils literal">(required …)</tt> or <tt class="docutils literal">(optional …)</tt> clauses indicating
|
||||
nondeduced parameters at the outer level.</p>
|
||||
</div>
|
||||
<p>With the declaration above, the following two calls are equivalent:</p>
|
||||
@@ -1000,8 +1031,8 @@ def("f", &f, <strong>"Documentation for f"</strong>, <st
|
||||
<!-- @example.prepend('''
|
||||
int main()
|
||||
{''') -->
|
||||
<p>If the user wants to pass a <tt class="docutils literal"><span class="pre">policies</span></tt> argument that was also,
|
||||
for some reason, convertible to <tt class="docutils literal"><span class="pre">char</span> <span class="pre">const*</span></tt>, she can always
|
||||
<p>If the user wants to pass a <tt class="docutils literal">policies</tt> argument that was also,
|
||||
for some reason, convertible to <tt class="docutils literal">char const*</tt>, she can always
|
||||
specify the parameter name explicitly, as follows:</p>
|
||||
<pre class="literal-block">
|
||||
def(
|
||||
@@ -1015,9 +1046,9 @@ def(
|
||||
</div>
|
||||
<div class="section" id="parameter-enabled-member-functions">
|
||||
<h2><a class="toc-backref" href="#id28">2.2 Parameter-Enabled Member Functions</a></h2>
|
||||
<p>The <tt class="docutils literal"><span class="pre">BOOST_PARAMETER_MEMBER_FUNCTION</span></tt> and
|
||||
<tt class="docutils literal"><span class="pre">BOOST_PARAMETER_CONST_MEMBER_FUNCTION</span></tt> macros accept exactly the
|
||||
same arguments as <tt class="docutils literal"><span class="pre">BOOST_PARAMETER_FUNCTION</span></tt>, but are designed to
|
||||
<p>The <tt class="docutils literal">BOOST_PARAMETER_MEMBER_FUNCTION</tt> and
|
||||
<tt class="docutils literal">BOOST_PARAMETER_CONST_MEMBER_FUNCTION</tt> macros accept exactly the
|
||||
same arguments as <tt class="docutils literal">BOOST_PARAMETER_FUNCTION</tt>, but are designed to
|
||||
be used within the body of a class:</p>
|
||||
<pre class="literal-block">
|
||||
BOOST_PARAMETER_NAME(arg1)
|
||||
@@ -1064,7 +1095,7 @@ using namespace boost::parameter;
|
||||
<div class="section" id="static-member-functions">
|
||||
<h3>2.2.1 Static Member Functions</h3>
|
||||
<p>To expose a static member function, simply insert the keyword
|
||||
“<tt class="docutils literal"><span class="pre">static</span></tt>” before the function name:</p>
|
||||
“<tt class="docutils literal">static</tt>” before the function name:</p>
|
||||
<pre class="literal-block">
|
||||
BOOST_PARAMETER_NAME(arg1)
|
||||
|
||||
@@ -1118,11 +1149,11 @@ struct myclass_impl
|
||||
<!-- @example.prepend('''
|
||||
#include <boost/parameter.hpp>
|
||||
#include <iostream>''') -->
|
||||
<p>Note that the bitwise or (“<tt class="docutils literal"><span class="pre">|</span></tt>”) operator has a special
|
||||
<p>Note that the bitwise or (“<tt class="docutils literal">|</tt>”) operator has a special
|
||||
meaning when applied to keyword objects that are passed to an
|
||||
<span class="concept">ArgumentPack</span>'s indexing operator: it is used to indicate a
|
||||
default value. In this case if there is no <tt class="docutils literal"><span class="pre">index</span></tt> parameter in
|
||||
the <span class="concept">ArgumentPack</span>, <tt class="docutils literal"><span class="pre">42</span></tt> will be used instead.</p>
|
||||
default value. In this case if there is no <tt class="docutils literal">index</tt> parameter in
|
||||
the <span class="concept">ArgumentPack</span>, <tt class="docutils literal">42</tt> will be used instead.</p>
|
||||
<p>Now we are ready to write the parameter-enabled constructor
|
||||
interface:</p>
|
||||
<pre class="literal-block">
|
||||
@@ -1133,8 +1164,8 @@ struct myclass : myclass_impl
|
||||
, (required (name,*)) (optional (index,*))) // no semicolon
|
||||
};
|
||||
</pre>
|
||||
<p>Since we have supplied a default value for <tt class="docutils literal"><span class="pre">index</span></tt> but not for
|
||||
<tt class="docutils literal"><span class="pre">name</span></tt>, only <tt class="docutils literal"><span class="pre">name</span></tt> is required. We can exercise our new
|
||||
<p>Since we have supplied a default value for <tt class="docutils literal">index</tt> but not for
|
||||
<tt class="docutils literal">name</tt>, only <tt class="docutils literal">name</tt> is required. We can exercise our new
|
||||
interface as follows:</p>
|
||||
<pre class="literal-block">
|
||||
myclass x("bob", 3); // positional
|
||||
@@ -1157,7 +1188,7 @@ template class<
|
||||
class class_;
|
||||
</pre>
|
||||
<!-- @ignore() -->
|
||||
<p>Only the first argument, <tt class="docutils literal"><span class="pre">ValueType</span></tt>, is required.</p>
|
||||
<p>Only the first argument, <tt class="docutils literal">ValueType</tt>, is required.</p>
|
||||
<div class="section" id="named-template-parameters">
|
||||
<h3>2.4.1 Named Template Parameters</h3>
|
||||
<p>First, we'll build an interface that allows users to pass arguments
|
||||
@@ -1190,7 +1221,7 @@ BOOST_PARAMETER_TEMPLATE_KEYWORD(copyable)
|
||||
</pre>
|
||||
<!-- @example.prepend('#include <boost/parameter.hpp>') -->
|
||||
<!-- @test('compile') -->
|
||||
<p>The declaration of the <tt class="docutils literal"><span class="pre">class_type</span></tt> keyword you see here is
|
||||
<p>The declaration of the <tt class="docutils literal">class_type</tt> keyword you see here is
|
||||
equivalent to:</p>
|
||||
<pre class="literal-block">
|
||||
namespace boost { namespace python {
|
||||
@@ -1206,7 +1237,7 @@ struct class_type
|
||||
<!-- @example.prepend('#include <boost/parameter.hpp>') -->
|
||||
<!-- @test('compile') -->
|
||||
<p>It defines a keyword tag type named <tt class="docutils literal"><span class="pre">tag::class_type</span></tt> and a
|
||||
<em>parameter passing template</em> named <tt class="docutils literal"><span class="pre">class_type</span></tt>.</p>
|
||||
<em>parameter passing template</em> named <tt class="docutils literal">class_type</tt>.</p>
|
||||
</div>
|
||||
<div class="section" id="class-template-skeleton">
|
||||
<h4>2.4.1.2 Class Template Skeleton</h4>
|
||||
@@ -1283,11 +1314,11 @@ struct bases
|
||||
</div>
|
||||
<div class="section" id="argument-packs-and-parameter-extraction">
|
||||
<span id="binding-intro"></span><h4>2.4.1.4 Argument Packs and Parameter Extraction</h4>
|
||||
<p>Next, within the body of <tt class="docutils literal"><span class="pre">class_</span></tt> , we use the <span class="concept">ParameterSpec</span>'s
|
||||
nested <tt class="docutils literal"><span class="pre">::bind<</span> <span class="pre">…</span> <span class="pre">></span></tt> template to bundle the actual arguments into an
|
||||
<a class="reference external" href="reference.html#argumentpack"><span class="concept">ArgumentPack</span></a> type, and then use the library's <tt class="docutils literal"><span class="pre">value_type<</span> <span class="pre">…</span> <span class="pre">></span></tt>
|
||||
metafunction to extract “logical parameters”. <tt class="docutils literal"><span class="pre">value_type<</span> <span class="pre">…</span> <span class="pre">></span></tt> is
|
||||
a lot like <tt class="docutils literal"><span class="pre">binding<</span> <span class="pre">…</span> <span class="pre">></span></tt>, but no reference is added to the actual
|
||||
<p>Next, within the body of <tt class="docutils literal">class_</tt> , we use the <span class="concept">ParameterSpec</span>'s
|
||||
nested <tt class="docutils literal">::bind< … ></tt> template to bundle the actual arguments into an
|
||||
<a class="reference external" href="reference.html#argumentpack"><span class="concept">ArgumentPack</span></a> type, and then use the library's <tt class="docutils literal">value_type< … ></tt>
|
||||
metafunction to extract “logical parameters”. <tt class="docutils literal">value_type< … ></tt> is
|
||||
a lot like <tt class="docutils literal">binding< … ></tt>, but no reference is added to the actual
|
||||
argument type. Note that defaults are specified by passing it an
|
||||
optional third argument:</p>
|
||||
<pre class="literal-block">
|
||||
@@ -1368,13 +1399,13 @@ BOOST_MPL_ASSERT((boost::is_same<c2::copyable, void>));
|
||||
<div class="section" id="deduced-template-parameters">
|
||||
<h3>2.4.3 Deduced Template Parameters</h3>
|
||||
<p>To apply a deduced parameter interface here, we need only make the
|
||||
type requirements a bit tighter so the <tt class="docutils literal"><span class="pre">held_type</span></tt> and
|
||||
<tt class="docutils literal"><span class="pre">copyable</span></tt> parameters can be crisply distinguished from the
|
||||
others. <a class="reference external" href="../../../python/doc/index.html">Boost.Python</a> does this by requiring that <tt class="docutils literal"><span class="pre">base_list</span></tt> be
|
||||
a specialization of its <tt class="docutils literal"><span class="pre">bases<</span> <span class="pre">…</span> <span class="pre">></span></tt> template (as opposed to
|
||||
being any old MPL sequence) and by requiring that <tt class="docutils literal"><span class="pre">copyable</span></tt>, if
|
||||
type requirements a bit tighter so the <tt class="docutils literal">held_type</tt> and
|
||||
<tt class="docutils literal">copyable</tt> parameters can be crisply distinguished from the
|
||||
others. <a class="reference external" href="../../../python/doc/index.html">Boost.Python</a> does this by requiring that <tt class="docutils literal">base_list</tt> be
|
||||
a specialization of its <tt class="docutils literal">bases< … ></tt> template (as opposed to
|
||||
being any old MPL sequence) and by requiring that <tt class="docutils literal">copyable</tt>, if
|
||||
explicitly supplied, be <tt class="docutils literal"><span class="pre">boost::noncopyable</span></tt>. One easy way of
|
||||
identifying specializations of <tt class="docutils literal"><span class="pre">bases<</span> <span class="pre">…</span> <span class="pre">></span></tt> is to derive them all
|
||||
identifying specializations of <tt class="docutils literal">bases< … ></tt> is to derive them all
|
||||
from the same class, as an implementation detail:</p>
|
||||
<pre class="literal-block">
|
||||
namespace boost { namespace python {
|
||||
@@ -1500,9 +1531,9 @@ section we'll cover some more esoteric uses of the library.</p>
|
||||
<div class="section" id="fine-grained-name-control">
|
||||
<h2><a class="toc-backref" href="#id32">3.1 Fine-Grained Name Control</a></h2>
|
||||
<p>If you don't like the leading-underscore naming convention used
|
||||
to refer to keyword objects, or you need the name <tt class="docutils literal"><span class="pre">tag</span></tt> for
|
||||
to refer to keyword objects, or you need the name <tt class="docutils literal">tag</tt> for
|
||||
something other than the keyword type namespace, there's another
|
||||
way to use <tt class="docutils literal"><span class="pre">BOOST_PARAMETER_NAME</span></tt>:</p>
|
||||
way to use <tt class="docutils literal">BOOST_PARAMETER_NAME</tt>:</p>
|
||||
<pre class="literal-block">
|
||||
BOOST_PARAMETER_NAME(<strong>(</strong><em>object-name</em><strong>,</strong> <em>tag-namespace</em><strong>)</strong> <em>parameter-name</em>)
|
||||
</pre>
|
||||
@@ -1556,7 +1587,7 @@ int x = print_index(_index = 3); // prints "index = 3"
|
||||
#include <iostream>''') -->
|
||||
<p>Also, <span class="concept">ArgumentPack</span>s can be composed using the comma operator.
|
||||
The extra parentheses below are used to prevent the compiler from
|
||||
seeing two separate arguments to <tt class="docutils literal"><span class="pre">print_name_and_index</span></tt>:</p>
|
||||
seeing two separate arguments to <tt class="docutils literal">print_name_and_index</tt>:</p>
|
||||
<pre class="literal-block">
|
||||
BOOST_PARAMETER_NAME(name)
|
||||
|
||||
@@ -1573,8 +1604,8 @@ int y = print_name_and_index((_index = 3, _name = "jones"));
|
||||
<a class="reference external" href="reference.html#parameterspec"><span class="concept">ParameterSpec</span></a>. As introduced described in the section on <a class="reference internal" href="#class-template-signatures">Class
|
||||
Template Signatures</a>, a <span class="concept">ParameterSpec</span> describes the positional
|
||||
order of parameters and any associated type requirements. Just as
|
||||
we can build an <span class="concept">ArgumentPack</span> <em>type</em> with its nested <tt class="docutils literal"><span class="pre">::bind<</span> <span class="pre">…</span>
|
||||
<span class="pre">></span></tt> template, we can build an <span class="concept">ArgumentPack</span> <em>object</em> by invoking
|
||||
we can build an <span class="concept">ArgumentPack</span> <em>type</em> with its nested <tt class="docutils literal">::bind< …
|
||||
></tt> template, we can build an <span class="concept">ArgumentPack</span> <em>object</em> by invoking
|
||||
its function call operator:</p>
|
||||
<pre class="literal-block">
|
||||
parameter::parameters<
|
||||
@@ -1601,13 +1632,13 @@ using boost::mpl::_;''') -->
|
||||
int main()
|
||||
{}''') -->
|
||||
<!-- @test('run', howmany='all') -->
|
||||
<p>Note that because of the <a class="reference external" href="http://std.dkuug.dk/jtc1/sc22/wg21/docs/papers/2002/n1385.htm">forwarding problem</a>, <tt class="docutils literal"><span class="pre">parameter::parameters::operator()</span></tt>
|
||||
<p>Note that because of the <a class="reference external" href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2002/n1385.htm">forwarding problem</a>, <tt class="docutils literal"><span class="pre">parameter::parameters::operator()</span></tt>
|
||||
can't accept non-const rvalues.</p>
|
||||
</div>
|
||||
<div class="section" id="extracting-parameter-types">
|
||||
<h3>3.2.2 Extracting Parameter Types</h3>
|
||||
<p>If we want to know the types of the arguments passed to
|
||||
<tt class="docutils literal"><span class="pre">print_name_and_index</span></tt>, we have a couple of options. The
|
||||
<tt class="docutils literal">print_name_and_index</tt>, we have a couple of options. The
|
||||
simplest and least error-prone approach is to forward them to a
|
||||
function template and allow <em>it</em> to do type deduction:</p>
|
||||
<pre class="literal-block">
|
||||
@@ -1643,8 +1674,8 @@ int main()
|
||||
<!-- @test('run') -->
|
||||
<p>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 <tt class="docutils literal"><span class="pre">index</span></tt> parameter? In that
|
||||
case we can use the <tt class="docutils literal"><span class="pre">value_type<</span> <span class="pre">…</span> <span class="pre">></span></tt> metafunction introduced
|
||||
twice the value of the <tt class="docutils literal">index</tt> parameter? In that
|
||||
case we can use the <tt class="docutils literal">value_type< … ></tt> metafunction introduced
|
||||
<a class="reference internal" href="#binding-intro">earlier</a>:</p>
|
||||
<pre class="literal-block">
|
||||
BOOST_PARAMETER_NAME(index)
|
||||
@@ -1671,17 +1702,17 @@ int main()
|
||||
assert(six == 6);
|
||||
}''') -->
|
||||
<!-- @test('run', howmany='all') -->
|
||||
<p>Note that if we had used <tt class="docutils literal"><span class="pre">binding<</span> <span class="pre">…</span> <span class="pre">></span></tt> rather than <tt class="docutils literal"><span class="pre">value_type<</span> <span class="pre">…</span>
|
||||
<span class="pre">></span></tt>, we would end up returning a reference to the temporary created in
|
||||
the <tt class="docutils literal"><span class="pre">2</span> <span class="pre">*</span> <span class="pre">…</span></tt> expression.</p>
|
||||
<p>Note that if we had used <tt class="docutils literal">binding< … ></tt> rather than <tt class="docutils literal">value_type< …
|
||||
></tt>, we would end up returning a reference to the temporary created in
|
||||
the <tt class="docutils literal">2 * …</tt> expression.</p>
|
||||
</div>
|
||||
<div class="section" id="lazy-default-computation">
|
||||
<h3>3.2.3 Lazy Default Computation</h3>
|
||||
<p>When a default value is expensive to compute, it would be
|
||||
preferable to avoid it until we're sure it's absolutely necessary.
|
||||
<tt class="docutils literal"><span class="pre">BOOST_PARAMETER_FUNCTION</span></tt> takes care of that problem for us, but
|
||||
<tt class="docutils literal">BOOST_PARAMETER_FUNCTION</tt> takes care of that problem for us, but
|
||||
when using <span class="concept">ArgumentPack</span>s explicitly, we need a tool other than
|
||||
<tt class="docutils literal"><span class="pre">operator|</span></tt>:</p>
|
||||
<tt class="docutils literal">operator|</tt>:</p>
|
||||
<pre class="literal-block">
|
||||
BOOST_PARAMETER_NAME(s1)
|
||||
BOOST_PARAMETER_NAME(s2)
|
||||
@@ -1709,8 +1740,8 @@ namespace parameter = boost::parameter;''') -->
|
||||
int main()
|
||||
{}''') -->
|
||||
<!-- @test('run') -->
|
||||
<p>In the example above, the string <tt class="docutils literal"><span class="pre">"hello,</span> <span class="pre">world"</span></tt> is constructed
|
||||
despite the fact that the user passed us a value for <tt class="docutils literal"><span class="pre">s3</span></tt>. To
|
||||
<p>In the example above, the string <tt class="docutils literal">"hello, world"</tt> is constructed
|
||||
despite the fact that the user passed us a value for <tt class="docutils literal">s3</tt>. To
|
||||
remedy that, we can compute the default value <em>lazily</em> (that is,
|
||||
only on demand), by using <tt class="docutils literal"><span class="pre">boost::bind()</span></tt> to create a function
|
||||
object.</p>
|
||||
@@ -1720,12 +1751,10 @@ object.</p>
|
||||
<!-- by combining the logical-or (“``||``”) operator -->
|
||||
<!-- with a function object built by the Boost Lambda_ library: [#bind]_ -->
|
||||
<pre class="literal-block">
|
||||
using boost::bind;
|
||||
using boost::ref;
|
||||
|
||||
typename parameter::binding<
|
||||
ArgumentPack, tag::s3, std::string
|
||||
>::type s3 = args[_s3 <strong>|| bind(std::plus<std::string>(), ref(s1), ref(s2))</strong> ];
|
||||
ArgumentPack, <a class="reference external" href="tag::s3">tag::s3</a>, std::string
|
||||
>::type s3 = args[_s3
|
||||
<strong>|| boost::bind(std::plus<std::string>(), boost::ref(s1), boost::ref(s2))</strong> ];
|
||||
</pre>
|
||||
<!-- @example.prepend('''
|
||||
#include <boost/bind.hpp>
|
||||
@@ -1757,15 +1786,15 @@ int main()
|
||||
<!-- .. _Lambda: ../../../lambda/index.html -->
|
||||
<div class="sidebar">
|
||||
<p class="first sidebar-title">Mnemonics</p>
|
||||
<p class="last">To remember the difference between <tt class="docutils literal"><span class="pre">|</span></tt> and <tt class="docutils literal"><span class="pre">||</span></tt>, recall that
|
||||
<tt class="docutils literal"><span class="pre">||</span></tt> normally uses short-circuit evaluation: its second
|
||||
argument is only evaluated if its first argument is <tt class="docutils literal"><span class="pre">false</span></tt>.
|
||||
Similarly, in <tt class="docutils literal"><span class="pre">color_map[param||f]</span></tt>, <tt class="docutils literal"><span class="pre">f</span></tt> is only invoked if
|
||||
no <tt class="docutils literal"><span class="pre">color_map</span></tt> argument was supplied.</p>
|
||||
<p class="last">To remember the difference between <tt class="docutils literal">|</tt> and <tt class="docutils literal">||</tt>, recall that
|
||||
<tt class="docutils literal">||</tt> normally uses short-circuit evaluation: its second
|
||||
argument is only evaluated if its first argument is <tt class="docutils literal">false</tt>.
|
||||
Similarly, in <tt class="docutils literal"><span class="pre">color_map[param||f]</span></tt>, <tt class="docutils literal">f</tt> is only invoked if
|
||||
no <tt class="docutils literal">color_map</tt> argument was supplied.</p>
|
||||
</div>
|
||||
<p>The expression <tt class="docutils literal"><span class="pre">bind(std::plus<std::string>(),</span> <span class="pre">ref(s1),</span> <span class="pre">ref(s2))</span></tt> yields
|
||||
<p>The expression <tt class="docutils literal"><span class="pre">bind(std::plus<std::string>(),</span> ref(s1), ref(s2))</tt> yields
|
||||
a <em>function object</em> that, when invoked, adds the two strings together.
|
||||
That function will only be invoked if no <tt class="docutils literal"><span class="pre">s3</span></tt> argument is supplied by
|
||||
That function will only be invoked if no <tt class="docutils literal">s3</tt> argument is supplied by
|
||||
the caller.</p>
|
||||
<!-- The expression ``lambda::var(s1)+lambda::var(s2)`` yields a -->
|
||||
<!-- *function object* that, when invoked, adds the two strings -->
|
||||
@@ -1781,7 +1810,7 @@ Parameter library. This section points out a few more-marginal
|
||||
issues that will help you use the library more effectively.</p>
|
||||
<div class="section" id="keyword-naming">
|
||||
<h2><a class="toc-backref" href="#id35">4.1 Keyword Naming</a></h2>
|
||||
<p><tt class="docutils literal"><span class="pre">BOOST_PARAMETER_NAME</span></tt> prepends a leading underscore to the names
|
||||
<p><tt class="docutils literal">BOOST_PARAMETER_NAME</tt> prepends a leading underscore to the names
|
||||
of all our keyword objects in order to avoid the following
|
||||
usually-silent bug:</p>
|
||||
<pre class="literal-block">
|
||||
@@ -1815,19 +1844,19 @@ namespace people
|
||||
</pre>
|
||||
<!-- @ignore() -->
|
||||
<p>Although in the case above, the user was trying to pass the value
|
||||
<tt class="docutils literal"><span class="pre">3</span></tt> as the <tt class="docutils literal"><span class="pre">age</span></tt> parameter to <tt class="docutils literal"><span class="pre">g</span></tt>, what happened instead
|
||||
was that <tt class="docutils literal"><span class="pre">f</span></tt>'s <tt class="docutils literal"><span class="pre">age</span></tt> argument got reassigned the value 3,
|
||||
and was then passed as a positional argument to <tt class="docutils literal"><span class="pre">g</span></tt>. Since
|
||||
<tt class="docutils literal"><span class="pre">g</span></tt>'s first positional parameter is <tt class="docutils literal"><span class="pre">name</span></tt>, the default value
|
||||
for <tt class="docutils literal"><span class="pre">age</span></tt> is used, and g prints <tt class="docutils literal"><span class="pre">3:42</span></tt>. Our leading
|
||||
<tt class="docutils literal">3</tt> as the <tt class="docutils literal">age</tt> parameter to <tt class="docutils literal">g</tt>, what happened instead
|
||||
was that <tt class="docutils literal">f</tt>'s <tt class="docutils literal">age</tt> argument got reassigned the value 3,
|
||||
and was then passed as a positional argument to <tt class="docutils literal">g</tt>. Since
|
||||
<tt class="docutils literal">g</tt>'s first positional parameter is <tt class="docutils literal">name</tt>, the default value
|
||||
for <tt class="docutils literal">age</tt> is used, and g prints <tt class="docutils literal">3:42</tt>. Our leading
|
||||
underscore naming convention that makes this problem less likely
|
||||
to occur.</p>
|
||||
<p>In this particular case, the problem could have been detected if
|
||||
f's <tt class="docutils literal"><span class="pre">age</span></tt> parameter had been made <tt class="docutils literal"><span class="pre">const</span></tt>, which is always a
|
||||
f's <tt class="docutils literal">age</tt> parameter had been made <tt class="docutils literal">const</tt>, which is always a
|
||||
good idea whenever possible. Finally, we recommend that you use
|
||||
an enclosing namespace for all your code, but particularly for
|
||||
names with leading underscores. If we were to leave out the
|
||||
<tt class="docutils literal"><span class="pre">people</span></tt> namespace above, names in the global namespace
|
||||
<tt class="docutils literal">people</tt> namespace above, names in the global namespace
|
||||
beginning with leading underscores—which are reserved to your C++
|
||||
compiler—might become irretrievably ambiguous with those in our
|
||||
unnamed namespace.</p>
|
||||
@@ -1898,7 +1927,7 @@ manage.</p>
|
||||
int x = <strong>f</strong>(_name = "jill", _index = 3);
|
||||
</pre>
|
||||
<p>This option is convenient, but it indiscriminately makes the
|
||||
<em>entire</em> contents of <tt class="docutils literal"><span class="pre">lib</span></tt> available without qualification.</p>
|
||||
<em>entire</em> contents of <tt class="docutils literal">lib</tt> available without qualification.</p>
|
||||
</blockquote>
|
||||
<!-- @example.prepend(namespace_setup) -->
|
||||
<!-- @example.append('int main() {}') -->
|
||||
@@ -1928,7 +1957,7 @@ namespace lib
|
||||
#include <boost/parameter.hpp>
|
||||
#include <iostream>''') -->
|
||||
<p>Now users need only a single <em>using-directive</em> to bring in just the
|
||||
names of all keywords associated with <tt class="docutils literal"><span class="pre">lib</span></tt>:</p>
|
||||
names of all keywords associated with <tt class="docutils literal">lib</tt>:</p>
|
||||
<pre class="literal-block">
|
||||
<strong>using namespace lib::keywords;</strong>
|
||||
int y = lib::f(_name = "bob", _index = 2);
|
||||
@@ -1959,22 +1988,22 @@ issues and workarounds for particular compilers.</p>
|
||||
<div class="section" id="no-sfinae-support">
|
||||
<h2><a class="toc-backref" href="#id39">5.1 No SFINAE Support</a></h2>
|
||||
<p>Some older compilers don't support SFINAE. If your compiler meets
|
||||
that criterion, then Boost headers will <tt class="docutils literal"><span class="pre">#define</span></tt> the preprocessor
|
||||
symbol <tt class="docutils literal"><span class="pre">BOOST_NO_SFINAE</span></tt>, and parameter-enabled functions won't be
|
||||
that criterion, then Boost headers will <tt class="docutils literal">#define</tt> the preprocessor
|
||||
symbol <tt class="docutils literal">BOOST_NO_SFINAE</tt>, and parameter-enabled functions won't be
|
||||
removed from the overload set based on their signatures.</p>
|
||||
</div>
|
||||
<div class="section" id="no-support-for-result-of">
|
||||
<h2>5.2 No Support for <a class="reference external" href="../../../utility/utility.htm#result_of"><tt class="docutils literal"><span class="pre">result_of</span></tt></a></h2>
|
||||
<p><a class="reference internal" href="#lazy-default-computation">Lazy default computation</a> relies on the <tt class="docutils literal"><span class="pre">result_of</span></tt> class
|
||||
<h2>5.2 No Support for <a class="reference external" href="../../../utility/utility.htm#result_of"><tt class="docutils literal">result_of</tt></a></h2>
|
||||
<p><a class="reference internal" href="#lazy-default-computation">Lazy default computation</a> relies on the <tt class="docutils literal">result_of</tt> class
|
||||
template to compute the types of default arguments given the type
|
||||
of the function object that constructs them. On compilers that
|
||||
don't support <tt class="docutils literal"><span class="pre">result_of</span></tt>, <tt class="docutils literal"><span class="pre">BOOST_NO_RESULT_OF</span></tt> will be
|
||||
<tt class="docutils literal"><span class="pre">#define</span></tt>d, and the compiler will expect the function object to
|
||||
contain a nested type name, <tt class="docutils literal"><span class="pre">result_type</span></tt>, that indicates its
|
||||
don't support <tt class="docutils literal">result_of</tt>, <tt class="docutils literal">BOOST_NO_RESULT_OF</tt> will be
|
||||
<tt class="docutils literal">#define</tt>d, and the compiler will expect the function object to
|
||||
contain a nested type name, <tt class="docutils literal">result_type</tt>, that indicates its
|
||||
return type when invoked without arguments. To use an ordinary
|
||||
function as a default generator on those compilers, you'll need to
|
||||
wrap it in a class that provides <tt class="docutils literal"><span class="pre">result_type</span></tt> as a <tt class="docutils literal"><span class="pre">typedef</span></tt>
|
||||
and invokes the function via its <tt class="docutils literal"><span class="pre">operator()</span></tt>.</p>
|
||||
wrap it in a class that provides <tt class="docutils literal">result_type</tt> as a <tt class="docutils literal">typedef</tt>
|
||||
and invokes the function via its <tt class="docutils literal">operator()</tt>.</p>
|
||||
<!-- Can't Declare |ParameterSpec| via ``typedef``
|
||||
=============================================
|
||||
|
||||
@@ -2054,8 +2083,8 @@ function or class template</td>
|
||||
<tr class="field"><th class="field-name" colspan="2">Parameter (or “formal parameter”):</th></tr>
|
||||
<tr><td> </td><td class="field-body"><p class="first">the name used to refer to an
|
||||
argument within a function or class template. For example, the
|
||||
value of <tt class="docutils literal"><span class="pre">f</span></tt>'s <em>parameter</em> <tt class="docutils literal"><span class="pre">x</span></tt> is given by the <em>argument</em>
|
||||
<tt class="docutils literal"><span class="pre">3</span></tt>:</p>
|
||||
value of <tt class="docutils literal">f</tt>'s <em>parameter</em> <tt class="docutils literal">x</tt> is given by the <em>argument</em>
|
||||
<tt class="docutils literal">3</tt>:</p>
|
||||
<pre class="last literal-block">
|
||||
int f(int x) { return x + 1 }
|
||||
int y = f(3);
|
||||
@@ -2096,7 +2125,7 @@ units (object files) that make up a program.</td></tr>
|
||||
Library, don't worry about the meaning of any
|
||||
Graph-library-specific details you encounter. In this case you
|
||||
could replace all mentions of vertex descriptor types with
|
||||
<tt class="docutils literal"><span class="pre">int</span></tt> in the text, and your understanding of the Parameter
|
||||
<tt class="docutils literal">int</tt> in the text, and your understanding of the Parameter
|
||||
library wouldn't suffer.</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -2114,7 +2143,7 @@ library wouldn't suffer.</td></tr>
|
||||
<colgroup><col class="label" /><col /></colgroup>
|
||||
<tbody valign="top">
|
||||
<tr><td class="label">[5]</td><td><em>(<a class="fn-backref" href="#id13">1</a>, <a class="fn-backref" href="#id14">2</a>)</em> Here we're assuming there's a predicate
|
||||
metafunction <tt class="docutils literal"><span class="pre">is_keyword_expression</span></tt> that can be used to
|
||||
metafunction <tt class="docutils literal">is_keyword_expression</tt> that can be used to
|
||||
identify models of Boost.Python's KeywordExpression concept.</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -2151,9 +2180,9 @@ from the overload set. By producing an invalid type in the
|
||||
function signature depending on the result of some condition,
|
||||
we can decide whether or not an overload is considered during overload
|
||||
resolution. The technique is formalized in
|
||||
the <a class="reference external" href="../../../utility/enable_if.html"><tt class="docutils literal"><span class="pre">enable_if</span></tt></a> utility. Most recent compilers support SFINAE;
|
||||
the <a class="reference external" href="../../../utility/enable_if.html"><tt class="docutils literal">enable_if</tt></a> utility. Most recent compilers support SFINAE;
|
||||
on compilers that don't support it, the Boost config library
|
||||
will <tt class="docutils literal"><span class="pre">#define</span></tt> the symbol <tt class="docutils literal"><span class="pre">BOOST_NO_SFINAE</span></tt>.
|
||||
will <tt class="docutils literal">#define</tt> the symbol <tt class="docutils literal">BOOST_NO_SFINAE</tt>.
|
||||
See
|
||||
<a class="reference external" href="http://www.semantics.org/once_weakly/w02_SFINAE.pdf">http://www.semantics.org/once_weakly/w02_SFINAE.pdf</a> for more
|
||||
information on SFINAE.</td></tr>
|
||||
@@ -2163,7 +2192,7 @@ information on SFINAE.</td></tr>
|
||||
</div>
|
||||
<div class="footer">
|
||||
<hr class="footer" />
|
||||
Generated on: 2009-05-31 01:40 UTC.
|
||||
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.
|
||||
|
||||
</div>
|
||||
|
||||
@@ -1,788 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta name="generator" content="Docutils 0.6: 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)" />
|
||||
<link rel="stylesheet" href="rst.css" type="text/css" />
|
||||
</head>
|
||||
<body>
|
||||
<div class="document" id="the-boost-parameter-library-python-binding-documentation">
|
||||
<h1 class="title">The Boost Parameter Library Python Binding Documentation</h1>
|
||||
<table class="docinfo" frame="void" rules="none">
|
||||
<col class="docinfo-name" />
|
||||
<col class="docinfo-content" />
|
||||
<tbody valign="top">
|
||||
<tr><th class="docinfo-name">Authors:</th>
|
||||
<td>David Abrahams
|
||||
<br />Daniel Wallin</td></tr>
|
||||
<tr><th class="docinfo-name">Contact:</th>
|
||||
<td><a class="first reference external" href="mailto:dave@boost-consulting.com">dave@boost-consulting.com</a>, <a class="last reference external" href="mailto:daniel@boostpro.com">daniel@boostpro.com</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>
|
||||
<tr><th class="docinfo-name">Date:</th>
|
||||
<td>2009-01-29</td></tr>
|
||||
<tr><th class="docinfo-name">Copyright:</th>
|
||||
<td>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 <a class="reference external" 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">
|
||||
<p class="topic-title first">Abstract</p>
|
||||
<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>
|
||||
<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"><span class="pre">init</span></tt></a></li>
|
||||
<li><a class="reference internal" href="#class-template-call" id="id12">class template <tt class="docutils literal"><span class="pre">call</span></tt></a></li>
|
||||
<li><a class="reference internal" href="#class-template-function" id="id13">class template <tt class="docutils literal"><span class="pre">function</span></tt></a></li>
|
||||
<li><a class="reference internal" href="#function-template-def" id="id14">function template <tt class="docutils literal"><span class="pre">def</span></tt></a></li>
|
||||
<li><a class="reference internal" href="#portability" id="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"><span class="pre">boost/parameter/python.hpp</span></tt> introduces a group of <a class="reference external" 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"><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
|
||||
functions are templates, the desired function signature must be
|
||||
specified.</p>
|
||||
<!-- The keyword tags are specified as an `MPL Sequence`_, using the
|
||||
pointer qualifications described in |ParameterSpec|_ below. The
|
||||
signature is also specifid as an `MPL sequence`_ of parameter
|
||||
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>
|
||||
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>
|
||||
<!-- The last two sentences are terribly vague. Which namespace is -->
|
||||
<!-- ``function`` in? Isn't the return type always needed? What -->
|
||||
<!-- 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>
|
||||
<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>
|
||||
<p>The class and member function we are interested in binding looks
|
||||
like this:</p>
|
||||
<pre class="literal-block">
|
||||
#include <boost/parameter/keyword.hpp>
|
||||
#include <boost/parameter/preprocessor.hpp>
|
||||
#include <boost/parameter/python.hpp>
|
||||
#include <boost/python.hpp>
|
||||
|
||||
// First the keywords
|
||||
BOOST_PARAMETER_KEYWORD(tag, title)
|
||||
BOOST_PARAMETER_KEYWORD(tag, width)
|
||||
BOOST_PARAMETER_KEYWORD(tag, height)
|
||||
|
||||
class window
|
||||
{
|
||||
public:
|
||||
BOOST_PARAMETER_MEMBER_FUNCTION(
|
||||
(void), open, tag,
|
||||
(required (title, (std::string)))
|
||||
(optional (width, (unsigned), 400)
|
||||
(height, (unsigned), 400))
|
||||
)
|
||||
{
|
||||
<em>… function implementation …</em>
|
||||
}
|
||||
};
|
||||
</pre>
|
||||
<!-- @example.prepend('#include <cassert>') -->
|
||||
<!-- @example.replace_emphasis('''
|
||||
assert(title == "foo");
|
||||
assert(height == 20);
|
||||
assert(width == 400);
|
||||
''') -->
|
||||
<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"><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>
|
||||
is a function template, so we can't refer to it in any other way.</p>
|
||||
<pre class="literal-block">
|
||||
struct open_fwd
|
||||
{
|
||||
template <class A0, class A1, class A2>
|
||||
void operator()(
|
||||
boost::type<void>, window& self
|
||||
, A0 const& a0, A1 const& a1, A2 const& a2
|
||||
)
|
||||
{
|
||||
self.open(a0, a1, a2);
|
||||
}
|
||||
};
|
||||
</pre>
|
||||
<p>The first parameter, <tt class="docutils literal"><span class="pre">boost::type<void></span></tt>, tells the forwarding overload
|
||||
what the return type should be. In this case we know that it's always void
|
||||
but in some cases, when we are exporting several specializations of a
|
||||
Boost.Parameter-enabled template, we need to use that parameter to
|
||||
deduce the return type.</p>
|
||||
<p><tt class="docutils literal"><span class="pre">window::open()</span></tt> takes a total of 3 parameters, so the forwarding function
|
||||
needs to take three parameters as well.</p>
|
||||
<div class="note">
|
||||
<p class="first admonition-title">Note</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>
|
||||
</div>
|
||||
<p>Next we'll define the module and export the class:</p>
|
||||
<pre class="literal-block">
|
||||
BOOST_PYTHON_MODULE(my_module)
|
||||
{
|
||||
using namespace boost::python;
|
||||
namespace py = boost::parameter::python;
|
||||
namespace mpl = boost::mpl;
|
||||
|
||||
class_<window>("window")
|
||||
.def(
|
||||
"open", py::function<
|
||||
open_fwd
|
||||
, mpl::vector<
|
||||
void
|
||||
, tag::title(std::string)
|
||||
, tag::width*(unsigned)
|
||||
, tag::height*(unsigned)
|
||||
>
|
||||
>()
|
||||
);
|
||||
}
|
||||
</pre>
|
||||
<!-- @jam_prefix.append('import python ;') -->
|
||||
<!-- @jam_prefix.append('stage . : my_module /boost/python//boost_python ;') -->
|
||||
<!-- @my_module = build(
|
||||
output = 'my_module'
|
||||
, target_rule = 'python-extension'
|
||||
, input = '/boost/python//boost_python'
|
||||
, howmany = 'all'
|
||||
) -->
|
||||
<!-- @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
|
||||
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"><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
|
||||
``width`` and ``height`` are optional parameters. The third parameter
|
||||
is an `MPL Sequence`_ with the desired function signature. The return type comes first, and
|
||||
then the parameter types:
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
mpl::vector<void, std::string, unsigned, unsigned>
|
||||
*return type* *title* *width* *height*
|
||||
|
||||
.. @ignore() -->
|
||||
<p>That's it! This class can now be used in Python with the expected syntax:</p>
|
||||
<pre class="literal-block">
|
||||
>>> w = my_module.window()
|
||||
>>> w.open(title = "foo", height = 20)
|
||||
</pre>
|
||||
<!-- @example.prepend('import my_module') -->
|
||||
<!-- @run_python(module_path = my_module) -->
|
||||
<!-- Sorry to say this at such a late date, but this syntax really -->
|
||||
<!-- strikes me as cumbersome. Couldn't we do something like:
|
||||
|
||||
class_<window>("window")
|
||||
.def(
|
||||
"open",
|
||||
(void (*)(
|
||||
tag::title(std::string),
|
||||
tag::width*(unsigned),
|
||||
tag::height*(unsigned))
|
||||
)0
|
||||
);
|
||||
|
||||
or at least:
|
||||
|
||||
class_<window>("window")
|
||||
.def(
|
||||
"open",
|
||||
mpl::vector<
|
||||
void,
|
||||
tag::title(std::string),
|
||||
tag::width*(unsigned),
|
||||
tag::height*(unsigned)
|
||||
>()
|
||||
);
|
||||
|
||||
assuming, that is, that we will have to repeat the tags (yes,
|
||||
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"><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"><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"><span class="pre">Tag</span></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
|
||||
defined as the closed range:</p>
|
||||
<pre class="literal-block">
|
||||
[ mpl::size<S> - number of <em>special</em> keyword tags in <tt class="docutils literal"><span class="pre">S</span></tt>, mpl::size<S> ]
|
||||
</pre>
|
||||
<p>For example, the <strong>arity range</strong> of <tt class="docutils literal"><span class="pre">mpl::vector2<x(int),y(int)></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<x(int),y*(int)></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<x(int),y**(int)></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>
|
||||
<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>
|
||||
<!-- An example_ of this is given in the Boost.Parameter
|
||||
docs. The example uses a different technique, but could also have been written like this: -->
|
||||
<pre class="literal-block">
|
||||
namespace core
|
||||
{
|
||||
template <class ArgumentPack>
|
||||
void dfs_dispatch(ArgumentPack const& args, mpl::false_)
|
||||
{
|
||||
<em>…compute and use default color map…</em>
|
||||
}
|
||||
|
||||
template <class ArgumentPack, class ColorMap>
|
||||
void dfs_dispatch(ArgumentPack const& args, ColorMap colormap)
|
||||
{
|
||||
<em>…use colormap…</em>
|
||||
}
|
||||
}
|
||||
|
||||
template <class ArgumentPack>
|
||||
void depth_first_search(ArgumentPack const& args)
|
||||
{
|
||||
core::dfs_dispatch(args, args[color | mpl::false_()]);
|
||||
}
|
||||
</pre>
|
||||
<!-- @example.prepend('''
|
||||
#include <boost/parameter/keyword.hpp>
|
||||
#include <boost/parameter/parameters.hpp>
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <cassert>
|
||||
|
||||
BOOST_PARAMETER_KEYWORD(tag, color);
|
||||
|
||||
typedef boost::parameter::parameters<tag::color> params;
|
||||
|
||||
namespace mpl = boost::mpl;
|
||||
''') -->
|
||||
<!-- @example.replace_emphasis('''
|
||||
assert(args[color | 1] == 1);
|
||||
''') -->
|
||||
<!-- @example.replace_emphasis('''
|
||||
assert(args[color | 1] == 0);
|
||||
''') -->
|
||||
<!-- @example.append('''
|
||||
int main()
|
||||
{
|
||||
depth_first_search(params()());
|
||||
depth_first_search(params()(color = 0));
|
||||
}''') -->
|
||||
<!-- @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"><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"><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
|
||||
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"><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"><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"><span class="pre">init</span></tt></a></h1>
|
||||
<p>Defines a named parameter enabled constructor.</p>
|
||||
<pre class="literal-block">
|
||||
template <class ParameterSpecs>
|
||||
struct init : python::def_visitor<init<ParameterSpecs> >
|
||||
{
|
||||
template <class Class>
|
||||
void def(Class& class_);
|
||||
|
||||
template <class CallPolicies>
|
||||
<em>def_visitor</em> operator[](CallPolicies const& policies) const;
|
||||
};
|
||||
</pre>
|
||||
<!-- @ignore() -->
|
||||
<div class="section" id="init-requirements">
|
||||
<h2><tt class="docutils literal"><span class="pre">init</span></tt> requirements</h2>
|
||||
<ul>
|
||||
<li><p class="first"><tt class="docutils literal"><span class="pre">ParameterSpecs</span></tt> is an <a class="reference external" 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"><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>
|
||||
<col width="30%" />
|
||||
<col width="17%" />
|
||||
<col width="53%" />
|
||||
</colgroup>
|
||||
<thead valign="bottom">
|
||||
<tr><th class="head"><p class="first last">Expression</p>
|
||||
</th>
|
||||
<th class="head"><p class="first last">Return type</p>
|
||||
</th>
|
||||
<th class="head"><p class="first last">Requirements</p>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody valign="top">
|
||||
<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"><span class="pre">a0</span></tt>…<tt class="docutils literal"><span class="pre">aN</span></tt> are tagged arguments.</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="template-class-callpolicies-operator-callpolicies-const">
|
||||
<h2><tt class="docutils literal"><span class="pre">template</span> <span class="pre"><class</span> <span class="pre">CallPolicies></span> <span class="pre">operator[](CallPolicies</span> <span class="pre">const&)</span></tt></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>
|
||||
<pre class="literal-block">
|
||||
#include <boost/parameter/keyword.hpp>
|
||||
#include <boost/parameter/preprocessor.hpp>
|
||||
#include <boost/parameter/python.hpp>
|
||||
#include <boost/python.hpp>
|
||||
#include <boost/mpl/vector.hpp>
|
||||
|
||||
BOOST_PARAMETER_KEYWORD(tag, x)
|
||||
BOOST_PARAMETER_KEYWORD(tag, y)
|
||||
|
||||
struct base
|
||||
{
|
||||
template <class ArgumentPack>
|
||||
base(ArgumentPack const& args)
|
||||
{
|
||||
<em>… use args …</em>
|
||||
}
|
||||
};
|
||||
|
||||
class X : base
|
||||
{
|
||||
public:
|
||||
BOOST_PARAMETER_CONSTRUCTOR(X, (base), tag,
|
||||
(required (x, *))
|
||||
(optional (y, *))
|
||||
)
|
||||
};
|
||||
|
||||
BOOST_PYTHON_MODULE(<em>module name</em>)
|
||||
{
|
||||
using namespace boost::python;
|
||||
namespace py = boost::parameter::python;
|
||||
namespace mpl = boost::mpl;
|
||||
|
||||
class_<X>("X", no_init)
|
||||
.def(
|
||||
py::init<
|
||||
mpl::vector<tag::x(int), tag::y*(int)>
|
||||
>()
|
||||
);
|
||||
}
|
||||
</pre>
|
||||
<!-- @example.replace_emphasis('''
|
||||
assert(args[x] == 0);
|
||||
assert(args[y | 1] == 1);
|
||||
''') -->
|
||||
<!-- @example.replace_emphasis('my_module') -->
|
||||
<!-- @jam_prefix.append('import python ;') -->
|
||||
<!-- @jam_prefix.append('stage . : my_module /boost/python//boost_python ;') -->
|
||||
<!-- @my_module = build(
|
||||
output = 'my_module'
|
||||
, target_rule = 'python-extension'
|
||||
, input = '/boost/python//boost_python'
|
||||
) -->
|
||||
</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"><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 <class ParameterSpecs>
|
||||
struct call : python::def_visitor<call<ParameterSpecs> >
|
||||
{
|
||||
template <class Class>
|
||||
void def(Class& class_);
|
||||
|
||||
template <class CallPolicies>
|
||||
<em>def_visitor</em> operator[](CallPolicies const& policies) const;
|
||||
};
|
||||
</pre>
|
||||
<!-- @ignore() -->
|
||||
<div class="section" id="call-requirements">
|
||||
<h2><tt class="docutils literal"><span class="pre">call</span></tt> requirements</h2>
|
||||
<ul>
|
||||
<li><p class="first"><tt class="docutils literal"><span class="pre">ParameterSpecs</span></tt> is an <a class="reference external" 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"><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%" />
|
||||
<col width="26%" />
|
||||
<col width="50%" />
|
||||
</colgroup>
|
||||
<thead valign="bottom">
|
||||
<tr><th class="head"><p class="first last">Expression</p>
|
||||
</th>
|
||||
<th class="head"><p class="first last">Return type</p>
|
||||
</th>
|
||||
<th class="head"><p class="first last">Requirements</p>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody valign="top">
|
||||
<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"><span class="pre">R</span></tt></p>
|
||||
</td>
|
||||
<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"><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"><span class="pre">template</span> <span class="pre"><class</span> <span class="pre">CallPolicies></span> <span class="pre">operator[](CallPolicies</span> <span class="pre">const&)</span></tt></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>
|
||||
<pre class="literal-block">
|
||||
#include <boost/parameter/keyword.hpp>
|
||||
#include <boost/parameter/preprocessor.hpp>
|
||||
#include <boost/parameter/python.hpp>
|
||||
#include <boost/python.hpp>
|
||||
#include <boost/mpl/vector.hpp>
|
||||
|
||||
BOOST_PARAMETER_KEYWORD(tag, x)
|
||||
BOOST_PARAMETER_KEYWORD(tag, y)
|
||||
|
||||
namespace parameter = boost::parameter;
|
||||
|
||||
typedef parameter::parameters<
|
||||
parameter::required<tag::x>
|
||||
, parameter::optional<tag::y>
|
||||
> call_parameters;
|
||||
|
||||
class X
|
||||
{
|
||||
public:
|
||||
template <class ArgumentPack>
|
||||
int call_impl(ArgumentPack const& args)
|
||||
{
|
||||
<em>… use args …</em>
|
||||
}
|
||||
|
||||
template <class A0>
|
||||
int operator()(A0 const& a0)
|
||||
{
|
||||
return call_impl(call_parameters()(a0));
|
||||
}
|
||||
|
||||
template <class A0, class A1>
|
||||
int operator()(A0 const& a0, A1 const& a1)
|
||||
{
|
||||
return call_impl(call_parameters()(a0,a1));
|
||||
}
|
||||
};
|
||||
|
||||
BOOST_PYTHON_MODULE(<em>module name</em>)
|
||||
{
|
||||
using namespace boost::python;
|
||||
namespace py = parameter::python;
|
||||
namespace mpl = boost::mpl;
|
||||
|
||||
class_<X>("X")
|
||||
.def(
|
||||
py::call<
|
||||
mpl::vector<int, tag::x(int), tag::y*(int)>
|
||||
>()
|
||||
);
|
||||
}
|
||||
</pre>
|
||||
<!-- @example.replace_emphasis('''
|
||||
assert(args[x] == 0);
|
||||
assert(args[y | 1] == 1);
|
||||
return 0;
|
||||
''') -->
|
||||
<!-- @example.replace_emphasis('my_module') -->
|
||||
<!-- @my_module = build(
|
||||
output = 'my_module'
|
||||
, target_rule = 'python-extension'
|
||||
, input = '/boost/python//boost_python'
|
||||
) -->
|
||||
</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"><span class="pre">function</span></tt></a></h1>
|
||||
<p>Defines a named parameter enabled member function.</p>
|
||||
<pre class="literal-block">
|
||||
template <class Fwd, class ParameterSpecs>
|
||||
struct function : python::def_visitor<function<Fwd, ParameterSpecs> >
|
||||
{
|
||||
template <class Class, class Options>
|
||||
void def(Class& class_, char const* name, Options const& options);
|
||||
};
|
||||
</pre>
|
||||
<!-- @ignore() -->
|
||||
<div class="section" id="function-requirements">
|
||||
<h2><tt class="docutils literal"><span class="pre">function</span></tt> requirements</h2>
|
||||
<ul>
|
||||
<li><p class="first"><tt class="docutils literal"><span class="pre">ParameterSpecs</span></tt> is an <a class="reference external" 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"><span class="pre">f</span></tt> is the member
|
||||
function.</p>
|
||||
</li>
|
||||
<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%" />
|
||||
<col width="18%" />
|
||||
<col width="43%" />
|
||||
</colgroup>
|
||||
<thead valign="bottom">
|
||||
<tr><th class="head"><p class="first last">Expression</p>
|
||||
</th>
|
||||
<th class="head"><p class="first last">Return type</p>
|
||||
</th>
|
||||
<th class="head"><p class="first last">Requirements</p>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody valign="top">
|
||||
<tr><td><p class="first last"><tt class="docutils literal"><span class="pre">fwd(boost::type<R>(),</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"><span class="pre">R</span></tt></p>
|
||||
</td>
|
||||
<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"><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"><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<tag::x(int),</span> <span class="pre">tag::y*(int)></span></tt> has
|
||||
an <strong>arity range</strong> of [2,2], so we only need one forwarding overload.</p>
|
||||
<pre class="literal-block">
|
||||
#include <boost/parameter/keyword.hpp>
|
||||
#include <boost/parameter/preprocessor.hpp>
|
||||
#include <boost/parameter/python.hpp>
|
||||
#include <boost/python.hpp>
|
||||
#include <boost/mpl/vector.hpp>
|
||||
|
||||
BOOST_PARAMETER_KEYWORD(tag, x)
|
||||
BOOST_PARAMETER_KEYWORD(tag, y)
|
||||
|
||||
class X
|
||||
{
|
||||
public:
|
||||
BOOST_PARAMETER_MEMBER_FUNCTION((void), f, tag,
|
||||
(required (x, *))
|
||||
(optional (y, *, 1))
|
||||
)
|
||||
{
|
||||
<em>…</em>
|
||||
}
|
||||
};
|
||||
|
||||
struct f_fwd
|
||||
{
|
||||
template <class A0, class A1>
|
||||
void operator()(boost::type<void>, X& self, A0 const& a0, A1 const& a1)
|
||||
{
|
||||
self.f(a0, a1);
|
||||
}
|
||||
};
|
||||
|
||||
BOOST_PYTHON_MODULE(<em>module name</em>)
|
||||
{
|
||||
using namespace boost::python;
|
||||
namespace py = boost::parameter::python;
|
||||
namespace mpl = boost::mpl;
|
||||
|
||||
class_<X>("X")
|
||||
.def("f",
|
||||
py::function<
|
||||
f_fwd
|
||||
, mpl::vector<void, tag::x(int), tag::y*(int)>
|
||||
>()
|
||||
);
|
||||
}
|
||||
</pre>
|
||||
<!-- @example.replace_emphasis('''
|
||||
assert(x == 0);
|
||||
assert(y == 1);
|
||||
''') -->
|
||||
<!-- @example.replace_emphasis('my_module') -->
|
||||
<!-- @my_module = build(
|
||||
output = 'my_module'
|
||||
, target_rule = 'python-extension'
|
||||
, input = '/boost/python//boost_python'
|
||||
) -->
|
||||
</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"><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 <class Fwd, class ParameterSpecs>
|
||||
void def(char const* name);
|
||||
</pre>
|
||||
<!-- @ignore() -->
|
||||
<div class="section" id="def-requirements">
|
||||
<h2><tt class="docutils literal"><span class="pre">def</span></tt> requirements</h2>
|
||||
<ul>
|
||||
<li><p class="first"><tt class="docutils literal"><span class="pre">ParameterSpecs</span></tt> is an <a class="reference external" 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"><span class="pre">f</span></tt> is the function.</p>
|
||||
</li>
|
||||
<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%" />
|
||||
<col width="21%" />
|
||||
<col width="40%" />
|
||||
</colgroup>
|
||||
<thead valign="bottom">
|
||||
<tr><th class="head"><p class="first last">Expression</p>
|
||||
</th>
|
||||
<th class="head"><p class="first last">Return type</p>
|
||||
</th>
|
||||
<th class="head"><p class="first last">Requirements</p>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody valign="top">
|
||||
<tr><td><p class="first last"><tt class="docutils literal"><span class="pre">fwd(boost::type<R>(),</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"><span class="pre">R</span></tt></p>
|
||||
</td>
|
||||
<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"><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"><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<tag::x(int),</span> <span class="pre">tag::y*(int)></span></tt> has
|
||||
an <strong>arity range</strong> of [2,2], so we only need one forwarding overload.</p>
|
||||
<pre class="literal-block">
|
||||
BOOST_PARAMETER_FUNCTION((void), f, tag,
|
||||
(required (x, *))
|
||||
(optional (y, *, 1))
|
||||
)
|
||||
{
|
||||
<em>…</em>
|
||||
}
|
||||
|
||||
struct f_fwd
|
||||
{
|
||||
template <class A0, class A1>
|
||||
void operator()(boost::type<void>, A0 const& a0, A1 const& a1)
|
||||
{
|
||||
f(a0, a1);
|
||||
}
|
||||
};
|
||||
|
||||
BOOST_PYTHON_MODULE(…)
|
||||
{
|
||||
def<
|
||||
f_fwd
|
||||
, mpl::vector<
|
||||
void, tag::x(int), tag::y*(int)
|
||||
>
|
||||
>("f");
|
||||
}
|
||||
</pre>
|
||||
<!-- @ignore() -->
|
||||
<!-- again, the undefined ``fwd`` identifier. -->
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="portability">
|
||||
<h1><a class="toc-backref" href="#id15">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: 2009-01-30 21:27 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.
|
||||
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -3,7 +3,7 @@
|
||||
<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.6: http://docutils.sourceforge.net/" />
|
||||
<meta name="generator" content="Docutils 0.7: http://docutils.sourceforge.net/" />
|
||||
<title>The Boost Parameter Library Reference Documentation</title>
|
||||
<meta name="authors" content="David Abrahams Daniel Wallin" />
|
||||
<meta name="organization" content="BoostPro Computing" />
|
||||
@@ -53,31 +53,31 @@ or copy at <a class="reference external" href="http://www.boost.org/LICENSE_1_0.
|
||||
</ul>
|
||||
</li>
|
||||
<li><a class="reference internal" href="#class-templates" id="id39">4 Class Templates</a><ul class="auto-toc">
|
||||
<li><a class="reference internal" href="#id7" id="id40">4.1 <tt class="docutils literal"><span class="pre">keyword</span></tt></a></li>
|
||||
<li><a class="reference internal" href="#parameters" id="id41">4.2 <tt class="docutils literal"><span class="pre">parameters</span></tt></a></li>
|
||||
<li><a class="reference internal" href="#optional-required" id="id42">4.3 <tt class="docutils literal"><span class="pre">optional</span></tt>, <tt class="docutils literal"><span class="pre">required</span></tt></a></li>
|
||||
<li><a class="reference internal" href="#deduced" id="id43">4.4 <tt class="docutils literal"><span class="pre">deduced</span></tt></a></li>
|
||||
<li><a class="reference internal" href="#id7" id="id40">4.1 <tt class="docutils literal">keyword</tt></a></li>
|
||||
<li><a class="reference internal" href="#parameters" id="id41">4.2 <tt class="docutils literal">parameters</tt></a></li>
|
||||
<li><a class="reference internal" href="#optional-required" id="id42">4.3 <tt class="docutils literal">optional</tt>, <tt class="docutils literal">required</tt></a></li>
|
||||
<li><a class="reference internal" href="#deduced" id="id43">4.4 <tt class="docutils literal">deduced</tt></a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a class="reference internal" href="#metafunctions" id="id44">5 Metafunctions</a><ul class="auto-toc">
|
||||
<li><a class="reference internal" href="#binding" id="id45">5.1 <tt class="docutils literal"><span class="pre">binding</span></tt></a></li>
|
||||
<li><a class="reference internal" href="#lazy-binding" id="id46">5.2 <tt class="docutils literal"><span class="pre">lazy_binding</span></tt></a></li>
|
||||
<li><a class="reference internal" href="#value-type" id="id47">5.3 <tt class="docutils literal"><span class="pre">value_type</span></tt></a></li>
|
||||
<li><a class="reference internal" href="#binding" id="id45">5.1 <tt class="docutils literal">binding</tt></a></li>
|
||||
<li><a class="reference internal" href="#lazy-binding" id="id46">5.2 <tt class="docutils literal">lazy_binding</tt></a></li>
|
||||
<li><a class="reference internal" href="#value-type" id="id47">5.3 <tt class="docutils literal">value_type</tt></a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a class="reference internal" href="#code-generation-macros" id="id48">6 Code Generation Macros</a><ul class="auto-toc">
|
||||
<li><a class="reference internal" href="#boost-parameter-function-result-name-tag-namespace-arguments" id="id49">6.1 <tt class="docutils literal"><span class="pre">BOOST_PARAMETER_FUNCTION(result,name,tag_namespace,arguments)</span></tt></a></li>
|
||||
<li><a class="reference internal" href="#boost-parameter-member-function-result-name-tag-namespace-arguments" id="id50">6.2 <tt class="docutils literal"><span class="pre">BOOST_PARAMETER_MEMBER_FUNCTION(result,name,tag_namespace,arguments)</span></tt></a></li>
|
||||
<li><a class="reference internal" href="#boost-parameter-constructor-cls-impl-tag-namespace-arguments" id="id51">6.3 <tt class="docutils literal"><span class="pre">BOOST_PARAMETER_CONSTRUCTOR(cls,</span> <span class="pre">impl,</span> <span class="pre">tag_namespace,</span> <span class="pre">arguments)</span></tt></a></li>
|
||||
<li><a class="reference internal" href="#boost-parameter-name-name" id="id52">6.4 <tt class="docutils literal"><span class="pre">BOOST_PARAMETER_NAME(name)</span></tt></a></li>
|
||||
<li><a class="reference internal" href="#boost-parameter-template-keyword-name" id="id53">6.5 <tt class="docutils literal"><span class="pre">BOOST_PARAMETER_TEMPLATE_KEYWORD(name)</span></tt></a></li>
|
||||
<li><a class="reference internal" href="#boost-parameter-fun-r-n-l-h-p" id="id54">6.6 <tt class="docutils literal"><span class="pre">BOOST_PARAMETER_FUN(r,n,l,h,p)</span></tt></a></li>
|
||||
<li><a class="reference internal" href="#boost-parameter-keyword-n-k" id="id55">6.7 <tt class="docutils literal"><span class="pre">BOOST_PARAMETER_KEYWORD(n,k)</span></tt></a></li>
|
||||
<li><a class="reference internal" href="#boost-parameter-match-p-a-x" id="id56">6.8 <tt class="docutils literal"><span class="pre">BOOST_PARAMETER_MATCH(p,a,x)</span></tt></a></li>
|
||||
<li><a class="reference internal" href="#boost-parameter-function-result-name-tag-namespace-arguments" id="id49">6.1 <tt class="docutils literal">BOOST_PARAMETER_FUNCTION(result,name,tag_namespace,arguments)</tt></a></li>
|
||||
<li><a class="reference internal" href="#boost-parameter-member-function-result-name-tag-namespace-arguments" id="id50">6.2 <tt class="docutils literal">BOOST_PARAMETER_MEMBER_FUNCTION(result,name,tag_namespace,arguments)</tt></a></li>
|
||||
<li><a class="reference internal" href="#boost-parameter-constructor-cls-impl-tag-namespace-arguments" id="id51">6.3 <tt class="docutils literal">BOOST_PARAMETER_CONSTRUCTOR(cls, impl, tag_namespace, arguments)</tt></a></li>
|
||||
<li><a class="reference internal" href="#boost-parameter-name-name" id="id52">6.4 <tt class="docutils literal">BOOST_PARAMETER_NAME(name)</tt></a></li>
|
||||
<li><a class="reference internal" href="#boost-parameter-template-keyword-name" id="id53">6.5 <tt class="docutils literal">BOOST_PARAMETER_TEMPLATE_KEYWORD(name)</tt></a></li>
|
||||
<li><a class="reference internal" href="#boost-parameter-fun-r-n-l-h-p" id="id54">6.6 <tt class="docutils literal">BOOST_PARAMETER_FUN(r,n,l,h,p)</tt></a></li>
|
||||
<li><a class="reference internal" href="#boost-parameter-keyword-n-k" id="id55">6.7 <tt class="docutils literal">BOOST_PARAMETER_KEYWORD(n,k)</tt></a></li>
|
||||
<li><a class="reference internal" href="#boost-parameter-match-p-a-x" id="id56">6.8 <tt class="docutils literal">BOOST_PARAMETER_MATCH(p,a,x)</tt></a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a class="reference internal" href="#configuration-macros" id="id57">7 Configuration Macros</a><ul class="auto-toc">
|
||||
<li><a class="reference internal" href="#boost-parameter-max-arity" id="id58">7.1 <tt class="docutils literal"><span class="pre">BOOST_PARAMETER_MAX_ARITY</span></tt></a></li>
|
||||
<li><a class="reference internal" href="#boost-parameter-max-arity" id="id58">7.1 <tt class="docutils literal">BOOST_PARAMETER_MAX_ARITY</tt></a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a class="reference internal" href="#tutorial" id="id59">8 Tutorial</a></li>
|
||||
@@ -113,7 +113,7 @@ follows the code block.</p>
|
||||
<p>In a specification of the tokens generated by a macro, <strong>bold
|
||||
type</strong> is used to highlight the position of the expanded macro
|
||||
argument in the result.</p>
|
||||
<p>The special character β represents the value of <a class="reference internal" href="#boost-parameter-max-arity"><tt class="docutils literal"><span class="pre">BOOST_PARAMETER_MAX_ARITY</span></tt></a>.</p>
|
||||
<p>The special character β represents the value of <a class="reference internal" href="#boost-parameter-max-arity"><tt class="docutils literal">BOOST_PARAMETER_MAX_ARITY</tt></a>.</p>
|
||||
</div>
|
||||
</div>
|
||||
<hr class="docutils" />
|
||||
@@ -140,15 +140,15 @@ parameter list.</dd>
|
||||
</dl>
|
||||
<span class="target" id="keyword-object"></span><dl class="docutils">
|
||||
<dt>keyword object</dt>
|
||||
<dd>An instance of <a class="reference internal" href="#keyword"><tt class="docutils literal"><span class="pre">keyword</span></tt></a> <tt class="docutils literal"><span class="pre"><T></span></tt> for some <a class="reference internal" href="#tag-type">tag type</a> <tt class="docutils literal"><span class="pre">T</span></tt>.</dd>
|
||||
<dd>An instance of <a class="reference internal" href="#keyword"><tt class="docutils literal">keyword</tt></a> <tt class="docutils literal"><T></tt> for some <a class="reference internal" href="#tag-type">tag type</a> <tt class="docutils literal">T</tt>.</dd>
|
||||
</dl>
|
||||
<span class="target" id="tagged-reference"></span><dl class="docutils">
|
||||
<dt>tagged reference</dt>
|
||||
<dd><p class="first">An object whose type is associated with a <a class="reference internal" href="#keyword-tag-type">keyword tag type</a> (the
|
||||
object's <em>keyword</em>), and that holds a reference (to the object's
|
||||
<em>value</em>).</p>
|
||||
<p class="last">As a shorthand, a “tagged reference to <tt class="docutils literal"><span class="pre">x</span></tt>” means a tagged
|
||||
reference whose <em>value</em> is <tt class="docutils literal"><span class="pre">x</span></tt>.</p>
|
||||
<p class="last">As a shorthand, a “tagged reference to <tt class="docutils literal">x</tt>” means a tagged
|
||||
reference whose <em>value</em> is <tt class="docutils literal">x</tt>.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
<span class="target" id="tagged-default"></span><dl class="docutils">
|
||||
@@ -165,7 +165,7 @@ arguments, computes a default argument value.</dd>
|
||||
<dt>intended argument type</dt>
|
||||
<dd>The <em>intended argument type</em> of a single-element <a class="reference internal" href="#argumentpack"><span class="concept">ArgumentPack</span></a> is the
|
||||
type of its element's <em>value</em>. The intended argument type of any other
|
||||
type <tt class="docutils literal"><span class="pre">X</span></tt> is <tt class="docutils literal"><span class="pre">X</span></tt> itself.</dd>
|
||||
type <tt class="docutils literal">X</tt> is <tt class="docutils literal">X</tt> itself.</dd>
|
||||
</dl>
|
||||
<div class="note">
|
||||
<p class="first admonition-title">Note</p>
|
||||
@@ -188,14 +188,14 @@ also a valid MPL <a class="reference external" href="../../../mpl/doc/refmanual/
|
||||
<h3>Requirements</h3>
|
||||
<p>In the table below,</p>
|
||||
<ul class="simple">
|
||||
<li><tt class="docutils literal"><span class="pre">A</span></tt> is a model of <span class="concept">ArgumentPack</span></li>
|
||||
<li><tt class="docutils literal"><span class="pre">x</span></tt> is an instance of <tt class="docutils literal"><span class="pre">A</span></tt></li>
|
||||
<li><tt class="docutils literal"><span class="pre">u</span></tt> is a <a class="reference internal" href="#keyword-object">keyword object</a> of type <tt class="docutils literal"><span class="pre">K</span></tt></li>
|
||||
<li><tt class="docutils literal"><span class="pre">v</span></tt> is a <a class="reference internal" href="#tagged-default">tagged default</a> with <a class="reference internal" href="#tag-type">tag type</a> <tt class="docutils literal"><span class="pre">L</span></tt> and <em>value</em> of type <tt class="docutils literal"><span class="pre">D</span></tt></li>
|
||||
<li><tt class="docutils literal"><span class="pre">w</span></tt> is a <a class="reference internal" href="#tagged-lazy-default">tagged lazy default</a> with <a class="reference internal" href="#tag-type">tag type</a> <tt class="docutils literal"><span class="pre">M</span></tt> and <em>value</em> of type <tt class="docutils literal"><span class="pre">E</span> <span class="pre">const</span></tt></li>
|
||||
<li><tt class="docutils literal"><span class="pre">z</span></tt> is an <span class="concept">ArgumentPack</span> containing a single element (as created by <a class="reference internal" href="#keyword"><tt class="docutils literal"><span class="pre">keyword</span></tt></a><tt class="docutils literal"><span class="pre"><…>::operator=</span></tt>)</li>
|
||||
<li><tt class="docutils literal">A</tt> is a model of <span class="concept">ArgumentPack</span></li>
|
||||
<li><tt class="docutils literal">x</tt> is an instance of <tt class="docutils literal">A</tt></li>
|
||||
<li><tt class="docutils literal">u</tt> is a <a class="reference internal" href="#keyword-object">keyword object</a> of type <tt class="docutils literal">K</tt></li>
|
||||
<li><tt class="docutils literal">v</tt> is a <a class="reference internal" href="#tagged-default">tagged default</a> with <a class="reference internal" href="#tag-type">tag type</a> <tt class="docutils literal">L</tt> and <em>value</em> of type <tt class="docutils literal">D</tt></li>
|
||||
<li><tt class="docutils literal">w</tt> is a <a class="reference internal" href="#tagged-lazy-default">tagged lazy default</a> with <a class="reference internal" href="#tag-type">tag type</a> <tt class="docutils literal">M</tt> and <em>value</em> of type <tt class="docutils literal">E const</tt></li>
|
||||
<li><tt class="docutils literal">z</tt> is an <span class="concept">ArgumentPack</span> containing a single element (as created by <a class="reference internal" href="#keyword"><tt class="docutils literal">keyword</tt></a><tt class="docutils literal"><span class="pre"><…>::operator=</span></tt>)</li>
|
||||
</ul>
|
||||
<p>Any exceptions are thrown from the invocation of <tt class="docutils literal"><span class="pre">w</span></tt>'s <em>value</em>
|
||||
<p>Any exceptions are thrown from the invocation of <tt class="docutils literal">w</tt>'s <em>value</em>
|
||||
will be propagated to the caller.</p>
|
||||
<table border="1" class="docutils">
|
||||
<caption><span class="concept">ArgumentPack</span> requirements</caption>
|
||||
@@ -213,36 +213,36 @@ will be propagated to the caller.</p>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody valign="top">
|
||||
<tr><td><tt class="docutils literal"><span class="pre">x[u]</span></tt></td>
|
||||
<tr><td><tt class="docutils literal">x[u]</tt></td>
|
||||
<td><tt class="docutils literal"><span class="pre">binding<A,K>::type</span></tt></td>
|
||||
<td><tt class="docutils literal"><span class="pre">x</span></tt> contains an
|
||||
<td><tt class="docutils literal">x</tt> contains an
|
||||
element <em>b</em> whose
|
||||
<a class="reference internal" href="#kw">keyword</a> is <tt class="docutils literal"><span class="pre">K</span></tt></td>
|
||||
<a class="reference internal" href="#kw">keyword</a> is <tt class="docutils literal">K</tt></td>
|
||||
<td>Returns <em>b</em>'s <em>value</em> (by
|
||||
reference).</td>
|
||||
</tr>
|
||||
<tr><td><tt class="docutils literal"><span class="pre">x[u]</span></tt></td>
|
||||
<tr><td><tt class="docutils literal">x[u]</tt></td>
|
||||
<td><tt class="docutils literal"><span class="pre">binding<A,L,D>::type</span></tt></td>
|
||||
<td><em>none</em></td>
|
||||
<td>If <tt class="docutils literal"><span class="pre">x</span></tt> contains an element <em>b</em> whose
|
||||
<a class="reference internal" href="#kw">keyword</a> is the same as <tt class="docutils literal"><span class="pre">u</span></tt>'s,
|
||||
<td>If <tt class="docutils literal">x</tt> contains an element <em>b</em> whose
|
||||
<a class="reference internal" href="#kw">keyword</a> is the same as <tt class="docutils literal">u</tt>'s,
|
||||
returns <em>b</em>'s <em>value</em> (by
|
||||
reference). Otherwise, returns <tt class="docutils literal"><span class="pre">u</span></tt>'s <em>value</em>.</td>
|
||||
reference). Otherwise, returns <tt class="docutils literal">u</tt>'s <em>value</em>.</td>
|
||||
</tr>
|
||||
<tr><td><tt class="docutils literal"><span class="pre">x[w]</span></tt></td>
|
||||
<tr><td><tt class="docutils literal">x[w]</tt></td>
|
||||
<td><tt class="docutils literal"><span class="pre">lazy_binding<A,M,E>::type</span></tt></td>
|
||||
<td><em>none</em></td>
|
||||
<td>If <tt class="docutils literal"><span class="pre">x</span></tt> contains an element <em>b</em> whose
|
||||
<a class="reference internal" href="#kw">keyword</a> is the same as <tt class="docutils literal"><span class="pre">w</span></tt>'s,
|
||||
<td>If <tt class="docutils literal">x</tt> contains an element <em>b</em> whose
|
||||
<a class="reference internal" href="#kw">keyword</a> is the same as <tt class="docutils literal">w</tt>'s,
|
||||
returns <em>b</em>'s <em>value</em> (by
|
||||
reference). Otherwise, invokes <tt class="docutils literal"><span class="pre">w</span></tt>'s <em>value</em> and returns the result.</td>
|
||||
reference). Otherwise, invokes <tt class="docutils literal">w</tt>'s <em>value</em> and returns the result.</td>
|
||||
</tr>
|
||||
<tr><td><tt class="docutils literal"><span class="pre">x,</span> <span class="pre">z</span></tt></td>
|
||||
<tr><td><tt class="docutils literal">x, z</tt></td>
|
||||
<td>Model of <span class="concept">ArgumentPack</span></td>
|
||||
<td><em>none</em></td>
|
||||
<td>Returns an <a class="reference internal" href="#argumentpack"><span class="concept">ArgumentPack</span></a> containing
|
||||
all the elements of both <tt class="docutils literal"><span class="pre">x</span></tt> and
|
||||
<tt class="docutils literal"><span class="pre">z</span></tt>.</td>
|
||||
all the elements of both <tt class="docutils literal">x</tt> and
|
||||
<tt class="docutils literal">z</tt>.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -256,9 +256,9 @@ is optional or required. The table below details the allowed forms
|
||||
and describes their condition for satisfaction by an actual
|
||||
argument type. In each row,</p>
|
||||
<ul class="simple" id="conditions">
|
||||
<li><tt class="docutils literal"><span class="pre">K</span></tt> is the <span class="concept">ParameterSpec</span>'s <a class="reference internal" href="#keyword-tag-type">keyword tag type</a></li>
|
||||
<li><tt class="docutils literal"><span class="pre">A</span></tt> is an <a class="reference internal" href="#intended-argument-type">intended argument type</a> associated with <tt class="docutils literal"><span class="pre">K</span></tt>, if any</li>
|
||||
<li><tt class="docutils literal"><span class="pre">F</span></tt> is a unary <a class="reference external" href="../../../mpl/doc/refmanual/lambda-expression.html">MPL lambda expression</a></li>
|
||||
<li><tt class="docutils literal">K</tt> is the <span class="concept">ParameterSpec</span>'s <a class="reference internal" href="#keyword-tag-type">keyword tag type</a></li>
|
||||
<li><tt class="docutils literal">A</tt> is an <a class="reference internal" href="#intended-argument-type">intended argument type</a> associated with <tt class="docutils literal">K</tt>, if any</li>
|
||||
<li><tt class="docutils literal">F</tt> is a unary <a class="reference external" href="../../../mpl/doc/refmanual/lambda-expression.html">MPL lambda expression</a></li>
|
||||
</ul>
|
||||
<table border="1" class="docutils">
|
||||
<caption><span class="concept">ParameterSpec</span> allowed forms and conditions of satisfaction</caption>
|
||||
@@ -269,24 +269,24 @@ argument type. In each row,</p>
|
||||
</colgroup>
|
||||
<thead valign="bottom">
|
||||
<tr><th class="head">Type</th>
|
||||
<th class="head"><tt class="docutils literal"><span class="pre">A</span></tt> required</th>
|
||||
<th class="head">Condition <tt class="docutils literal"><span class="pre">A</span></tt> must satisfy</th>
|
||||
<th class="head"><tt class="docutils literal">A</tt> required</th>
|
||||
<th class="head">Condition <tt class="docutils literal">A</tt> must satisfy</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody valign="top">
|
||||
<tr><td><tt class="docutils literal"><span class="pre">K</span></tt></td>
|
||||
<tr><td><tt class="docutils literal">K</tt></td>
|
||||
<td>no</td>
|
||||
<td><em>n/a</em></td>
|
||||
</tr>
|
||||
<tr><td><a class="reference internal" href="#optional"><tt class="docutils literal"><span class="pre">optional</span></tt></a><tt class="docutils literal"><span class="pre"><K,F></span></tt></td>
|
||||
<tr><td><a class="reference internal" href="#optional"><tt class="docutils literal">optional</tt></a><tt class="docutils literal"><K,F></tt></td>
|
||||
<td>no</td>
|
||||
<td><tt class="docutils literal"><span class="pre">mpl::apply<F,A>::type::value</span></tt>
|
||||
is <tt class="docutils literal"><span class="pre">true</span></tt>.</td>
|
||||
is <tt class="docutils literal">true</tt>.</td>
|
||||
</tr>
|
||||
<tr><td><a class="reference internal" href="#required"><tt class="docutils literal"><span class="pre">required</span></tt></a><tt class="docutils literal"><span class="pre"><K,F></span></tt></td>
|
||||
<tr><td><a class="reference internal" href="#required"><tt class="docutils literal">required</tt></a><tt class="docutils literal"><K,F></tt></td>
|
||||
<td>yes</td>
|
||||
<td><tt class="docutils literal"><span class="pre">mpl::apply<F,A>::type::value</span></tt>
|
||||
is <tt class="docutils literal"><span class="pre">true</span></tt>.</td>
|
||||
is <tt class="docutils literal">true</tt>.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -298,8 +298,8 @@ arguments that will be matched by <a class="reference external" href="index.html
|
||||
<div class="section" id="class-templates">
|
||||
<h1><a class="toc-backref" href="#id39">4 Class Templates</a></h1>
|
||||
<div class="section" id="id7">
|
||||
<span id="keyword"></span><h2><a class="toc-backref" href="#id40">4.1 <tt class="docutils literal"><span class="pre">keyword</span></tt></a></h2>
|
||||
<p>The type of every <a class="reference internal" href="#keyword-object">keyword object</a> is a specialization of <tt class="docutils literal"><span class="pre">keyword</span></tt>.</p>
|
||||
<span id="keyword"></span><h2><a class="toc-backref" href="#id40">4.1 <tt class="docutils literal">keyword</tt></a></h2>
|
||||
<p>The type of every <a class="reference internal" href="#keyword-object">keyword object</a> is a specialization of <tt class="docutils literal">keyword</tt>.</p>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
@@ -324,7 +324,7 @@ struct keyword
|
||||
};
|
||||
</pre>
|
||||
<dl class="docutils" id="operator">
|
||||
<dt><tt class="docutils literal"><span class="pre">operator=</span></tt></dt>
|
||||
<dt><tt class="docutils literal">operator=</tt></dt>
|
||||
<dd><pre class="first literal-block">
|
||||
template <class T> <a class="reference internal" href="#argumentpack"><span class="concept">ArgumentPack</span></a> operator=(T& value) const;
|
||||
template <class T> <a class="reference internal" href="#argumentpack"><span class="concept">ArgumentPack</span></a> operator=(T const& value) const;
|
||||
@@ -336,14 +336,14 @@ template <class T> <a class="reference internal" href="#argumentpack"><spa
|
||||
<tr class="field"><th class="field-name">Requires:</th><td class="field-body">nothing</td>
|
||||
</tr>
|
||||
<tr class="field"><th class="field-name">Returns:</th><td class="field-body">an <a class="reference internal" href="#argumentpack"><span class="concept">ArgumentPack</span></a> containing a single <a class="reference internal" href="#tagged-reference">tagged reference</a> to
|
||||
<tt class="docutils literal"><span class="pre">value</span></tt> with <a class="reference internal" href="#kw">keyword</a> <tt class="docutils literal"><span class="pre">Tag</span></tt></td>
|
||||
<tt class="docutils literal">value</tt> with <a class="reference internal" href="#kw">keyword</a> <tt class="docutils literal">Tag</tt></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class="docutils" id="id9">
|
||||
<dt><tt class="docutils literal"><span class="pre">operator|</span></tt></dt>
|
||||
<dt><tt class="docutils literal">operator|</tt></dt>
|
||||
<dd><pre class="first literal-block">
|
||||
template <class T> <em>tagged default</em> operator|(T& x) const;
|
||||
template <class T> <em>tagged default</em> operator|(T const& x) const;
|
||||
@@ -352,14 +352,14 @@ template <class T> <em>tagged default</em> operator|(T const& x) const
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field"><th class="field-name">Returns:</th><td class="field-body">a <a class="reference internal" href="#tagged-default">tagged default</a> with <em>value</em> <tt class="docutils literal"><span class="pre">x</span></tt> and <a class="reference internal" href="#kw">keyword</a> <tt class="docutils literal"><span class="pre">Tag</span></tt>.</td>
|
||||
<tr class="field"><th class="field-name">Returns:</th><td class="field-body">a <a class="reference internal" href="#tagged-default">tagged default</a> with <em>value</em> <tt class="docutils literal">x</tt> and <a class="reference internal" href="#kw">keyword</a> <tt class="docutils literal">Tag</tt>.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class="docutils" id="id10">
|
||||
<dt><tt class="docutils literal"><span class="pre">operator||</span></tt></dt>
|
||||
<dt><tt class="docutils literal">operator||</tt></dt>
|
||||
<dd><pre class="first literal-block">
|
||||
template <class F> <em>tagged lazy default</em> operator||(F const& g) const;
|
||||
</pre>
|
||||
@@ -367,16 +367,16 @@ template <class F> <em>tagged lazy default</em> operator||(F const& g)
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field"><th class="field-name">Requires:</th><td class="field-body"><tt class="docutils literal"><span class="pre">g()</span></tt> is valid, with type <tt class="docutils literal"><span class="pre">boost::</span></tt><a class="reference external" href="../../../utility/utility.htm#result_of"><tt class="docutils literal"><span class="pre">result_of</span></tt></a><tt class="docutils literal"><span class="pre"><F()>::type</span></tt>.<a class="footnote-reference" href="#no-result-of" id="id11"><sup>2</sup></a></td>
|
||||
<tr class="field"><th class="field-name">Requires:</th><td class="field-body"><tt class="docutils literal">g()</tt> is valid, with type <tt class="docutils literal">boost::</tt><a class="reference external" href="../../../utility/utility.htm#result_of"><tt class="docutils literal">result_of</tt></a><tt class="docutils literal"><span class="pre"><F()>::type</span></tt>.<a class="footnote-reference" href="#no-result-of" id="id11"><sup>2</sup></a></td>
|
||||
</tr>
|
||||
<tr class="field"><th class="field-name">Returns:</th><td class="field-body">a <a class="reference internal" href="#tagged-lazy-default">tagged lazy default</a> with <em>value</em> <tt class="docutils literal"><span class="pre">g</span></tt> and <a class="reference internal" href="#kw">keyword</a> <tt class="docutils literal"><span class="pre">Tag</span></tt>.</td>
|
||||
<tr class="field"><th class="field-name">Returns:</th><td class="field-body">a <a class="reference internal" href="#tagged-lazy-default">tagged lazy default</a> with <em>value</em> <tt class="docutils literal">g</tt> and <a class="reference internal" href="#kw">keyword</a> <tt class="docutils literal">Tag</tt>.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class="docutils" id="get">
|
||||
<dt><tt class="docutils literal"><span class="pre">get</span></tt></dt>
|
||||
<dt><tt class="docutils literal">get</tt></dt>
|
||||
<dd><pre class="first literal-block">
|
||||
static keyword<Tag>& get();
|
||||
</pre>
|
||||
@@ -385,9 +385,9 @@ static keyword<Tag>& get();
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field"><th class="field-name">Returns:</th><td class="field-body">a “singleton instance”: the same object will be
|
||||
returned on each invocation of <tt class="docutils literal"><span class="pre">get()</span></tt>.</td>
|
||||
returned on each invocation of <tt class="docutils literal">get()</tt>.</td>
|
||||
</tr>
|
||||
<tr class="field"><th class="field-name">Thread Safety:</th><td class="field-body"><tt class="docutils literal"><span class="pre">get()</span></tt> can be called from multiple threads
|
||||
<tr class="field"><th class="field-name">Thread Safety:</th><td class="field-body"><tt class="docutils literal">get()</tt> can be called from multiple threads
|
||||
simultaneously.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
@@ -396,11 +396,11 @@ simultaneously.</td>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="section" id="parameters">
|
||||
<h2><a class="toc-backref" href="#id41">4.2 <tt class="docutils literal"><span class="pre">parameters</span></tt></a></h2>
|
||||
<h2><a class="toc-backref" href="#id41">4.2 <tt class="docutils literal">parameters</tt></a></h2>
|
||||
<p>Provides an interface for assembling the actual arguments to a
|
||||
<cite>forwarding function</cite> into an <span class="concept">ArgumentPack</span>, in which any
|
||||
<a class="reference internal" href="#positional">positional</a> arguments will be tagged according to the
|
||||
corresponding template argument to <tt class="docutils literal"><span class="pre">parameters</span></tt>.</p>
|
||||
corresponding template argument to <tt class="docutils literal">parameters</tt>.</p>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
@@ -435,78 +435,78 @@ struct parameters
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field"><th class="field-name">Requires:</th><td class="field-body"><tt class="docutils literal"><span class="pre">P0</span></tt>, <tt class="docutils literal"><span class="pre">P1</span></tt>, … <tt class="docutils literal"><span class="pre">P</span></tt>β are models of <a class="reference internal" href="#parameterspec"><span class="concept">ParameterSpec</span></a>.</td>
|
||||
<tr class="field"><th class="field-name">Requires:</th><td class="field-body"><tt class="docutils literal">P0</tt>, <tt class="docutils literal">P1</tt>, … <tt class="docutils literal">P</tt>β are models of <a class="reference internal" href="#parameterspec"><span class="concept">ParameterSpec</span></a>.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="note">
|
||||
<p class="first admonition-title">Note</p>
|
||||
<p>In this section, <tt class="docutils literal"><span class="pre">R</span></tt><em>i</em> and <tt class="docutils literal"><span class="pre">K</span></tt><em>i</em> are defined as
|
||||
follows, for any argument type <tt class="docutils literal"><span class="pre">A</span></tt><em>i</em>:</p>
|
||||
<p>In this section, <tt class="docutils literal">R</tt><em>i</em> and <tt class="docutils literal">K</tt><em>i</em> are defined as
|
||||
follows, for any argument type <tt class="docutils literal">A</tt><em>i</em>:</p>
|
||||
<blockquote class="last">
|
||||
<div class="line-block">
|
||||
<div class="line">let <tt class="docutils literal"><span class="pre">D0</span></tt> the set [d0, …, d<em>j</em>] of all <strong>deduced</strong> <em>parameter specs</em> in [<tt class="docutils literal"><span class="pre">P0</span></tt>, …, <tt class="docutils literal"><span class="pre">P</span></tt>β]</div>
|
||||
<div class="line"><tt class="docutils literal"><span class="pre">R</span></tt><em>i</em> is <tt class="docutils literal"><span class="pre">A</span></tt><em>i</em>'s <a class="reference internal" href="#intended-argument-type">intended argument type</a></div>
|
||||
<div class="line">let <tt class="docutils literal">D0</tt> the set [d0, …, d<em>j</em>] of all <strong>deduced</strong> <em>parameter specs</em> in [<tt class="docutils literal">P0</tt>, …, <tt class="docutils literal">P</tt>β]</div>
|
||||
<div class="line"><tt class="docutils literal">R</tt><em>i</em> is <tt class="docutils literal">A</tt><em>i</em>'s <a class="reference internal" href="#intended-argument-type">intended argument type</a></div>
|
||||
<div class="line"><br /></div>
|
||||
<div class="line">if <tt class="docutils literal"><span class="pre">A</span></tt><em>i</em> is a result type of <tt class="docutils literal"><span class="pre">keyword<T>::</span></tt><a class="reference internal" href="#operator"><tt class="docutils literal"><span class="pre">operator=</span></tt></a></div>
|
||||
<div class="line">if <tt class="docutils literal">A</tt><em>i</em> is a result type of <tt class="docutils literal"><span class="pre">keyword<T>::</span></tt><a class="reference internal" href="#operator"><tt class="docutils literal">operator=</tt></a></div>
|
||||
<div class="line">then</div>
|
||||
<div class="line-block">
|
||||
<div class="line"><tt class="docutils literal"><span class="pre">K</span></tt><em>i</em> is <tt class="docutils literal"><span class="pre">T</span></tt></div>
|
||||
<div class="line"><tt class="docutils literal">K</tt><em>i</em> is <tt class="docutils literal">T</tt></div>
|
||||
</div>
|
||||
<div class="line">else</div>
|
||||
<div class="line-block">
|
||||
<div class="line">if some <tt class="docutils literal"><span class="pre">A</span></tt><em>j</em> where <em>j</em>≤<em>i</em> is a result type of <tt class="docutils literal"><span class="pre">keyword<T>::</span></tt><a class="reference internal" href="#operator"><tt class="docutils literal"><span class="pre">operator=</span></tt></a></div>
|
||||
<div class="line"><em>or</em> some <tt class="docutils literal"><span class="pre">P</span></tt><em>j</em> in <em>j</em>≤<em>i</em> is <strong>deduced</strong></div>
|
||||
<div class="line">if some <tt class="docutils literal">A</tt><em>j</em> where <em>j</em>≤<em>i</em> is a result type of <tt class="docutils literal"><span class="pre">keyword<T>::</span></tt><a class="reference internal" href="#operator"><tt class="docutils literal">operator=</tt></a></div>
|
||||
<div class="line"><em>or</em> some <tt class="docutils literal">P</tt><em>j</em> in <em>j</em>≤<em>i</em> is <strong>deduced</strong></div>
|
||||
<div class="line">then</div>
|
||||
<div class="line-block">
|
||||
<div class="line">if some <em>parameter spec</em> <tt class="docutils literal"><span class="pre">d</span></tt><em>j</em> in <tt class="docutils literal"><span class="pre">D</span></tt><em>i</em> matches <tt class="docutils literal"><span class="pre">A</span></tt><em>i</em></div>
|
||||
<div class="line">if some <em>parameter spec</em> <tt class="docutils literal">d</tt><em>j</em> in <tt class="docutils literal">D</tt><em>i</em> matches <tt class="docutils literal">A</tt><em>i</em></div>
|
||||
<div class="line">then</div>
|
||||
<div class="line-block">
|
||||
<div class="line"><tt class="docutils literal"><span class="pre">K</span></tt><em>i</em> is <tt class="docutils literal"><span class="pre">d</span></tt><em>j</em>'s <a class="reference internal" href="#keyword-tag-type">keyword tag type</a>.</div>
|
||||
<div class="line"><tt class="docutils literal"><span class="pre">D</span></tt><sub>i+1</sub> is <tt class="docutils literal"><span class="pre">D</span></tt><em>i</em> - [<tt class="docutils literal"><span class="pre">d</span></tt><em>j</em>]</div>
|
||||
<div class="line"><tt class="docutils literal">K</tt><em>i</em> is <tt class="docutils literal">d</tt><em>j</em>'s <a class="reference internal" href="#keyword-tag-type">keyword tag type</a>.</div>
|
||||
<div class="line"><tt class="docutils literal">D</tt><sub>i+1</sub> is <tt class="docutils literal">D</tt><em>i</em> - [<tt class="docutils literal">d</tt><em>j</em>]</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="line">else</div>
|
||||
<div class="line-block">
|
||||
<div class="line"><tt class="docutils literal"><span class="pre">K</span></tt><em>i</em> is <tt class="docutils literal"><span class="pre">P</span></tt><em>i</em>'s <a class="reference internal" href="#keyword-tag-type">keyword tag type</a>.</div>
|
||||
<div class="line"><tt class="docutils literal">K</tt><em>i</em> is <tt class="docutils literal">P</tt><em>i</em>'s <a class="reference internal" href="#keyword-tag-type">keyword tag type</a>.</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</blockquote>
|
||||
</div>
|
||||
<dl class="docutils" id="match">
|
||||
<dt><tt class="docutils literal"><span class="pre">match</span></tt></dt>
|
||||
<dt><tt class="docutils literal">match</tt></dt>
|
||||
<dd><p class="first">A <a class="reference external" href="../../../mpl/doc/refmanual/metafunction.html"><span class="concept">Metafunction</span></a> used to remove a <a class="reference external" href="index.html#forwarding-functions">forwarding function</a> from overload resolution.</p>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field"><th class="field-name">Returns:</th><td class="field-body">if <tt class="docutils literal"><span class="pre">P0</span></tt>, <tt class="docutils literal"><span class="pre">P1</span></tt>, …<tt class="docutils literal"><span class="pre">P</span></tt>β are <em>satisfied</em> (see
|
||||
<tr class="field"><th class="field-name">Returns:</th><td class="field-body">if <tt class="docutils literal">P0</tt>, <tt class="docutils literal">P1</tt>, …<tt class="docutils literal">P</tt>β are <em>satisfied</em> (see
|
||||
below), then <tt class="docutils literal"><span class="pre">parameters<P0,P1,…Pβ></span></tt>. Otherwise,
|
||||
<tt class="docutils literal"><span class="pre">match<A0,A1,…Aβ>::type</span></tt> is not defined.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p><tt class="docutils literal"><span class="pre">P0</span></tt>, <tt class="docutils literal"><span class="pre">P1</span></tt>, …<tt class="docutils literal"><span class="pre">P</span></tt>β are <strong>satisfied</strong> if, for
|
||||
<p><tt class="docutils literal">P0</tt>, <tt class="docutils literal">P1</tt>, …<tt class="docutils literal">P</tt>β are <strong>satisfied</strong> if, for
|
||||
every <em>j</em> in 0…β, either:</p>
|
||||
<ul class="last simple">
|
||||
<li><tt class="docutils literal"><span class="pre">P</span></tt><em>j</em> is the <em>unspecified</em> default</li>
|
||||
<li><strong>or</strong>, <tt class="docutils literal"><span class="pre">P</span></tt><em>j</em> is a <em>keyword tag type</em></li>
|
||||
<li><strong>or</strong>, <tt class="docutils literal"><span class="pre">P</span></tt><em>j</em> is <a class="reference internal" href="#optional"><tt class="docutils literal"><span class="pre">optional</span></tt></a> <tt class="docutils literal"><span class="pre"><X,F></span></tt> and either<ul>
|
||||
<li><tt class="docutils literal"><span class="pre">X</span></tt> is not <tt class="docutils literal"><span class="pre">K</span></tt><em>i</em> for any <em>i</em>,</li>
|
||||
<li><strong>or</strong> <tt class="docutils literal"><span class="pre">X</span></tt> is some <tt class="docutils literal"><span class="pre">K</span></tt><em>i</em> and <tt class="docutils literal"><span class="pre">mpl::apply<F,R</span></tt><em>i</em><tt class="docutils literal"><span class="pre">>::type::value</span></tt> is <tt class="docutils literal"><span class="pre">true</span></tt></li>
|
||||
<li><tt class="docutils literal">P</tt><em>j</em> is the <em>unspecified</em> default</li>
|
||||
<li><strong>or</strong>, <tt class="docutils literal">P</tt><em>j</em> is a <em>keyword tag type</em></li>
|
||||
<li><strong>or</strong>, <tt class="docutils literal">P</tt><em>j</em> is <a class="reference internal" href="#optional"><tt class="docutils literal">optional</tt></a> <tt class="docutils literal"><X,F></tt> and either<ul>
|
||||
<li><tt class="docutils literal">X</tt> is not <tt class="docutils literal">K</tt><em>i</em> for any <em>i</em>,</li>
|
||||
<li><strong>or</strong> <tt class="docutils literal">X</tt> is some <tt class="docutils literal">K</tt><em>i</em> and <tt class="docutils literal"><span class="pre">mpl::apply<F,R</span></tt><em>i</em><tt class="docutils literal"><span class="pre">>::type::value</span></tt> is <tt class="docutils literal">true</tt></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><strong>or</strong>, <tt class="docutils literal"><span class="pre">P</span></tt><em>j</em> is <a class="reference internal" href="#required"><tt class="docutils literal"><span class="pre">required</span></tt></a> <tt class="docutils literal"><span class="pre"><X,F></span></tt>, and<ul>
|
||||
<li><tt class="docutils literal"><span class="pre">X</span></tt> is some <tt class="docutils literal"><span class="pre">K</span></tt><em>i</em>, <strong>and</strong></li>
|
||||
<li><tt class="docutils literal"><span class="pre">mpl::apply<F,R</span></tt><em>i</em><tt class="docutils literal"><span class="pre">>::type::value</span></tt> is <tt class="docutils literal"><span class="pre">true</span></tt></li>
|
||||
<li><strong>or</strong>, <tt class="docutils literal">P</tt><em>j</em> is <a class="reference internal" href="#required"><tt class="docutils literal">required</tt></a> <tt class="docutils literal"><X,F></tt>, and<ul>
|
||||
<li><tt class="docutils literal">X</tt> is some <tt class="docutils literal">K</tt><em>i</em>, <strong>and</strong></li>
|
||||
<li><tt class="docutils literal"><span class="pre">mpl::apply<F,R</span></tt><em>i</em><tt class="docutils literal"><span class="pre">>::type::value</span></tt> is <tt class="docutils literal">true</tt></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class="docutils" id="id13">
|
||||
<dt><tt class="docutils literal"><span class="pre">operator()</span></tt></dt>
|
||||
<dt><tt class="docutils literal">operator()</tt></dt>
|
||||
<dd><pre class="first literal-block">
|
||||
template <class A0> <a class="reference internal" href="#argumentpack"><span class="concept">ArgumentPack</span></a> operator()(A0 const& a0) const;
|
||||
|
||||
@@ -518,10 +518,10 @@ template <class A0, …class Aβ> <a class="reference internal" href="#arg
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">An <a class="reference internal" href="#argumentpack"><span class="concept">ArgumentPack</span></a> containing, for each <tt class="docutils literal"><span class="pre">a</span></tt><em>i</em>,</p>
|
||||
<tr class="field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">An <a class="reference internal" href="#argumentpack"><span class="concept">ArgumentPack</span></a> containing, for each <tt class="docutils literal">a</tt><em>i</em>,</p>
|
||||
<ul class="last simple">
|
||||
<li>if <tt class="docutils literal"><span class="pre">a</span></tt><em>i</em>, is a single-element <span class="concept">ArgumentPack</span>, its element</li>
|
||||
<li>Otherwise, a <a class="reference internal" href="#tagged-reference">tagged reference</a> with <a class="reference internal" href="#kw">keyword</a> <tt class="docutils literal"><span class="pre">K</span></tt><em>i</em> and <em>value</em> <tt class="docutils literal"><span class="pre">a</span></tt><em>i</em></li>
|
||||
<li>if <tt class="docutils literal">a</tt><em>i</em>, is a single-element <span class="concept">ArgumentPack</span>, its element</li>
|
||||
<li>Otherwise, a <a class="reference internal" href="#tagged-reference">tagged reference</a> with <a class="reference internal" href="#kw">keyword</a> <tt class="docutils literal">K</tt><em>i</em> and <em>value</em> <tt class="docutils literal">a</tt><em>i</em></li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -531,7 +531,7 @@ template <class A0, …class Aβ> <a class="reference internal" href="#arg
|
||||
</dl>
|
||||
</div>
|
||||
<div class="section" id="optional-required">
|
||||
<span id="required"></span><span id="optional"></span><h2><a class="toc-backref" href="#id42">4.3 <tt class="docutils literal"><span class="pre">optional</span></tt>, <tt class="docutils literal"><span class="pre">required</span></tt></a></h2>
|
||||
<span id="required"></span><span id="optional"></span><h2><a class="toc-backref" href="#id42">4.3 <tt class="docutils literal">optional</tt>, <tt class="docutils literal">required</tt></a></h2>
|
||||
<p>These templates describe the requirements on a function parameter.</p>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
@@ -557,13 +557,13 @@ struct optional;
|
||||
template <class Tag, class Predicate = <em>unspecified</em>>
|
||||
struct required;
|
||||
</pre>
|
||||
<p>The default value of <tt class="docutils literal"><span class="pre">Predicate</span></tt> is an unspecified <a class="reference external" href="../../../mpl/doc/refmanual/metafunction.html"><span class="concept">Metafunction</span></a> that returns
|
||||
<p>The default value of <tt class="docutils literal">Predicate</tt> is an unspecified <a class="reference external" href="../../../mpl/doc/refmanual/metafunction.html"><span class="concept">Metafunction</span></a> that returns
|
||||
<tt class="docutils literal"><span class="pre">mpl::true_</span></tt> for any argument.</p>
|
||||
</div>
|
||||
<div class="section" id="deduced">
|
||||
<h2><a class="toc-backref" href="#id43">4.4 <tt class="docutils literal"><span class="pre">deduced</span></tt></a></h2>
|
||||
<h2><a class="toc-backref" href="#id43">4.4 <tt class="docutils literal">deduced</tt></a></h2>
|
||||
<p>This template is used to wrap the <em>keyword tag</em> argument to
|
||||
<tt class="docutils literal"><span class="pre">optional</span></tt> or <tt class="docutils literal"><span class="pre">required</span></tt>.</p>
|
||||
<tt class="docutils literal">optional</tt> or <tt class="docutils literal">required</tt>.</p>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
@@ -584,7 +584,7 @@ struct deduced;
|
||||
<p>A <a class="reference external" href="../../../mpl/doc/refmanual/metafunction.html"><span class="concept">Metafunction</span></a> is conceptually a function that operates on, and
|
||||
returns, C++ types.</p>
|
||||
<div class="section" id="binding">
|
||||
<h2><a class="toc-backref" href="#id45">5.1 <tt class="docutils literal"><span class="pre">binding</span></tt></a></h2>
|
||||
<h2><a class="toc-backref" href="#id45">5.1 <tt class="docutils literal">binding</tt></a></h2>
|
||||
<p>Returns the result type of indexing an argument pack with a
|
||||
<a class="reference internal" href="#keyword-tag-type">keyword tag type</a> or with a <a class="reference internal" href="#tagged-default">tagged default</a>.</p>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
@@ -606,16 +606,16 @@ struct binding
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field"><th class="field-name">Requires:</th><td class="field-body"><tt class="docutils literal"><span class="pre">A</span></tt> is a model of <a class="reference internal" href="#argumentpack"><span class="concept">ArgumentPack</span></a>.</td>
|
||||
<tr class="field"><th class="field-name">Requires:</th><td class="field-body"><tt class="docutils literal">A</tt> is a model of <a class="reference internal" href="#argumentpack"><span class="concept">ArgumentPack</span></a>.</td>
|
||||
</tr>
|
||||
<tr class="field"><th class="field-name">Returns:</th><td class="field-body">the reference type of the <a class="reference internal" href="#tagged-reference">tagged reference</a> in <tt class="docutils literal"><span class="pre">A</span></tt>
|
||||
having <a class="reference internal" href="#keyword-tag-type">keyword tag type</a> <tt class="docutils literal"><span class="pre">K</span></tt>, if any. If no such <a class="reference internal" href="#tagged-reference">tagged reference</a> exists, returns <tt class="docutils literal"><span class="pre">D</span></tt>.</td>
|
||||
<tr class="field"><th class="field-name">Returns:</th><td class="field-body">the reference type of the <a class="reference internal" href="#tagged-reference">tagged reference</a> in <tt class="docutils literal">A</tt>
|
||||
having <a class="reference internal" href="#keyword-tag-type">keyword tag type</a> <tt class="docutils literal">K</tt>, if any. If no such <a class="reference internal" href="#tagged-reference">tagged reference</a> exists, returns <tt class="docutils literal">D</tt>.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="section" id="lazy-binding">
|
||||
<h2><a class="toc-backref" href="#id46">5.2 <tt class="docutils literal"><span class="pre">lazy_binding</span></tt></a></h2>
|
||||
<h2><a class="toc-backref" href="#id46">5.2 <tt class="docutils literal">lazy_binding</tt></a></h2>
|
||||
<p>Returns the result type of indexing an argument pack with a <a class="reference internal" href="#tagged-lazy-default">tagged lazy default</a>.</p>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
@@ -636,16 +636,16 @@ struct lazy_binding
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field"><th class="field-name">Requires:</th><td class="field-body"><tt class="docutils literal"><span class="pre">A</span></tt> is a model of <a class="reference internal" href="#argumentpack"><span class="concept">ArgumentPack</span></a>.</td>
|
||||
<tr class="field"><th class="field-name">Requires:</th><td class="field-body"><tt class="docutils literal">A</tt> is a model of <a class="reference internal" href="#argumentpack"><span class="concept">ArgumentPack</span></a>.</td>
|
||||
</tr>
|
||||
<tr class="field"><th class="field-name">Returns:</th><td class="field-body">the reference type of the <a class="reference internal" href="#tagged-reference">tagged reference</a> in <tt class="docutils literal"><span class="pre">A</span></tt>
|
||||
having <a class="reference internal" href="#keyword-tag-type">keyword tag type</a> <tt class="docutils literal"><span class="pre">K</span></tt>, if any. If no such <a class="reference internal" href="#tagged-reference">tagged reference</a> exists, returns <tt class="docutils literal"><span class="pre">boost::</span></tt><a class="reference external" href="../../../utility/utility.htm#result_of"><tt class="docutils literal"><span class="pre">result_of</span></tt></a><tt class="docutils literal"><span class="pre"><F()>::type</span></tt>.<a class="footnote-reference" href="#no-result-of" id="id18"><sup>2</sup></a></td>
|
||||
<tr class="field"><th class="field-name">Returns:</th><td class="field-body">the reference type of the <a class="reference internal" href="#tagged-reference">tagged reference</a> in <tt class="docutils literal">A</tt>
|
||||
having <a class="reference internal" href="#keyword-tag-type">keyword tag type</a> <tt class="docutils literal">K</tt>, if any. If no such <a class="reference internal" href="#tagged-reference">tagged reference</a> exists, returns <tt class="docutils literal">boost::</tt><a class="reference external" href="../../../utility/utility.htm#result_of"><tt class="docutils literal">result_of</tt></a><tt class="docutils literal"><span class="pre"><F()>::type</span></tt>.<a class="footnote-reference" href="#no-result-of" id="id18"><sup>2</sup></a></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="section" id="value-type">
|
||||
<h2><a class="toc-backref" href="#id47">5.3 <tt class="docutils literal"><span class="pre">value_type</span></tt></a></h2>
|
||||
<h2><a class="toc-backref" href="#id47">5.3 <tt class="docutils literal">value_type</tt></a></h2>
|
||||
<p>Returns the result type of indexing an argument pack with a
|
||||
<a class="reference internal" href="#keyword-tag-type">keyword tag type</a> or with a <a class="reference internal" href="#tagged-default">tagged default</a>.</p>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
@@ -667,17 +667,17 @@ struct value_type
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field"><th class="field-name">Requires:</th><td class="field-body"><p class="first"><tt class="docutils literal"><span class="pre">A</span></tt> is a model of <a class="reference internal" href="#argumentpack"><span class="concept">ArgumentPack</span></a>.</p>
|
||||
<tr class="field"><th class="field-name">Requires:</th><td class="field-body"><p class="first"><tt class="docutils literal">A</tt> is a model of <a class="reference internal" href="#argumentpack"><span class="concept">ArgumentPack</span></a>.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">the type of the <a class="reference internal" href="#tagged-reference">tagged reference</a> in <tt class="docutils literal"><span class="pre">A</span></tt>
|
||||
having <a class="reference internal" href="#keyword-tag-type">keyword tag type</a> <tt class="docutils literal"><span class="pre">K</span></tt>, if any. If no such <a class="reference internal" href="#tagged-reference">tagged reference</a> exists, returns <tt class="docutils literal"><span class="pre">D</span></tt>. Equivalent to:</p>
|
||||
<tr class="field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">the type of the <a class="reference internal" href="#tagged-reference">tagged reference</a> in <tt class="docutils literal">A</tt>
|
||||
having <a class="reference internal" href="#keyword-tag-type">keyword tag type</a> <tt class="docutils literal">K</tt>, if any. If no such <a class="reference internal" href="#tagged-reference">tagged reference</a> exists, returns <tt class="docutils literal">D</tt>. Equivalent to:</p>
|
||||
<pre class="literal-block">
|
||||
typename remove_reference<
|
||||
typename binding<A, K, D>::type
|
||||
>::type
|
||||
</pre>
|
||||
<p class="last">… when <tt class="docutils literal"><span class="pre">D</span></tt> is not a reference type.</p>
|
||||
<p class="last">… when <tt class="docutils literal">D</tt> is not a reference type.</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
@@ -690,7 +690,7 @@ typename remove_reference<
|
||||
<p>Macros in this section can be used to ease the writing of code
|
||||
using the Parameter libray by eliminating repetitive boilerplate.</p>
|
||||
<div class="section" id="boost-parameter-function-result-name-tag-namespace-arguments">
|
||||
<h2><a class="toc-backref" href="#id49">6.1 <tt class="docutils literal"><span class="pre">BOOST_PARAMETER_FUNCTION(result,name,tag_namespace,arguments)</span></tt></a></h2>
|
||||
<h2><a class="toc-backref" href="#id49">6.1 <tt class="docutils literal">BOOST_PARAMETER_FUNCTION(result,name,tag_namespace,arguments)</tt></a></h2>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
@@ -703,10 +703,10 @@ using the Parameter libray by eliminating repetitive boilerplate.</p>
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field"><th class="field-name">Requires:</th><td class="field-body"><p class="first"><tt class="docutils literal"><span class="pre">result</span></tt> is the parenthesized return type of the function.
|
||||
<tt class="docutils literal"><span class="pre">name</span></tt> is the base name of the function, this is the name of the
|
||||
generated forwarding functions. <tt class="docutils literal"><span class="pre">tag_namespace</span></tt> is the namespace in
|
||||
which the keywords used by the function resides. <tt class="docutils literal"><span class="pre">arguments</span></tt> is
|
||||
<tr class="field"><th class="field-name">Requires:</th><td class="field-body"><p class="first"><tt class="docutils literal">result</tt> is the parenthesized return type of the function.
|
||||
<tt class="docutils literal">name</tt> is the base name of the function, this is the name of the
|
||||
generated forwarding functions. <tt class="docutils literal">tag_namespace</tt> is the namespace in
|
||||
which the keywords used by the function resides. <tt class="docutils literal">arguments</tt> is
|
||||
a list of <em>argument specifiers</em>, as defined below.</p>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -727,8 +727,8 @@ restriction ::= ('<strong>*</strong>' '<strong>(</strong>' <em>lambda-expression
|
||||
( '<strong>(</strong>' <em>typename</em> '<strong>)</strong>' ) |
|
||||
'<strong>*</strong>'
|
||||
</pre>
|
||||
<p class="last"><tt class="docutils literal"><span class="pre">name</span></tt> is any valid C++ identifier. <tt class="docutils literal"><span class="pre">default-value</span></tt> is any valid
|
||||
C++ expression. <tt class="docutils literal"><span class="pre">typename</span></tt> is the name of a type.
|
||||
<p class="last"><tt class="docutils literal">name</tt> is any valid C++ identifier. <tt class="docutils literal"><span class="pre">default-value</span></tt> is any valid
|
||||
C++ expression. <tt class="docutils literal">typename</tt> is the name of a type.
|
||||
<tt class="docutils literal"><span class="pre">lambda-expression</span></tt> is an <a class="reference external" href="../../../mpl/doc/refmanual/lambda-expression.html">MPL lambda expression</a>.</p>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -740,11 +740,11 @@ C++ expression. <tt class="docutils literal"><span class="pre">typename</span></
|
||||
<tbody valign="top">
|
||||
<tr class="field"><th class="field-name" colspan="2">Generated names in enclosing scope:</th></tr>
|
||||
<tr><td> </td><td class="field-body"><ul class="first last simple">
|
||||
<li><tt class="docutils literal"><span class="pre">boost_param_result_</span> <span class="pre">##</span> <span class="pre">__LINE__</span> <span class="pre">##</span> <span class="pre">name</span></tt></li>
|
||||
<li><tt class="docutils literal"><span class="pre">boost_param_params_</span> <span class="pre">##</span> <span class="pre">__LINE__</span> <span class="pre">##</span> <span class="pre">name</span></tt></li>
|
||||
<li><tt class="docutils literal"><span class="pre">boost_param_parameters_</span> <span class="pre">##</span> <span class="pre">__LINE__</span> <span class="pre">##</span> <span class="pre">name</span></tt></li>
|
||||
<li><tt class="docutils literal"><span class="pre">boost_param_impl</span> <span class="pre">##</span> <span class="pre">name</span></tt></li>
|
||||
<li><tt class="docutils literal"><span class="pre">boost_param_default_</span> <span class="pre">##</span> <span class="pre">__LINE__</span> <span class="pre">##</span> <span class="pre">name</span></tt></li>
|
||||
<li><tt class="docutils literal">boost_param_result_ ## __LINE__ ## name</tt></li>
|
||||
<li><tt class="docutils literal">boost_param_params_ ## __LINE__ ## name</tt></li>
|
||||
<li><tt class="docutils literal">boost_param_parameters_ ## __LINE__ ## name</tt></li>
|
||||
<li><tt class="docutils literal">boost_param_impl ## name</tt></li>
|
||||
<li><tt class="docutils literal">boost_param_default_ ## __LINE__ ## name</tt></li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -754,8 +754,8 @@ C++ expression. <tt class="docutils literal"><span class="pre">typename</span></
|
||||
<dt>Approximate expansion:</dt>
|
||||
<dd><p class="first"><strong>Where</strong>:</p>
|
||||
<ul class="simple">
|
||||
<li><tt class="docutils literal"><span class="pre">n</span></tt> denotes the <em>minimum</em> arity, as determined from <tt class="docutils literal"><span class="pre">arguments</span></tt>.</li>
|
||||
<li><tt class="docutils literal"><span class="pre">m</span></tt> denotes the <em>maximum</em> arity, as determined from <tt class="docutils literal"><span class="pre">arguments</span></tt>.</li>
|
||||
<li><tt class="docutils literal">n</tt> denotes the <em>minimum</em> arity, as determined from <tt class="docutils literal">arguments</tt>.</li>
|
||||
<li><tt class="docutils literal">m</tt> denotes the <em>maximum</em> arity, as determined from <tt class="docutils literal">arguments</tt>.</li>
|
||||
</ul>
|
||||
<pre class="last literal-block">
|
||||
template <class T>
|
||||
@@ -814,7 +814,7 @@ ResultType boost_param_default_ ## __LINE__ ## <strong>name</strong>(
|
||||
</dl>
|
||||
</div>
|
||||
<div class="section" id="boost-parameter-member-function-result-name-tag-namespace-arguments">
|
||||
<h2><a class="toc-backref" href="#id50">6.2 <tt class="docutils literal"><span class="pre">BOOST_PARAMETER_MEMBER_FUNCTION(result,name,tag_namespace,arguments)</span></tt></a></h2>
|
||||
<h2><a class="toc-backref" href="#id50">6.2 <tt class="docutils literal">BOOST_PARAMETER_MEMBER_FUNCTION(result,name,tag_namespace,arguments)</tt></a></h2>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
@@ -823,10 +823,10 @@ ResultType boost_param_default_ ## __LINE__ ## <strong>name</strong>(
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p>See <tt class="docutils literal"><span class="pre">BOOST_PARAMETER_FUNCTION(result,name,tag_namespace,arguments)</span></tt></p>
|
||||
<p>See <tt class="docutils literal">BOOST_PARAMETER_FUNCTION(result,name,tag_namespace,arguments)</tt></p>
|
||||
</div>
|
||||
<div class="section" id="boost-parameter-constructor-cls-impl-tag-namespace-arguments">
|
||||
<h2><a class="toc-backref" href="#id51">6.3 <tt class="docutils literal"><span class="pre">BOOST_PARAMETER_CONSTRUCTOR(cls,</span> <span class="pre">impl,</span> <span class="pre">tag_namespace,</span> <span class="pre">arguments)</span></tt></a></h2>
|
||||
<h2><a class="toc-backref" href="#id51">6.3 <tt class="docutils literal">BOOST_PARAMETER_CONSTRUCTOR(cls, impl, tag_namespace, arguments)</tt></a></h2>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
@@ -839,18 +839,18 @@ ResultType boost_param_default_ ## __LINE__ ## <strong>name</strong>(
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field"><th class="field-name">Requires:</th><td class="field-body"><p class="first"><tt class="docutils literal"><span class="pre">cls</span></tt> is the name of this class. <tt class="docutils literal"><span class="pre">impl</span></tt> is the
|
||||
parenthesized implementation base class for <tt class="docutils literal"><span class="pre">cls</span></tt>.
|
||||
<tt class="docutils literal"><span class="pre">tag_namespace</span></tt> is the namespace in which the keywords
|
||||
used by the function resides. <tt class="docutils literal"><span class="pre">arguments</span></tt> is
|
||||
<tr class="field"><th class="field-name">Requires:</th><td class="field-body"><p class="first"><tt class="docutils literal">cls</tt> is the name of this class. <tt class="docutils literal">impl</tt> is the
|
||||
parenthesized implementation base class for <tt class="docutils literal">cls</tt>.
|
||||
<tt class="docutils literal">tag_namespace</tt> is the namespace in which the keywords
|
||||
used by the function resides. <tt class="docutils literal">arguments</tt> is
|
||||
a list of <em>argument specifiers</em>, as defined in
|
||||
<tt class="docutils literal"><span class="pre">BOOST_PARAMETER_FUNCTION(result,name,tag_namespace,arguments)</span></tt>.</p>
|
||||
<tt class="docutils literal">BOOST_PARAMETER_FUNCTION(result,name,tag_namespace,arguments)</tt>.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="field"><th class="field-name" colspan="2">Generated names in enclosing scope:</th></tr>
|
||||
<tr><td> </td><td class="field-body"><ul class="first last simple">
|
||||
<li><tt class="docutils literal"><span class="pre">boost_param_params_</span> <span class="pre">##</span> <span class="pre">__LINE__</span> <span class="pre">##</span> <span class="pre">ctor</span></tt></li>
|
||||
<li><tt class="docutils literal"><span class="pre">constructor_parameters</span> <span class="pre">##</span> <span class="pre">__LINE__</span></tt></li>
|
||||
<li><tt class="docutils literal">boost_param_params_ ## __LINE__ ## ctor</tt></li>
|
||||
<li><tt class="docutils literal">constructor_parameters ## __LINE__</tt></li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -860,8 +860,8 @@ a list of <em>argument specifiers</em>, as defined in
|
||||
<dt>Approximate expansion:</dt>
|
||||
<dd><p class="first"><strong>Where</strong>:</p>
|
||||
<ul class="simple">
|
||||
<li><tt class="docutils literal"><span class="pre">n</span></tt> denotes the <em>minimum</em> arity, as determined from <tt class="docutils literal"><span class="pre">arguments</span></tt>.</li>
|
||||
<li><tt class="docutils literal"><span class="pre">m</span></tt> denotes the <em>maximum</em> arity, as determined from <tt class="docutils literal"><span class="pre">arguments</span></tt>.</li>
|
||||
<li><tt class="docutils literal">n</tt> denotes the <em>minimum</em> arity, as determined from <tt class="docutils literal">arguments</tt>.</li>
|
||||
<li><tt class="docutils literal">m</tt> denotes the <em>maximum</em> arity, as determined from <tt class="docutils literal">arguments</tt>.</li>
|
||||
</ul>
|
||||
<pre class="last literal-block">
|
||||
struct boost_param_params_ ## __LINE__ ## ctor
|
||||
@@ -889,7 +889,7 @@ template <class A0, …, class A<strong>m</strong>>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="section" id="boost-parameter-name-name">
|
||||
<h2><a class="toc-backref" href="#id52">6.4 <tt class="docutils literal"><span class="pre">BOOST_PARAMETER_NAME(name)</span></tt></a></h2>
|
||||
<h2><a class="toc-backref" href="#id52">6.4 <tt class="docutils literal">BOOST_PARAMETER_NAME(name)</tt></a></h2>
|
||||
<p>Declares a tag-type and keyword object.</p>
|
||||
<p>Expands to:</p>
|
||||
<p><strong>If</strong> <em>name</em> is of the form:</p>
|
||||
@@ -936,7 +936,7 @@ namespace tag
|
||||
</pre>
|
||||
</div>
|
||||
<div class="section" id="boost-parameter-template-keyword-name">
|
||||
<h2><a class="toc-backref" href="#id53">6.5 <tt class="docutils literal"><span class="pre">BOOST_PARAMETER_TEMPLATE_KEYWORD(name)</span></tt></a></h2>
|
||||
<h2><a class="toc-backref" href="#id53">6.5 <tt class="docutils literal">BOOST_PARAMETER_TEMPLATE_KEYWORD(name)</tt></a></h2>
|
||||
<p>Expands to:</p>
|
||||
<pre class="literal-block">
|
||||
namespace tag
|
||||
@@ -951,15 +951,15 @@ struct <em>name</em>
|
||||
</pre>
|
||||
</div>
|
||||
<div class="section" id="boost-parameter-fun-r-n-l-h-p">
|
||||
<h2><a class="toc-backref" href="#id54">6.6 <tt class="docutils literal"><span class="pre">BOOST_PARAMETER_FUN(r,n,l,h,p)</span></tt></a></h2>
|
||||
<h2><a class="toc-backref" href="#id54">6.6 <tt class="docutils literal">BOOST_PARAMETER_FUN(r,n,l,h,p)</tt></a></h2>
|
||||
<div class="admonition-deprecated admonition">
|
||||
<p class="first admonition-title">Deprecated</p>
|
||||
<p class="last">This macro has been deprecated in favor of
|
||||
<tt class="docutils literal"><span class="pre">BOOST_PARAMETER_FUNCTION</span></tt>.</p>
|
||||
<tt class="docutils literal">BOOST_PARAMETER_FUNCTION</tt>.</p>
|
||||
</div>
|
||||
<p>Generates a sequence of <a class="reference external" href="index.html#forwarding-functions">forwarding function</a> templates named
|
||||
<tt class="docutils literal"><span class="pre">n</span></tt>, with arities ranging from <tt class="docutils literal"><span class="pre">l</span></tt> to <tt class="docutils literal"><span class="pre">h</span></tt> , returning <tt class="docutils literal"><span class="pre">r</span></tt>,
|
||||
and using <tt class="docutils literal"><span class="pre">p</span></tt> to control overload resolution and assign tags to
|
||||
<tt class="docutils literal">n</tt>, with arities ranging from <tt class="docutils literal">l</tt> to <tt class="docutils literal">h</tt> , returning <tt class="docutils literal">r</tt>,
|
||||
and using <tt class="docutils literal">p</tt> to control overload resolution and assign tags to
|
||||
positional arguments.</p>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
@@ -973,8 +973,8 @@ positional arguments.</p>
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field"><th class="field-name">Requires:</th><td class="field-body"><tt class="docutils literal"><span class="pre">l</span></tt> and <tt class="docutils literal"><span class="pre">h</span></tt> are nonnegative integer tokens such
|
||||
that <tt class="docutils literal"><span class="pre">l</span></tt> < <tt class="docutils literal"><span class="pre">h</span></tt></td>
|
||||
<tr class="field"><th class="field-name">Requires:</th><td class="field-body"><tt class="docutils literal">l</tt> and <tt class="docutils literal">h</tt> are nonnegative integer tokens such
|
||||
that <tt class="docutils literal">l</tt> < <tt class="docutils literal">h</tt></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -1012,14 +1012,14 @@ r name(
|
||||
</dl>
|
||||
</div>
|
||||
<div class="section" id="boost-parameter-keyword-n-k">
|
||||
<h2><a class="toc-backref" href="#id55">6.7 <tt class="docutils literal"><span class="pre">BOOST_PARAMETER_KEYWORD(n,k)</span></tt></a></h2>
|
||||
<h2><a class="toc-backref" href="#id55">6.7 <tt class="docutils literal">BOOST_PARAMETER_KEYWORD(n,k)</tt></a></h2>
|
||||
<div class="admonition-deprecated admonition">
|
||||
<p class="first admonition-title">Deprecated</p>
|
||||
<p class="last">This macro has been deprecated in favor of
|
||||
<tt class="docutils literal"><span class="pre">BOOST_PARAMETER_NAME</span></tt>.</p>
|
||||
<tt class="docutils literal">BOOST_PARAMETER_NAME</tt>.</p>
|
||||
</div>
|
||||
<p>Generates the declaration of a <a class="reference internal" href="#keyword-tag-type">keyword tag type</a> named <tt class="docutils literal"><span class="pre">k</span></tt> in
|
||||
namespace <tt class="docutils literal"><span class="pre">n</span></tt>, and a corresponding <a class="reference internal" href="#keyword-object">keyword object</a> definition in
|
||||
<p>Generates the declaration of a <a class="reference internal" href="#keyword-tag-type">keyword tag type</a> named <tt class="docutils literal">k</tt> in
|
||||
namespace <tt class="docutils literal">n</tt>, and a corresponding <a class="reference internal" href="#keyword-object">keyword object</a> definition in
|
||||
the enclosing namespace.</p>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
@@ -1042,7 +1042,7 @@ namespace {
|
||||
</dl>
|
||||
</div>
|
||||
<div class="section" id="boost-parameter-match-p-a-x">
|
||||
<h2><a class="toc-backref" href="#id56">6.8 <tt class="docutils literal"><span class="pre">BOOST_PARAMETER_MATCH(p,a,x)</span></tt></a></h2>
|
||||
<h2><a class="toc-backref" href="#id56">6.8 <tt class="docutils literal">BOOST_PARAMETER_MATCH(p,a,x)</tt></a></h2>
|
||||
<p>Generates a defaulted parameter declaration for a <a class="reference external" href="index.html#forwarding-functions">forwarding
|
||||
function</a>.</p>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
@@ -1057,7 +1057,7 @@ function</a>.</p>
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field"><th class="field-name">Requires:</th><td class="field-body"><p class="first"><tt class="docutils literal"><span class="pre">a</span></tt> is a <a class="reference external" href="http://www.boost.org/libs/preprocessor/doc/data.html">Boost.Preprocessor sequence</a>
|
||||
<tr class="field"><th class="field-name">Requires:</th><td class="field-body"><p class="first"><tt class="docutils literal">a</tt> is a <a class="reference external" href="http://www.boost.org/libs/preprocessor/doc/data.html">Boost.Preprocessor sequence</a>
|
||||
of the form</p>
|
||||
<pre class="last literal-block">
|
||||
(A0)(A1)…(A<em>n</em>)
|
||||
@@ -1078,10 +1078,10 @@ typename <strong>p</strong>::match<<strong>A0</strong>,<strong>A1</strong>…
|
||||
<div class="section" id="configuration-macros">
|
||||
<h1><a class="toc-backref" href="#id57">7 Configuration Macros</a></h1>
|
||||
<div class="section" id="boost-parameter-max-arity">
|
||||
<h2><a class="toc-backref" href="#id58">7.1 <tt class="docutils literal"><span class="pre">BOOST_PARAMETER_MAX_ARITY</span></tt></a></h2>
|
||||
<h2><a class="toc-backref" href="#id58">7.1 <tt class="docutils literal">BOOST_PARAMETER_MAX_ARITY</tt></a></h2>
|
||||
<p>Determines the maximum number of arguments supported by the
|
||||
library. Will only be <tt class="docutils literal"><span class="pre">#defined</span></tt> by the library if it is not
|
||||
already <tt class="docutils literal"><span class="pre">#defined</span></tt>.</p>
|
||||
library. Will only be <tt class="docutils literal">#defined</tt> by the library if it is not
|
||||
already <tt class="docutils literal">#defined</tt>.</p>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
@@ -1094,7 +1094,7 @@ already <tt class="docutils literal"><span class="pre">#defined</span></tt>.</p>
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field"><th class="field-name">Default Value:</th><td class="field-body"><tt class="docutils literal"><span class="pre">5</span></tt></td>
|
||||
<tr class="field"><th class="field-name">Default Value:</th><td class="field-body"><tt class="docutils literal">8</tt></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -1119,8 +1119,8 @@ where it could make a difference.</td></tr>
|
||||
<table class="docutils footnote" frame="void" id="no-result-of" rules="none">
|
||||
<colgroup><col class="label" /><col /></colgroup>
|
||||
<tbody valign="top">
|
||||
<tr><td class="label">[2]</td><td><em>(<a class="fn-backref" href="#id11">1</a>, <a class="fn-backref" href="#id18">2</a>)</em> Where <a class="reference external" href="../../../utility/utility.htm#BOOST_NO_RESULT_OF"><tt class="docutils literal"><span class="pre">BOOST_NO_RESULT_OF</span></tt></a> is <tt class="docutils literal"><span class="pre">#defined</span></tt>,
|
||||
<tt class="docutils literal"><span class="pre">boost::</span></tt><a class="reference external" href="../../../utility/utility.htm#result_of"><tt class="docutils literal"><span class="pre">result_of</span></tt></a><tt class="docutils literal"><span class="pre"><F()>::type</span></tt> is replaced by
|
||||
<tr><td class="label">[2]</td><td><em>(<a class="fn-backref" href="#id11">1</a>, <a class="fn-backref" href="#id18">2</a>)</em> Where <a class="reference external" href="../../../utility/utility.htm#BOOST_NO_RESULT_OF"><tt class="docutils literal">BOOST_NO_RESULT_OF</tt></a> is <tt class="docutils literal">#defined</tt>,
|
||||
<tt class="docutils literal">boost::</tt><a class="reference external" href="../../../utility/utility.htm#result_of"><tt class="docutils literal">result_of</tt></a><tt class="docutils literal"><span class="pre"><F()>::type</span></tt> is replaced by
|
||||
<tt class="docutils literal"><span class="pre">F::result_type</span></tt>.</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -1128,7 +1128,7 @@ where it could make a difference.</td></tr>
|
||||
</div>
|
||||
<div class="footer">
|
||||
<hr class="footer" />
|
||||
Generated on: 2009-01-30 21:27 UTC.
|
||||
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.
|
||||
|
||||
</div>
|
||||
|
||||
0
doc/html/rst.css
Executable file → Normal file
0
doc/html/rst.css
Executable file → Normal file
0
doc/html/vellipsis.gif
Executable file → Normal file
0
doc/html/vellipsis.gif
Executable file → Normal file
|
Before Width: | Height: | Size: 62 B After Width: | Height: | Size: 62 B |
119
doc/index.rst
119
doc/index.rst
@@ -30,7 +30,7 @@ __ ../../../../index.htm
|
||||
can be deduced from their types.
|
||||
|
||||
.. @jam_prefix.append('''
|
||||
project test : requirements <include>. <source>/boost//headers ;''')
|
||||
project test : requirements <include>. <implicit-dependency>/boost//headers ;''')
|
||||
|
||||
.. @example.prepend('''
|
||||
#include <boost/parameter.hpp>
|
||||
@@ -783,7 +783,7 @@ signatures.
|
||||
isolate ``depth_first_search`` in a namespace containing no
|
||||
types [#using]_, but suppose we *want* it to found via ADL?
|
||||
|
||||
__ http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/lwg-defects.html#225
|
||||
__ http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#225
|
||||
|
||||
It's usually a good idea to prevent functions from being considered
|
||||
for overload resolution when the passed argument types aren't
|
||||
@@ -856,6 +856,44 @@ 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
|
||||
|
||||
@@ -863,12 +901,10 @@ in parentheses *and preceded by an asterix*, as follows:
|
||||
(graph
|
||||
, **\ \*(boost::mpl::and_<
|
||||
boost::is_convertible<
|
||||
boost::graph_traits<_>::traversal_category
|
||||
, boost::incidence_graph_tag
|
||||
traversal_category<_>, boost::incidence_graph_tag
|
||||
>
|
||||
, boost::is_convertible<
|
||||
boost::graph_traits<_>::traversal_category
|
||||
, boost::vertex_list_graph_tag
|
||||
traversal_category<_>, boost::vertex_list_graph_tag
|
||||
>
|
||||
>)** ))
|
||||
|
||||
@@ -876,25 +912,21 @@ in parentheses *and preceded by an asterix*, as follows:
|
||||
(visitor, \*, boost::dfs_visitor<>()) // not checkable
|
||||
|
||||
(root_vertex
|
||||
, (typename boost::graph_traits<graphs::graph::_>::vertex_descriptor)
|
||||
, (vertex_descriptor<graphs::graph::_>)
|
||||
, \*vertices(graph).first)
|
||||
|
||||
(index_map
|
||||
, **\ \*(boost::mpl::and_<
|
||||
boost::is_integral<
|
||||
boost::property_traits<_>::value_type
|
||||
>
|
||||
boost::is_integral<value_type<_> >
|
||||
, boost::is_same<
|
||||
typename boost::graph_traits<graphs::graph::_>::vertex_descriptor
|
||||
, boost::property_traits<_>::key_type
|
||||
vertex_descriptor<graphs::graph::_>, key_type<_>
|
||||
>
|
||||
>)**
|
||||
, get(boost::vertex_index,graph))
|
||||
|
||||
(in_out(color_map)
|
||||
, **\ \*(boost::is_same<
|
||||
typename boost::graph_traits<graphs::graph::_>::vertex_descriptor
|
||||
, boost::property_traits<_>::key_type
|
||||
vertex_descriptor<graphs::graph::_>, key_type<_>
|
||||
>)**
|
||||
, default_color_map(num_vertices(graph), index_map) )
|
||||
)
|
||||
@@ -902,6 +934,8 @@ 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)
|
||||
@@ -910,38 +944,37 @@ 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.
|
||||
@@ -1767,7 +1800,7 @@ its function call operator:
|
||||
Note that because of the `forwarding problem`_, ``parameter::parameters::operator()``
|
||||
can't accept non-const rvalues.
|
||||
|
||||
.. _`forwarding problem`: http://std.dkuug.dk/jtc1/sc22/wg21/docs/papers/2002/n1385.htm
|
||||
.. _`forwarding problem`: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2002/n1385.htm
|
||||
|
||||
Extracting Parameter Types
|
||||
==========================
|
||||
@@ -2252,7 +2285,7 @@ enclosing namespace without qualification::
|
||||
Follow `this link`__ for documentation on how to expose
|
||||
Boost.Parameter-enabled functions to Python with `Boost.Python`_.
|
||||
|
||||
__ python.html
|
||||
__ ../../../parameter_python/doc/html/index.html
|
||||
|
||||
===========
|
||||
Reference
|
||||
|
||||
778
doc/python.rst
778
doc/python.rst
@@ -1,778 +0,0 @@
|
||||
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
The Boost Parameter Library Python Binding Documentation
|
||||
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
:Authors: David Abrahams, Daniel Wallin
|
||||
:Contact: dave@boost-consulting.com, daniel@boostpro.com
|
||||
:organization: `BoostPro Computing`_
|
||||
:date: $Date$
|
||||
|
||||
:copyright: 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)
|
||||
|
||||
:abstract: Makes it possible to bind Boost.Parameter-enabled
|
||||
functions, operators and constructors to Python.
|
||||
|
||||
|(logo)|__
|
||||
|
||||
.. |(logo)| image:: ../../../../boost.png
|
||||
:alt: Boost
|
||||
|
||||
__ ../../../../index.htm
|
||||
|
||||
.. _`BoostPro Computing`: http://www.boostpro.com
|
||||
|
||||
|
||||
.. role:: class
|
||||
:class: class
|
||||
|
||||
.. role:: concept
|
||||
:class: concept
|
||||
|
||||
.. role:: function
|
||||
:class: function
|
||||
|
||||
.. |ParameterSpec| replace:: :concept:`ParameterSpec`
|
||||
|
||||
.. contents::
|
||||
:depth: 1
|
||||
|
||||
Introduction
|
||||
------------
|
||||
|
||||
``boost/parameter/python.hpp`` introduces a group of |def_visitors|_ that can
|
||||
be used to easily expose Boost.Parameter-enabled member functions to Python with
|
||||
Boost.Python. It also provides a function template ``def()`` that can be used
|
||||
to expose Boost.Parameter-enabled free functions.
|
||||
|
||||
.. |def_visitor| replace:: ``def_visitor``
|
||||
.. |def_visitors| replace:: ``def_visitors``
|
||||
|
||||
.. _def_visitor: def_visitors_
|
||||
.. _def_visitors: ../../../python/doc/v2/def_visitor.html
|
||||
|
||||
When binding a Boost.Parameter enabled function, the keyword tags
|
||||
must be specified. Additionally, because Boost.Parameter enabled
|
||||
functions are templates, the desired function signature must be
|
||||
specified.
|
||||
|
||||
.. The keyword tags are specified as an `MPL Sequence`_, using the
|
||||
pointer qualifications described in |ParameterSpec|_ below. The
|
||||
signature is also specifid as an `MPL sequence`_ of parameter
|
||||
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.
|
||||
|
||||
The keyword tags and associated argument types are specified as an `MPL
|
||||
Sequence`_, using the function type syntax described in |ParameterSpec|_
|
||||
below. 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.
|
||||
|
||||
.. The last two sentences are terribly vague. Which namespace is
|
||||
.. ``function`` in? Isn't the return type always needed? What
|
||||
.. else are we going to do other than pass these sequences to
|
||||
.. function?
|
||||
|
||||
.. _`MPL Sequence`: ../../../mpl/doc/refmanual/sequences.html
|
||||
.. _parameterspec: `concept ParameterSpec`_
|
||||
|
||||
Tutorial
|
||||
--------
|
||||
|
||||
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 macros_ are required to understand this section.
|
||||
|
||||
.. _macros: index.html
|
||||
|
||||
The class and member function we are interested in binding looks
|
||||
like this:
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
#include <boost/parameter/keyword.hpp>
|
||||
#include <boost/parameter/preprocessor.hpp>
|
||||
#include <boost/parameter/python.hpp>
|
||||
#include <boost/python.hpp>
|
||||
|
||||
// First the keywords
|
||||
BOOST_PARAMETER_KEYWORD(tag, title)
|
||||
BOOST_PARAMETER_KEYWORD(tag, width)
|
||||
BOOST_PARAMETER_KEYWORD(tag, height)
|
||||
|
||||
class window
|
||||
{
|
||||
public:
|
||||
BOOST_PARAMETER_MEMBER_FUNCTION(
|
||||
(void), open, tag,
|
||||
(required (title, (std::string)))
|
||||
(optional (width, (unsigned), 400)
|
||||
(height, (unsigned), 400))
|
||||
)
|
||||
{
|
||||
*… function implementation …*
|
||||
}
|
||||
};
|
||||
|
||||
.. @example.prepend('#include <cassert>')
|
||||
.. @example.replace_emphasis('''
|
||||
assert(title == "foo");
|
||||
assert(height == 20);
|
||||
assert(width == 400);
|
||||
''')
|
||||
|
||||
It defines a set of overloaded member functions called ``open`` with one
|
||||
required parameter and two optional ones. To bind this member function to
|
||||
Python we use the binding utility ``boost::parameter::python::function``.
|
||||
``boost::parameter::python::function`` is a |def_visitor|_ that we'll instantiate
|
||||
and pass to ``boost::python::class_::def()``.
|
||||
|
||||
To use ``boost::parameter::python::function`` we first need to define
|
||||
a class with forwarding overloads. This is needed because ``window::open()``
|
||||
is a function template, so we can't refer to it in any other way.
|
||||
|
||||
::
|
||||
|
||||
struct open_fwd
|
||||
{
|
||||
template <class A0, class A1, class A2>
|
||||
void operator()(
|
||||
boost::type<void>, window& self
|
||||
, A0 const& a0, A1 const& a1, A2 const& a2
|
||||
)
|
||||
{
|
||||
self.open(a0, a1, a2);
|
||||
}
|
||||
};
|
||||
|
||||
The first parameter, ``boost::type<void>``, tells the forwarding overload
|
||||
what the return type should be. In this case we know that it's always void
|
||||
but in some cases, when we are exporting several specializations of a
|
||||
Boost.Parameter-enabled template, we need to use that parameter to
|
||||
deduce the return type.
|
||||
|
||||
``window::open()`` takes a total of 3 parameters, so the forwarding function
|
||||
needs to take three parameters as well.
|
||||
|
||||
.. Note::
|
||||
|
||||
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
|
||||
`special keywords`_.
|
||||
|
||||
Next we'll define the module and export the class:
|
||||
|
||||
::
|
||||
|
||||
BOOST_PYTHON_MODULE(my_module)
|
||||
{
|
||||
using namespace boost::python;
|
||||
namespace py = boost::parameter::python;
|
||||
namespace mpl = boost::mpl;
|
||||
|
||||
class_<window>("window")
|
||||
.def(
|
||||
"open", py::function<
|
||||
open_fwd
|
||||
, mpl::vector<
|
||||
void
|
||||
, tag::title(std::string)
|
||||
, tag::width*(unsigned)
|
||||
, tag::height*(unsigned)
|
||||
>
|
||||
>()
|
||||
);
|
||||
}
|
||||
|
||||
.. @jam_prefix.append('import python ;')
|
||||
.. @jam_prefix.append('stage . : my_module /boost/python//boost_python ;')
|
||||
.. @my_module = build(
|
||||
output = 'my_module'
|
||||
, target_rule = 'python-extension'
|
||||
, input = '/boost/python//boost_python'
|
||||
, howmany = 'all'
|
||||
)
|
||||
|
||||
.. @del jam_prefix[:]
|
||||
|
||||
``py::function`` is passed two parameters. The first one is the class with
|
||||
forwarding overloads that we defined earlier. The second one is an `MPL
|
||||
Sequence`_ with the keyword tag types and argument types for the function
|
||||
specified as function types. The pointer syntax used in ``tag::width*`` and
|
||||
``tag::height*`` means that the parameter is optional. The first element of
|
||||
the `MPL Sequence`_ is the return type of the function, in this case ``void``,
|
||||
which is passed as the first argument to ``operator()`` in the forwarding
|
||||
class.
|
||||
|
||||
.. The
|
||||
pointer syntax means that the parameter is optional, so in this case
|
||||
``width`` and ``height`` are optional parameters. The third parameter
|
||||
is an `MPL Sequence`_ with the desired function signature. The return type comes first, and
|
||||
then the parameter types:
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
mpl::vector<void, std::string, unsigned, unsigned>
|
||||
*return type* *title* *width* *height*
|
||||
|
||||
.. @ignore()
|
||||
|
||||
That's it! This class can now be used in Python with the expected syntax::
|
||||
|
||||
>>> w = my_module.window()
|
||||
>>> w.open(title = "foo", height = 20)
|
||||
|
||||
.. @example.prepend('import my_module')
|
||||
.. @run_python(module_path = my_module)
|
||||
|
||||
.. Sorry to say this at such a late date, but this syntax really
|
||||
.. strikes me as cumbersome. Couldn't we do something like:
|
||||
|
||||
class_<window>("window")
|
||||
.def(
|
||||
"open",
|
||||
(void (*)(
|
||||
tag::title(std::string),
|
||||
tag::width*(unsigned),
|
||||
tag::height*(unsigned))
|
||||
)0
|
||||
);
|
||||
|
||||
or at least:
|
||||
|
||||
class_<window>("window")
|
||||
.def(
|
||||
"open",
|
||||
mpl::vector<
|
||||
void,
|
||||
tag::title(std::string),
|
||||
tag::width*(unsigned),
|
||||
tag::height*(unsigned)
|
||||
>()
|
||||
);
|
||||
|
||||
assuming, that is, that we will have to repeat the tags (yes,
|
||||
users of broken compilers will have to give us function pointer
|
||||
types instead).
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
concept |ParameterSpec|
|
||||
-----------------------
|
||||
|
||||
A |ParameterSpec| is a function type ``K(T)`` that describes both the keyword tag,
|
||||
``K``, and the argument type, ``T``, for a parameter.
|
||||
|
||||
``K`` is either:
|
||||
|
||||
* A *required* keyword of the form ``Tag``
|
||||
* **or**, an *optional* keyword of the form ``Tag*``
|
||||
* **or**, a *special* keyword of the form ``Tag**``
|
||||
|
||||
where ``Tag`` is a keyword tag type, as used in a specialization
|
||||
of |keyword|__.
|
||||
|
||||
.. |keyword| replace:: ``boost::parameter::keyword``
|
||||
__ ../../../parameter/doc/html/reference.html#keyword
|
||||
|
||||
The **arity range** for an `MPL Sequence`_ of |ParameterSpec|'s is
|
||||
defined as the closed range:
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
[ mpl::size<S> - number of *special* keyword tags in ``S``, mpl::size<S> ]
|
||||
|
||||
For example, the **arity range** of ``mpl::vector2<x(int),y(int)>`` is ``[2,2]``,
|
||||
the **arity range** of ``mpl::vector2<x(int),y*(int)>`` is ``[2,2]`` and the
|
||||
**arity range** of ``mpl::vector2<x(int),y**(int)>`` is ``[1,2]``.
|
||||
|
||||
|
||||
|
||||
*special* keywords
|
||||
---------------------------------
|
||||
|
||||
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:
|
||||
|
||||
.. An example_ of this is given in the Boost.Parameter
|
||||
docs. The example uses a different technique, but could also have been written like this:
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
namespace core
|
||||
{
|
||||
template <class ArgumentPack>
|
||||
void dfs_dispatch(ArgumentPack const& args, mpl::false\_)
|
||||
{
|
||||
*…compute and use default color map…*
|
||||
}
|
||||
|
||||
template <class ArgumentPack, class ColorMap>
|
||||
void dfs_dispatch(ArgumentPack const& args, ColorMap colormap)
|
||||
{
|
||||
*…use colormap…*
|
||||
}
|
||||
}
|
||||
|
||||
template <class ArgumentPack>
|
||||
void depth_first_search(ArgumentPack const& args)
|
||||
{
|
||||
core::dfs_dispatch(args, args[color | mpl::false_()]);
|
||||
}
|
||||
|
||||
.. @example.prepend('''
|
||||
#include <boost/parameter/keyword.hpp>
|
||||
#include <boost/parameter/parameters.hpp>
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <cassert>
|
||||
|
||||
BOOST_PARAMETER_KEYWORD(tag, color);
|
||||
|
||||
typedef boost::parameter::parameters<tag::color> params;
|
||||
|
||||
namespace mpl = boost::mpl;
|
||||
''')
|
||||
|
||||
.. @example.replace_emphasis('''
|
||||
assert(args[color | 1] == 1);
|
||||
''')
|
||||
|
||||
.. @example.replace_emphasis('''
|
||||
assert(args[color | 1] == 0);
|
||||
''')
|
||||
|
||||
.. @example.append('''
|
||||
int main()
|
||||
{
|
||||
depth_first_search(params()());
|
||||
depth_first_search(params()(color = 0));
|
||||
}''')
|
||||
|
||||
.. @build()
|
||||
|
||||
.. .. _example: index.html#dispatching-based-on-the-presence-of-a-default
|
||||
|
||||
In the above example the type of the default for ``color`` is ``mpl::false_``, a
|
||||
type that is distinct from any color map that the user might supply.
|
||||
|
||||
When binding the case outlined above, the default type for ``color`` will not
|
||||
be convertible to the parameter type. Therefore we need to tag the ``color``
|
||||
keyword as a *special* keyword. This is done by specifying the tag as
|
||||
``tag::color**`` when binding the function (see `concept ParameterSpec`_ for
|
||||
more details on the tagging). By doing this we tell the binding functions that
|
||||
it needs to generate two overloads, one with the ``color`` parameter present
|
||||
and one without. Had there been two *special* keywords, four overloads would
|
||||
need to be generated. The number of generated overloads is equal to 2\
|
||||
:sup:`N`, where ``N`` is the number of *special* keywords.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
class template ``init``
|
||||
-----------------------
|
||||
|
||||
Defines a named parameter enabled constructor.
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
template <class ParameterSpecs>
|
||||
struct init : python::def_visitor<init<ParameterSpecs> >
|
||||
{
|
||||
template <class Class>
|
||||
void def(Class& class\_);
|
||||
|
||||
template <class CallPolicies>
|
||||
*def\_visitor* operator[](CallPolicies const& policies) const;
|
||||
};
|
||||
|
||||
.. @ignore()
|
||||
|
||||
``init`` requirements
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
* ``ParameterSpecs`` is an `MPL sequence`_ where each element is a
|
||||
model of |ParameterSpec|.
|
||||
* For every ``N`` in ``[U,V]``, where ``[U,V]`` is the **arity
|
||||
range** of ``ParameterSpecs``, ``Class`` must support these
|
||||
expressions:
|
||||
|
||||
======================= ============= =========================================
|
||||
Expression Return type Requirements
|
||||
======================= ============= =========================================
|
||||
``Class(a0, …, aN)`` \- ``a0``\ …\ ``aN`` are tagged arguments.
|
||||
======================= ============= =========================================
|
||||
|
||||
|
||||
|
||||
``template <class CallPolicies> operator[](CallPolicies const&)``
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Returns a ``def_visitor`` equivalent to ``*this``, except that it
|
||||
uses CallPolicies when creating the binding.
|
||||
|
||||
|
||||
Example
|
||||
~~~~~~~
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
#include <boost/parameter/keyword.hpp>
|
||||
#include <boost/parameter/preprocessor.hpp>
|
||||
#include <boost/parameter/python.hpp>
|
||||
#include <boost/python.hpp>
|
||||
#include <boost/mpl/vector.hpp>
|
||||
|
||||
BOOST_PARAMETER_KEYWORD(tag, x)
|
||||
BOOST_PARAMETER_KEYWORD(tag, y)
|
||||
|
||||
struct base
|
||||
{
|
||||
template <class ArgumentPack>
|
||||
base(ArgumentPack const& args)
|
||||
{
|
||||
*… use args …*
|
||||
}
|
||||
};
|
||||
|
||||
class X : base
|
||||
{
|
||||
public:
|
||||
BOOST_PARAMETER_CONSTRUCTOR(X, (base), tag,
|
||||
(required (x, \*))
|
||||
(optional (y, \*))
|
||||
)
|
||||
};
|
||||
|
||||
BOOST_PYTHON_MODULE(*module name*)
|
||||
{
|
||||
using namespace boost::python;
|
||||
namespace py = boost::parameter::python;
|
||||
namespace mpl = boost::mpl;
|
||||
|
||||
class_<X>("X", no_init)
|
||||
.def(
|
||||
py::init<
|
||||
mpl::vector<tag::x(int), tag::y\*(int)>
|
||||
>()
|
||||
);
|
||||
}
|
||||
|
||||
.. @example.replace_emphasis('''
|
||||
assert(args[x] == 0);
|
||||
assert(args[y | 1] == 1);
|
||||
''')
|
||||
|
||||
.. @example.replace_emphasis('my_module')
|
||||
|
||||
.. @jam_prefix.append('import python ;')
|
||||
.. @jam_prefix.append('stage . : my_module /boost/python//boost_python ;')
|
||||
.. @my_module = build(
|
||||
output = 'my_module'
|
||||
, target_rule = 'python-extension'
|
||||
, input = '/boost/python//boost_python'
|
||||
)
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
class template ``call``
|
||||
-----------------------
|
||||
|
||||
Defines a ``__call__`` operator, mapped to ``operator()`` in C++.
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
template <class ParameterSpecs>
|
||||
struct call : python::def_visitor<call<ParameterSpecs> >
|
||||
{
|
||||
template <class Class>
|
||||
void def(Class& class\_);
|
||||
|
||||
template <class CallPolicies>
|
||||
*def\_visitor* operator[](CallPolicies const& policies) const;
|
||||
};
|
||||
|
||||
.. @ignore()
|
||||
|
||||
``call`` requirements
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
* ``ParameterSpecs`` is an `MPL sequence`_ where each element
|
||||
except the first models |ParameterSpec|. The first element
|
||||
is the result type of ``c(…)``.
|
||||
* ``Class`` must support these expressions, where ``c`` is an
|
||||
instance of ``Class``:
|
||||
|
||||
=================== ==================== =======================================
|
||||
Expression Return type Requirements
|
||||
=================== ==================== =======================================
|
||||
``c(a0, …, aN)`` Convertible to ``R`` ``a0``\ …\ ``aN`` are tagged arguments.
|
||||
=================== ==================== =======================================
|
||||
|
||||
For every ``N`` in ``[U,V]``, where ``[U,V]`` is the **arity range** of ``ParameterSpecs``.
|
||||
|
||||
|
||||
``template <class CallPolicies> operator[](CallPolicies const&)``
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Returns a ``def_visitor`` equivalent to ``*this``, except that it
|
||||
uses CallPolicies when creating the binding.
|
||||
|
||||
|
||||
Example
|
||||
~~~~~~~
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
#include <boost/parameter/keyword.hpp>
|
||||
#include <boost/parameter/preprocessor.hpp>
|
||||
#include <boost/parameter/python.hpp>
|
||||
#include <boost/python.hpp>
|
||||
#include <boost/mpl/vector.hpp>
|
||||
|
||||
BOOST_PARAMETER_KEYWORD(tag, x)
|
||||
BOOST_PARAMETER_KEYWORD(tag, y)
|
||||
|
||||
namespace parameter = boost::parameter;
|
||||
|
||||
typedef parameter::parameters<
|
||||
parameter::required<tag::x>
|
||||
, parameter::optional<tag::y>
|
||||
> call_parameters;
|
||||
|
||||
class X
|
||||
{
|
||||
public:
|
||||
template <class ArgumentPack>
|
||||
int call_impl(ArgumentPack const& args)
|
||||
{
|
||||
*… use args …*
|
||||
}
|
||||
|
||||
template <class A0>
|
||||
int operator()(A0 const& a0)
|
||||
{
|
||||
return call_impl(call_parameters()(a0));
|
||||
}
|
||||
|
||||
template <class A0, class A1>
|
||||
int operator()(A0 const& a0, A1 const& a1)
|
||||
{
|
||||
return call_impl(call_parameters()(a0,a1));
|
||||
}
|
||||
};
|
||||
|
||||
BOOST_PYTHON_MODULE(*module name*)
|
||||
{
|
||||
using namespace boost::python;
|
||||
namespace py = parameter::python;
|
||||
namespace mpl = boost::mpl;
|
||||
|
||||
class_<X>("X")
|
||||
.def(
|
||||
py::call<
|
||||
mpl::vector<int, tag::x(int), tag::y\*(int)>
|
||||
>()
|
||||
);
|
||||
}
|
||||
|
||||
.. @example.replace_emphasis('''
|
||||
assert(args[x] == 0);
|
||||
assert(args[y | 1] == 1);
|
||||
return 0;
|
||||
''')
|
||||
|
||||
.. @example.replace_emphasis('my_module')
|
||||
|
||||
.. @my_module = build(
|
||||
output = 'my_module'
|
||||
, target_rule = 'python-extension'
|
||||
, input = '/boost/python//boost_python'
|
||||
)
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
class template ``function``
|
||||
---------------------------
|
||||
|
||||
Defines a named parameter enabled member function.
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
template <class Fwd, class ParameterSpecs>
|
||||
struct function : python::def_visitor<function<Fwd, ParameterSpecs> >
|
||||
{
|
||||
template <class Class, class Options>
|
||||
void def(Class& class\_, char const* name, Options const& options);
|
||||
};
|
||||
|
||||
.. @ignore()
|
||||
|
||||
``function`` requirements
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
* ``ParameterSpecs`` is an `MPL sequence`_ where each element
|
||||
except the first models |ParameterSpec|. The first element
|
||||
is the result type of ``c.f(…)``, where ``f`` is the member
|
||||
function.
|
||||
* An instance of ``Fwd`` must support this expression:
|
||||
|
||||
============================================ ==================== =================================================
|
||||
Expression Return type Requirements
|
||||
============================================ ==================== =================================================
|
||||
``fwd(boost::type<R>(), self, a0, …, aN)`` Convertible to ``R`` ``self`` is a reference to the object on which
|
||||
the function should be invoked. ``a0``\ …\ ``aN``
|
||||
are tagged arguments.
|
||||
============================================ ==================== =================================================
|
||||
|
||||
For every ``N`` in ``[U,V]``, where ``[U,V]`` is the **arity range** of ``ParameterSpecs``.
|
||||
|
||||
|
||||
Example
|
||||
~~~~~~~
|
||||
|
||||
This example exports a member function ``f(int x, int y = …)`` to Python. The
|
||||
sequence of |ParameterSpec|'s ``mpl::vector2<tag::x(int), tag::y*(int)>`` has
|
||||
an **arity range** of [2,2], so we only need one forwarding overload.
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
#include <boost/parameter/keyword.hpp>
|
||||
#include <boost/parameter/preprocessor.hpp>
|
||||
#include <boost/parameter/python.hpp>
|
||||
#include <boost/python.hpp>
|
||||
#include <boost/mpl/vector.hpp>
|
||||
|
||||
BOOST_PARAMETER_KEYWORD(tag, x)
|
||||
BOOST_PARAMETER_KEYWORD(tag, y)
|
||||
|
||||
class X
|
||||
{
|
||||
public:
|
||||
BOOST_PARAMETER_MEMBER_FUNCTION((void), f, tag,
|
||||
(required (x, \*))
|
||||
(optional (y, \*, 1))
|
||||
)
|
||||
{
|
||||
*…*
|
||||
}
|
||||
};
|
||||
|
||||
struct f_fwd
|
||||
{
|
||||
template <class A0, class A1>
|
||||
void operator()(boost::type<void>, X& self, A0 const& a0, A1 const& a1)
|
||||
{
|
||||
self.f(a0, a1);
|
||||
}
|
||||
};
|
||||
|
||||
BOOST_PYTHON_MODULE(*module name*)
|
||||
{
|
||||
using namespace boost::python;
|
||||
namespace py = boost::parameter::python;
|
||||
namespace mpl = boost::mpl;
|
||||
|
||||
class_<X>("X")
|
||||
.def("f",
|
||||
py::function<
|
||||
f_fwd
|
||||
, mpl::vector<void, tag::x(int), tag::y\*(int)>
|
||||
>()
|
||||
);
|
||||
}
|
||||
|
||||
.. @example.replace_emphasis('''
|
||||
assert(x == 0);
|
||||
assert(y == 1);
|
||||
''')
|
||||
|
||||
.. @example.replace_emphasis('my_module')
|
||||
|
||||
.. @my_module = build(
|
||||
output = 'my_module'
|
||||
, target_rule = 'python-extension'
|
||||
, input = '/boost/python//boost_python'
|
||||
)
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
function template ``def``
|
||||
-------------------------
|
||||
|
||||
Defines a named parameter enabled free function in the current Python scope.
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
template <class Fwd, class ParameterSpecs>
|
||||
void def(char const* name);
|
||||
|
||||
.. @ignore()
|
||||
|
||||
``def`` requirements
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
* ``ParameterSpecs`` is an `MPL sequence`_ where each element
|
||||
except the first models |ParameterSpec|. The first element
|
||||
is the result type of ``f(…)``, where ``f`` is the function.
|
||||
* An instance of ``Fwd`` must support this expression:
|
||||
|
||||
====================================== ==================== =======================================
|
||||
Expression Return type Requirements
|
||||
====================================== ==================== =======================================
|
||||
``fwd(boost::type<R>(), a0, …, aN)`` Convertible to ``R`` ``a0``\ …\ ``aN`` are tagged arguments.
|
||||
====================================== ==================== =======================================
|
||||
|
||||
For every ``N`` in ``[U,V]``, where ``[U,V]`` is the **arity range** of ``ParameterSpecs``.
|
||||
|
||||
|
||||
Example
|
||||
~~~~~~~
|
||||
|
||||
This example exports a function ``f(int x, int y = …)`` to Python. The
|
||||
sequence of |ParameterSpec|'s ``mpl::vector2<tag::x(int), tag::y*(int)>`` has
|
||||
an **arity range** of [2,2], so we only need one forwarding overload.
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
BOOST_PARAMETER_FUNCTION((void), f, tag,
|
||||
(required (x, \*))
|
||||
(optional (y, \*, 1))
|
||||
)
|
||||
{
|
||||
*…*
|
||||
}
|
||||
|
||||
struct f_fwd
|
||||
{
|
||||
template <class A0, class A1>
|
||||
void operator()(boost::type<void>, A0 const& a0, A1 const& a1)
|
||||
{
|
||||
f(a0, a1);
|
||||
}
|
||||
};
|
||||
|
||||
BOOST_PYTHON_MODULE(…)
|
||||
{
|
||||
def<
|
||||
f_fwd
|
||||
, mpl::vector<
|
||||
void, tag::\ x(int), tag::\ y\*(int)
|
||||
>
|
||||
>("f");
|
||||
}
|
||||
|
||||
.. @ignore()
|
||||
|
||||
.. again, the undefined ``fwd`` identifier.
|
||||
|
||||
Portability
|
||||
-----------
|
||||
|
||||
The Boost.Parameter Python binding library requires *partial template
|
||||
specialization*.
|
||||
|
||||
@@ -970,7 +970,7 @@ already ``#defined``.
|
||||
|
||||
__ ../../../../boost/parameter/config.hpp
|
||||
|
||||
:Default Value: ``5``
|
||||
:Default Value: ``8``
|
||||
|
||||
Tutorial
|
||||
========
|
||||
|
||||
0
include/boost/parameter.hpp
Executable file → Normal file
0
include/boost/parameter.hpp
Executable file → Normal file
@@ -78,15 +78,11 @@ struct empty_arg_list
|
||||
};
|
||||
};
|
||||
|
||||
#if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
|
||||
// Terminator for has_key, indicating that the keyword is unique
|
||||
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))
|
||||
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
|
||||
|
||||
// The overload set technique doesn't work with these older
|
||||
// compilers, so they need some explicit handholding.
|
||||
@@ -150,11 +146,6 @@ struct empty_arg_list
|
||||
typedef arg_list_tag tag; // For dispatching to sequence intrinsics
|
||||
};
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
|
||||
template<class KW>
|
||||
no_tag operator*(empty_arg_list, KW*);
|
||||
#endif
|
||||
|
||||
// Forward declaration for arg_list::operator,
|
||||
template <class KW, class T>
|
||||
struct tagged_argument;
|
||||
@@ -227,25 +218,17 @@ struct arg_list : Next
|
||||
};
|
||||
};
|
||||
|
||||
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && !BOOST_WORKAROUND(__GNUC__, == 2)
|
||||
# if BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
|
||||
friend yes_tag operator*(arg_list, key_type*);
|
||||
# define BOOST_PARAMETER_CALL_HAS_KEY(next, key) (*(next*)0 * (key*)0)
|
||||
# else
|
||||
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
|
||||
// Overload for key_type, so the assert below will fire if the
|
||||
// same keyword is used again
|
||||
static yes_tag has_key(key_type*);
|
||||
using Next::has_key;
|
||||
|
||||
# define BOOST_PARAMETER_CALL_HAS_KEY(next, key) next::has_key((key*)0)
|
||||
# endif
|
||||
|
||||
BOOST_MPL_ASSERT_MSG(
|
||||
sizeof(BOOST_PARAMETER_CALL_HAS_KEY(Next,key_type)) == sizeof(no_tag)
|
||||
sizeof(Next::has_key((key_type*)0)) == sizeof(no_tag)
|
||||
, duplicate_keyword, (key_type)
|
||||
);
|
||||
|
||||
# undef BOOST_PARAMETER_CALL_HAS_KEY
|
||||
#endif
|
||||
//
|
||||
// Begin implementation of indexing operators for looking up
|
||||
@@ -266,9 +249,7 @@ struct arg_list : Next
|
||||
return arg.value ? arg.value.get() : arg.value.construct(d.value);
|
||||
}
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, <= 1300) \
|
||||
|| BOOST_WORKAROUND(__GNUC__, < 3) \
|
||||
|| BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
|
||||
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
|
||||
// These older compilers don't support the overload set creation
|
||||
// idiom well, so we need to do all the return type calculation
|
||||
// for the compiler and dispatch through an outer function template
|
||||
@@ -358,6 +339,7 @@ struct arg_list : Next
|
||||
template <class Default>
|
||||
reference operator[](lazy_default<key_type, Default>) const
|
||||
{
|
||||
BOOST_MPL_ASSERT_NOT((holds_maybe));
|
||||
return arg.value;
|
||||
}
|
||||
|
||||
@@ -407,10 +389,6 @@ struct arg_list : Next
|
||||
typedef arg_list_tag tag; // For dispatching to sequence intrinsics
|
||||
};
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, <= 1300) // ETI workaround
|
||||
template <> struct arg_list<int,int> {};
|
||||
#endif
|
||||
|
||||
// MPL sequence support
|
||||
template <class ArgumentPack>
|
||||
struct arg_list_iterator
|
||||
|
||||
50
include/boost/parameter/aux_/cast.hpp
Executable file → Normal file
50
include/boost/parameter/aux_/cast.hpp
Executable file → Normal file
@@ -7,8 +7,7 @@
|
||||
|
||||
# include <boost/detail/workaround.hpp>
|
||||
|
||||
# if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) \
|
||||
&& !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
|
||||
# if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
|
||||
# include <boost/type_traits/add_reference.hpp>
|
||||
# include <boost/type_traits/remove_const.hpp>
|
||||
# endif
|
||||
@@ -17,8 +16,7 @@ namespace boost { namespace parameter { namespace aux {
|
||||
|
||||
struct use_default_tag {};
|
||||
|
||||
# if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) \
|
||||
|| BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
|
||||
# if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
|
||||
|
||||
# define BOOST_PARAMETER_FUNCTION_CAST(value, predicate) value
|
||||
|
||||
@@ -40,11 +38,11 @@ struct use_default_tag {};
|
||||
// X(something, *(predicate))
|
||||
// X(something, (int))
|
||||
|
||||
template <class T>
|
||||
template <class T, class Args>
|
||||
struct cast;
|
||||
|
||||
template <>
|
||||
struct cast<void*>
|
||||
template <class Args>
|
||||
struct cast<void*, Args>
|
||||
{
|
||||
static use_default_tag execute(use_default_tag)
|
||||
{
|
||||
@@ -73,27 +71,39 @@ struct cast<void*>
|
||||
|
||||
typedef void* voidstar;
|
||||
|
||||
template <class T>
|
||||
struct cast<voidstar(T)>
|
||||
: cast<void*>
|
||||
template <class T, class Args>
|
||||
struct cast<voidstar(T), Args>
|
||||
: cast<void*, Args>
|
||||
{
|
||||
};
|
||||
|
||||
#else
|
||||
|
||||
template <class T>
|
||||
struct cast<void*(T)>
|
||||
: cast<void*>
|
||||
template <class T, class Args>
|
||||
struct cast<void*(T), Args>
|
||||
: cast<void*, Args>
|
||||
{
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
template <class T>
|
||||
struct cast<void(T)>
|
||||
// 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
|
||||
{
|
||||
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<T>::type
|
||||
typename boost::remove_const<type0>::type
|
||||
>::type reference;
|
||||
|
||||
static use_default_tag execute(use_default_tag)
|
||||
@@ -106,7 +116,7 @@ struct cast<void(T)>
|
||||
return use_default_tag();
|
||||
}
|
||||
|
||||
static T execute(T value)
|
||||
static type0 execute(type0 value)
|
||||
{
|
||||
return value;
|
||||
}
|
||||
@@ -118,9 +128,9 @@ struct cast<void(T)>
|
||||
}
|
||||
};
|
||||
|
||||
# define BOOST_PARAMETER_FUNCTION_CAST(value, predicate) \
|
||||
boost::parameter::aux::cast<void predicate>::remove_const( \
|
||||
boost::parameter::aux::cast<void predicate>::execute(value) \
|
||||
# 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) \
|
||||
)
|
||||
|
||||
# endif
|
||||
|
||||
0
include/boost/parameter/aux_/default.hpp
Executable file → Normal file
0
include/boost/parameter/aux_/default.hpp
Executable file → Normal file
0
include/boost/parameter/aux_/overloads.hpp
Executable file → Normal file
0
include/boost/parameter/aux_/overloads.hpp
Executable file → Normal file
0
include/boost/parameter/aux_/parameter_requirements.hpp
Executable file → Normal file
0
include/boost/parameter/aux_/parameter_requirements.hpp
Executable file → Normal file
84
include/boost/parameter/aux_/parenthesized_type.hpp
Executable file → Normal file
84
include/boost/parameter/aux_/parenthesized_type.hpp
Executable file → Normal file
@@ -18,96 +18,12 @@ namespace boost { namespace parameter { namespace aux {
|
||||
template <class UnaryFunctionPointer>
|
||||
struct unaryfunptr_arg_type;
|
||||
|
||||
# if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
|
||||
|
||||
template <class Arg>
|
||||
struct unaryfunptr_arg_type<void(*)(Arg)>
|
||||
{
|
||||
typedef Arg type;
|
||||
};
|
||||
|
||||
# else
|
||||
|
||||
// Use the "native typeof" bugfeatures of older versions of MSVC to
|
||||
// accomplish what we'd normally do with partial specialization. This
|
||||
// capability was discovered by Igor Chesnokov.
|
||||
|
||||
# if BOOST_WORKAROUND(BOOST_MSVC, != 1300)
|
||||
|
||||
// This version applies to VC6.5 and VC7.1 (except that we can just
|
||||
// use partial specialization for the latter in this case).
|
||||
|
||||
// This gets used as a base class.
|
||||
template<typename Address>
|
||||
struct msvc_type_memory
|
||||
{
|
||||
// A nullary metafunction that will yield the Value type "stored"
|
||||
// at this Address.
|
||||
struct storage;
|
||||
};
|
||||
|
||||
template<typename Value, typename Address>
|
||||
struct msvc_store_type : msvc_type_memory<Address>
|
||||
{
|
||||
// VC++ somehow lets us define the base's nested storage
|
||||
// metafunction here, where we have the Value type we'd like to
|
||||
// "store" in it. Later we can come back to the base class and
|
||||
// extract the "stored type."
|
||||
typedef msvc_type_memory<Address> location;
|
||||
struct location::storage
|
||||
{
|
||||
typedef Value type;
|
||||
};
|
||||
};
|
||||
|
||||
# else
|
||||
|
||||
// This slightly more complicated version of the same thing is
|
||||
// required for msvc-7.0
|
||||
template<typename Address>
|
||||
struct msvc_type_memory
|
||||
{
|
||||
template<bool>
|
||||
struct storage_impl;
|
||||
|
||||
typedef storage_impl<true> storage;
|
||||
};
|
||||
|
||||
template<typename Value, typename Address>
|
||||
struct msvc_store_type : msvc_type_memory<Address>
|
||||
{
|
||||
// Rather than supplying a definition for the base class' nested
|
||||
// class, we specialize the base class' nested template
|
||||
template<>
|
||||
struct storage_impl<true>
|
||||
{
|
||||
typedef Value type;
|
||||
};
|
||||
};
|
||||
|
||||
# endif
|
||||
|
||||
// Function template argument deduction does many of the same things
|
||||
// as type matching during partial specialization, so we call a
|
||||
// function template to "store" T into the type memory addressed by
|
||||
// void(*)(T).
|
||||
template <class T>
|
||||
msvc_store_type<T,void(*)(T)>
|
||||
msvc_store_argument_type(void(*)(T));
|
||||
|
||||
template <class FunctionPointer>
|
||||
struct unaryfunptr_arg_type
|
||||
{
|
||||
// We don't want the function to be evaluated, just instantiated,
|
||||
// so protect it inside of sizeof.
|
||||
enum { dummy = sizeof(msvc_store_argument_type((FunctionPointer)0)) };
|
||||
|
||||
// Now pull the type out of the instantiated base class
|
||||
typedef typename msvc_type_memory<FunctionPointer>::storage::type type;
|
||||
};
|
||||
|
||||
# endif
|
||||
|
||||
template <>
|
||||
struct unaryfunptr_arg_type<void(*)(void)>
|
||||
{
|
||||
|
||||
0
include/boost/parameter/aux_/preprocessor/flatten.hpp
Executable file → Normal file
0
include/boost/parameter/aux_/preprocessor/flatten.hpp
Executable file → Normal file
0
include/boost/parameter/aux_/preprocessor/for_each.hpp
Executable file → Normal file
0
include/boost/parameter/aux_/preprocessor/for_each.hpp
Executable file → Normal file
@@ -1,132 +0,0 @@
|
||||
// Copyright Daniel Wallin 2005. Use, modification and distribution is
|
||||
// subject to the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifndef BOOST_PARAMETER_INVOKER_051210_HPP
|
||||
# define BOOST_PARAMETER_INVOKER_051210_HPP
|
||||
|
||||
# include <boost/mpl/begin.hpp>
|
||||
# include <boost/mpl/next.hpp>
|
||||
# include <boost/mpl/deref.hpp>
|
||||
# include <boost/mpl/size.hpp>
|
||||
# include <boost/parameter/keyword.hpp>
|
||||
# include <boost/preprocessor/iteration/iterate.hpp>
|
||||
|
||||
namespace boost { namespace parameter { namespace python { namespace aux {
|
||||
|
||||
template <long Arity, class M, class R, class Args>
|
||||
struct invoker;
|
||||
|
||||
template <class M, class R>
|
||||
struct make_invoker
|
||||
{
|
||||
template <class Args>
|
||||
struct apply
|
||||
{
|
||||
typedef invoker<
|
||||
mpl::size<Args>::value, M, R, Args
|
||||
> type;
|
||||
};
|
||||
};
|
||||
|
||||
template <long Arity, class M, class R, class T, class Args>
|
||||
struct member_invoker;
|
||||
|
||||
template <class M, class R, class T>
|
||||
struct make_member_invoker
|
||||
{
|
||||
template <class Args>
|
||||
struct apply
|
||||
{
|
||||
typedef member_invoker<
|
||||
mpl::size<Args>::value, M, R, T, Args
|
||||
> type;
|
||||
};
|
||||
};
|
||||
|
||||
template <long Arity, class T, class R, class Args>
|
||||
struct call_invoker;
|
||||
|
||||
template <class T, class R>
|
||||
struct make_call_invoker
|
||||
{
|
||||
template <class Args>
|
||||
struct apply
|
||||
{
|
||||
typedef call_invoker<
|
||||
mpl::size<Args>::value, T, R, Args
|
||||
> type;
|
||||
};
|
||||
};
|
||||
|
||||
template <long Arity, class T, class Args>
|
||||
struct init_invoker;
|
||||
|
||||
template <class T>
|
||||
struct make_init_invoker
|
||||
{
|
||||
template <class Args>
|
||||
struct apply
|
||||
{
|
||||
typedef init_invoker<
|
||||
mpl::size<Args>::value, T, Args
|
||||
> type;
|
||||
};
|
||||
};
|
||||
|
||||
template <class M, class R, class Args>
|
||||
struct invoker<0, M, R, Args>
|
||||
{
|
||||
static R execute()
|
||||
{
|
||||
return M()(boost::type<R>());
|
||||
}
|
||||
};
|
||||
|
||||
template <class M, class R, class T, class Args>
|
||||
struct member_invoker<0, M, R, T, Args>
|
||||
{
|
||||
static R execute(T& self)
|
||||
{
|
||||
return M()(boost::type<R>(), self);
|
||||
}
|
||||
};
|
||||
|
||||
template <class T, class R, class Args>
|
||||
struct call_invoker<0, T, R, Args>
|
||||
{
|
||||
static R execute(T& self)
|
||||
{
|
||||
return self();
|
||||
}
|
||||
};
|
||||
|
||||
template <class T, class Args>
|
||||
struct init_invoker<0, T, Args>
|
||||
{
|
||||
static T* execute(T& self)
|
||||
{
|
||||
return new T;
|
||||
}
|
||||
};
|
||||
|
||||
# define BOOST_PP_ITERATION_PARAMS_1 (4, \
|
||||
(1, BOOST_PARAMETER_MAX_ARITY, <boost/parameter/aux_/python/invoker_iterate.hpp>, 1))
|
||||
# include BOOST_PP_ITERATE()
|
||||
|
||||
# define BOOST_PP_ITERATION_PARAMS_1 (4, \
|
||||
(1, BOOST_PARAMETER_MAX_ARITY, <boost/parameter/aux_/python/invoker_iterate.hpp>, 2))
|
||||
# include BOOST_PP_ITERATE()
|
||||
|
||||
# define BOOST_PP_ITERATION_PARAMS_1 (4, \
|
||||
(1, BOOST_PARAMETER_MAX_ARITY, <boost/parameter/aux_/python/invoker_iterate.hpp>, 3))
|
||||
# include BOOST_PP_ITERATE()
|
||||
|
||||
# define BOOST_PP_ITERATION_PARAMS_1 (4, \
|
||||
(1, BOOST_PARAMETER_MAX_ARITY, <boost/parameter/aux_/python/invoker_iterate.hpp>, 4))
|
||||
# include BOOST_PP_ITERATE()
|
||||
|
||||
}}}} // namespace boost::parameter::python::aux
|
||||
|
||||
#endif // BOOST_PARAMETER_INVOKER_051210_HPP
|
||||
|
||||
@@ -1,93 +0,0 @@
|
||||
// Copyright Daniel Wallin 2005. Use, modification and distribution is
|
||||
// subject to the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <boost/preprocessor/cat.hpp>
|
||||
#include <boost/preprocessor/dec.hpp>
|
||||
#include <boost/preprocessor/repetition/enum_binary_params.hpp>
|
||||
#include <boost/preprocessor/repetition/repeat_from_to.hpp>
|
||||
|
||||
#define N BOOST_PP_ITERATION()
|
||||
|
||||
#define BOOST_PARAMETER_PY_ARG_TYPES(z, n, _) \
|
||||
typedef typename mpl::next< \
|
||||
BOOST_PP_CAT(iter,BOOST_PP_DEC(n)) \
|
||||
>::type BOOST_PP_CAT(iter,n); \
|
||||
\
|
||||
typedef typename mpl::deref<BOOST_PP_CAT(iter,n)>::type BOOST_PP_CAT(spec,n); \
|
||||
typedef typename mpl::if_< \
|
||||
mpl::and_< \
|
||||
mpl::not_<typename BOOST_PP_CAT(spec,n)::required> \
|
||||
, typename BOOST_PP_CAT(spec,n)::optimized_default \
|
||||
> \
|
||||
, parameter::aux::maybe<typename BOOST_PP_CAT(spec,n)::type> \
|
||||
, typename BOOST_PP_CAT(spec,n)::type \
|
||||
>::type BOOST_PP_CAT(arg,n); \
|
||||
typedef typename BOOST_PP_CAT(spec,n)::keyword BOOST_PP_CAT(kw,n);
|
||||
|
||||
#if BOOST_PP_ITERATION_FLAGS() == 1
|
||||
template <class M, class R, class Args>
|
||||
struct invoker<N, M, R, Args>
|
||||
#elif BOOST_PP_ITERATION_FLAGS() == 2
|
||||
template <class T, class R, class Args>
|
||||
struct call_invoker<N, T, R, Args>
|
||||
#elif BOOST_PP_ITERATION_FLAGS() == 3
|
||||
template <class T, class Args>
|
||||
struct init_invoker<N, T, Args>
|
||||
#elif BOOST_PP_ITERATION_FLAGS() == 4
|
||||
template <class M, class R, class T, class Args>
|
||||
struct member_invoker<N, M, R, T, Args>
|
||||
#endif
|
||||
{
|
||||
typedef typename mpl::begin<Args>::type iter0;
|
||||
typedef typename mpl::deref<iter0>::type spec0;
|
||||
typedef typename mpl::if_<
|
||||
mpl::and_<
|
||||
mpl::not_<typename spec0::required>
|
||||
, typename spec0::optimized_default
|
||||
>
|
||||
, parameter::aux::maybe<typename spec0::type>
|
||||
, typename spec0::type
|
||||
>::type arg0;
|
||||
typedef typename spec0::keyword kw0;
|
||||
|
||||
BOOST_PP_REPEAT_FROM_TO(1, N, BOOST_PARAMETER_PY_ARG_TYPES, ~)
|
||||
|
||||
static
|
||||
#if BOOST_PP_ITERATION_FLAGS() == 3
|
||||
T*
|
||||
#else
|
||||
R
|
||||
#endif
|
||||
execute(
|
||||
#if BOOST_PP_ITERATION_FLAGS() == 2 || BOOST_PP_ITERATION_FLAGS() == 4
|
||||
T& self
|
||||
,
|
||||
#endif
|
||||
BOOST_PP_ENUM_BINARY_PARAMS(N, arg, a)
|
||||
)
|
||||
{
|
||||
return
|
||||
#if BOOST_PP_ITERATION_FLAGS() == 1 || BOOST_PP_ITERATION_FLAGS() == 4
|
||||
M()(
|
||||
boost::type<R>()
|
||||
# if BOOST_PP_ITERATION_FLAGS() == 4
|
||||
, self
|
||||
# endif
|
||||
, BOOST_PP_ENUM_BINARY_PARAMS(N, parameter::keyword<kw, >::get() = a)
|
||||
);
|
||||
#elif BOOST_PP_ITERATION_FLAGS() == 2
|
||||
self(
|
||||
BOOST_PP_ENUM_BINARY_PARAMS(N, parameter::keyword<kw, >::get() = a)
|
||||
);
|
||||
#elif BOOST_PP_ITERATION_FLAGS() == 3
|
||||
new T(
|
||||
BOOST_PP_ENUM_BINARY_PARAMS(N, parameter::keyword<kw, >::get() = a)
|
||||
);
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
#undef BOOST_PARAMETER_PY_ARG_TYPES
|
||||
#undef N
|
||||
|
||||
0
include/boost/parameter/aux_/result_of0.hpp
Executable file → Normal file
0
include/boost/parameter/aux_/result_of0.hpp
Executable file → Normal file
3
include/boost/parameter/aux_/set.hpp
Executable file → Normal file
3
include/boost/parameter/aux_/set.hpp
Executable file → Normal file
@@ -7,8 +7,7 @@
|
||||
|
||||
# include <boost/detail/workaround.hpp>
|
||||
|
||||
# if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) \
|
||||
&& !BOOST_WORKAROUND(__GNUC__, < 3)
|
||||
# if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
|
||||
# include <boost/mpl/insert.hpp>
|
||||
# include <boost/mpl/set/set0.hpp>
|
||||
# include <boost/mpl/has_key.hpp>
|
||||
|
||||
0
include/boost/parameter/aux_/tag.hpp
Executable file → Normal file
0
include/boost/parameter/aux_/tag.hpp
Executable file → Normal file
@@ -120,13 +120,13 @@ struct tagged_argument : tagged_argument_base
|
||||
}
|
||||
# else
|
||||
template <class Default>
|
||||
reference operator[](default_<key_type,Default> const& x) const
|
||||
reference operator[](default_<key_type,Default> const& ) const
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
template <class F>
|
||||
reference operator[](lazy_default<key_type,F> const& x) const
|
||||
reference operator[](lazy_default<key_type,F> const& ) const
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
0
include/boost/parameter/aux_/template_keyword.hpp
Executable file → Normal file
0
include/boost/parameter/aux_/template_keyword.hpp
Executable file → Normal file
6
include/boost/parameter/aux_/unwrap_cv_reference.hpp
Executable file → Normal file
6
include/boost/parameter/aux_/unwrap_cv_reference.hpp
Executable file → Normal file
@@ -44,12 +44,6 @@ struct is_cv_reference_wrapper
|
||||
value> type;
|
||||
};
|
||||
|
||||
#if BOOST_WORKAROUND(MSVC, == 1200)
|
||||
template <>
|
||||
struct is_cv_reference_wrapper<int>
|
||||
: mpl::false_ {};
|
||||
#endif
|
||||
|
||||
// Needed for unwrap_cv_reference below. T might be const, so
|
||||
// eval_if might fail because of deriving from T const on EDG.
|
||||
template <class T>
|
||||
|
||||
0
include/boost/parameter/aux_/void.hpp
Executable file → Normal file
0
include/boost/parameter/aux_/void.hpp
Executable file → Normal file
0
include/boost/parameter/aux_/yesno.hpp
Executable file → Normal file
0
include/boost/parameter/aux_/yesno.hpp
Executable file → Normal file
30
include/boost/parameter/binding.hpp
Executable file → Normal file
30
include/boost/parameter/binding.hpp
Executable file → Normal file
@@ -11,18 +11,13 @@
|
||||
# include <boost/parameter/aux_/void.hpp>
|
||||
# include <boost/type_traits/is_same.hpp>
|
||||
|
||||
# if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
||||
# include <boost/mpl/eval_if.hpp>
|
||||
# endif
|
||||
|
||||
namespace boost { namespace parameter {
|
||||
|
||||
// A metafunction that, given an argument pack, returns the type of
|
||||
// the parameter identified by the given keyword. If no such
|
||||
// parameter has been specified, returns Default
|
||||
|
||||
# if BOOST_WORKAROUND(BOOST_MSVC, <= 1300) \
|
||||
|| BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
|
||||
# if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
|
||||
template <class Parameters, class Keyword, class Default>
|
||||
struct binding0
|
||||
{
|
||||
@@ -40,14 +35,9 @@ struct binding0
|
||||
# endif
|
||||
|
||||
template <class Parameters, class Keyword, class Default = void_>
|
||||
# if !BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
||||
struct binding
|
||||
# else
|
||||
struct binding_eti
|
||||
# endif
|
||||
{
|
||||
# if BOOST_WORKAROUND(BOOST_MSVC, <= 1300) \
|
||||
|| BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
|
||||
# if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
|
||||
typedef typename mpl::eval_if<
|
||||
mpl::is_placeholder<Parameters>
|
||||
, mpl::identity<int>
|
||||
@@ -66,24 +56,8 @@ struct binding_eti
|
||||
));
|
||||
# endif
|
||||
|
||||
# if !BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
||||
BOOST_MPL_AUX_LAMBDA_SUPPORT(3,binding,(Parameters,Keyword,Default))
|
||||
# endif
|
||||
};
|
||||
|
||||
# if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
||||
template <class Parameters, class Keyword, class Default = void_>
|
||||
struct binding
|
||||
{
|
||||
typedef typename mpl::eval_if<
|
||||
is_same<Parameters, int>
|
||||
, mpl::identity<int>
|
||||
, binding_eti<Parameters, Keyword, Default>
|
||||
>::type type;
|
||||
|
||||
BOOST_MPL_AUX_LAMBDA_SUPPORT(3,binding,(Parameters,Keyword,Default))
|
||||
};
|
||||
# endif
|
||||
|
||||
// A metafunction that, given an argument pack, returns the type of
|
||||
// the parameter identified by the given keyword. If no such
|
||||
|
||||
2
include/boost/parameter/config.hpp
Executable file → Normal file
2
include/boost/parameter/config.hpp
Executable file → Normal file
@@ -7,7 +7,7 @@
|
||||
#define BOOST_PARAMETER_CONFIG_050403_HPP
|
||||
|
||||
#ifndef BOOST_PARAMETER_MAX_ARITY
|
||||
# define BOOST_PARAMETER_MAX_ARITY 5
|
||||
# define BOOST_PARAMETER_MAX_ARITY 8
|
||||
#endif
|
||||
|
||||
#endif // BOOST_PARAMETER_CONFIG_050403_HPP
|
||||
|
||||
30
include/boost/parameter/keyword.hpp
Executable file → Normal file
30
include/boost/parameter/keyword.hpp
Executable file → Normal file
@@ -52,7 +52,6 @@ struct keyword
|
||||
return aux::lazy_default<Tag, Default>(default_);
|
||||
}
|
||||
|
||||
#if !BOOST_WORKAROUND(BOOST_MSVC, < 1300) // avoid partial ordering bugs
|
||||
template <class T>
|
||||
typename aux::tag<Tag, T const>::type const
|
||||
operator=(T const& x) const
|
||||
@@ -60,15 +59,10 @@ struct keyword
|
||||
typedef typename aux::tag<Tag, T const>::type result;
|
||||
return result(x);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !BOOST_WORKAROUND(BOOST_MSVC, < 1300) // avoid partial ordering bugs
|
||||
template <class Default>
|
||||
aux::default_<Tag, const Default>
|
||||
operator|(const Default& default_) const
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, == 1300)
|
||||
volatile
|
||||
#endif
|
||||
{
|
||||
return aux::default_<Tag, const Default>(default_);
|
||||
}
|
||||
@@ -76,13 +70,9 @@ struct keyword
|
||||
template <class Default>
|
||||
aux::lazy_default<Tag, Default>
|
||||
operator||(Default const& default_) const
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, == 1300)
|
||||
volatile
|
||||
#endif
|
||||
{
|
||||
return aux::lazy_default<Tag, Default>(default_);
|
||||
}
|
||||
#endif
|
||||
|
||||
public: // Insurance against ODR violations
|
||||
|
||||
@@ -109,24 +99,6 @@ keyword<Tag> const keyword<Tag>::instance = {};
|
||||
// reference in an anonymous namespace to a singleton instance of that
|
||||
// type.
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
||||
|
||||
# define BOOST_PARAMETER_KEYWORD(tag_namespace,name) \
|
||||
namespace tag_namespace \
|
||||
{ \
|
||||
struct name \
|
||||
{ \
|
||||
static char const* keyword_name() \
|
||||
{ \
|
||||
return #name; \
|
||||
} \
|
||||
}; \
|
||||
} \
|
||||
static ::boost::parameter::keyword<tag_namespace::name> const& name \
|
||||
= ::boost::parameter::keyword<tag_namespace::name>::instance;
|
||||
|
||||
#else
|
||||
|
||||
#define BOOST_PARAMETER_KEYWORD(tag_namespace,name) \
|
||||
namespace tag_namespace \
|
||||
{ \
|
||||
@@ -144,8 +116,6 @@ keyword<Tag> const keyword<Tag>::instance = {};
|
||||
= ::boost::parameter::keyword<tag_namespace::name>::instance;\
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
}} // namespace boost::parameter
|
||||
|
||||
#endif // KEYWORD_050328_HPP
|
||||
|
||||
0
include/boost/parameter/macros.hpp
Executable file → Normal file
0
include/boost/parameter/macros.hpp
Executable file → Normal file
0
include/boost/parameter/match.hpp
Executable file → Normal file
0
include/boost/parameter/match.hpp
Executable file → Normal file
24
include/boost/parameter/name.hpp
Executable file → Normal file
24
include/boost/parameter/name.hpp
Executable file → Normal file
@@ -16,7 +16,6 @@
|
||||
# include <boost/mpl/placeholders.hpp>
|
||||
|
||||
# if !defined(BOOST_NO_SFINAE) \
|
||||
&& !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) \
|
||||
&& !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x592))
|
||||
|
||||
# include <boost/utility/enable_if.hpp>
|
||||
@@ -27,7 +26,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 +45,7 @@ namespace boost { namespace mpl {
|
||||
template <class T>
|
||||
struct lambda<
|
||||
T
|
||||
, typename enable_if<
|
||||
, typename boost::enable_if<
|
||||
parameter::aux::is_name_tag<T>, parameter::aux::lambda_tag
|
||||
>::type
|
||||
>
|
||||
@@ -75,19 +74,6 @@ struct lambda<
|
||||
# define BOOST_PARAMETER_IS_BINARY(x) BOOST_PP_IS_BINARY(x)
|
||||
# endif
|
||||
|
||||
# if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
||||
# define BOOST_PARAMETER_NAME_OBJECT(tag, name) \
|
||||
static ::boost::parameter::keyword<tag> const& name \
|
||||
= ::boost::parameter::keyword<tag>::instance;
|
||||
# else
|
||||
# define BOOST_PARAMETER_NAME_OBJECT(tag, name) \
|
||||
namespace \
|
||||
{ \
|
||||
::boost::parameter::keyword<tag> const& name \
|
||||
= ::boost::parameter::keyword<tag>::instance; \
|
||||
}
|
||||
# endif
|
||||
|
||||
# define BOOST_PARAMETER_BASIC_NAME(tag_namespace, tag, name) \
|
||||
namespace tag_namespace \
|
||||
{ \
|
||||
@@ -107,7 +93,11 @@ struct lambda<
|
||||
> _1; \
|
||||
}; \
|
||||
} \
|
||||
BOOST_PARAMETER_NAME_OBJECT(tag_namespace::tag, name)
|
||||
namespace \
|
||||
{ \
|
||||
::boost::parameter::keyword<tag_namespace::tag> const& name \
|
||||
= ::boost::parameter::keyword<tag_namespace::tag>::instance; \
|
||||
}
|
||||
|
||||
# define BOOST_PARAMETER_COMPLEX_NAME_TUPLE1(tag,namespace) \
|
||||
(tag, namespace), ~
|
||||
|
||||
0
include/boost/parameter/parameters.hpp
Executable file → Normal file
0
include/boost/parameter/parameters.hpp
Executable file → Normal file
@@ -37,10 +37,6 @@
|
||||
# include <boost/mpl/always.hpp>
|
||||
# include <boost/mpl/apply_wrap.hpp>
|
||||
|
||||
# if BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
|
||||
# include <boost/type.hpp>
|
||||
# endif
|
||||
|
||||
namespace boost { namespace parameter { namespace aux {
|
||||
|
||||
# if ! defined(BOOST_NO_SFINAE) && ! BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x592))
|
||||
@@ -102,41 +98,6 @@ struct match
|
||||
{};
|
||||
# endif
|
||||
|
||||
# if BOOST_WORKAROUND(BOOST_MSVC, == 1300)
|
||||
|
||||
// Function template argument deduction does many of the same things
|
||||
// as type matching during partial specialization, so we call a
|
||||
// function template to "store" T into the type memory addressed by
|
||||
// void(*)(T).
|
||||
template <class T>
|
||||
msvc_store_type<T,void*(*)(void**(T))>
|
||||
msvc_store_predicate_type(void*(*)(void**(T)));
|
||||
|
||||
template <class T>
|
||||
msvc_store_type<boost::is_convertible<mpl::_,T>,void*(*)(void*(T))>
|
||||
msvc_store_predicate_type(void*(*)(void*(T)));
|
||||
|
||||
template <class FunctionType>
|
||||
struct unwrap_predicate
|
||||
{
|
||||
static FunctionType f;
|
||||
|
||||
// We don't want the function to be evaluated, just instantiated,
|
||||
// so protect it inside of sizeof.
|
||||
enum { dummy = sizeof(msvc_store_predicate_type(f)) };
|
||||
|
||||
// Now pull the type out of the instantiated base class
|
||||
typedef typename msvc_type_memory<FunctionType>::storage::type type;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct unwrap_predicate<void*(*)(void**)>
|
||||
{
|
||||
typedef mpl::always<mpl::true_> type;
|
||||
};
|
||||
|
||||
# endif
|
||||
|
||||
# undef false_
|
||||
|
||||
template <
|
||||
@@ -158,7 +119,6 @@ struct argument_pack
|
||||
typedef typename mpl::first<result>::type type;
|
||||
};
|
||||
|
||||
# if 1 //BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
||||
// Works around VC6 problem where it won't accept rvalues.
|
||||
template <class T>
|
||||
T& as_lvalue(T& value, long)
|
||||
@@ -171,11 +131,9 @@ T const& as_lvalue(T const& value, int)
|
||||
{
|
||||
return value;
|
||||
}
|
||||
# endif
|
||||
|
||||
|
||||
# if BOOST_WORKAROUND(BOOST_MSVC, < 1300) \
|
||||
|| BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
|
||||
# if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
|
||||
|
||||
template <class Predicate, class T, class Args>
|
||||
struct apply_predicate
|
||||
@@ -502,13 +460,7 @@ struct funptr_predicate<void**>
|
||||
# define BOOST_PARAMETER_FUNCTION_PARAMETERS_QUALIFIER_deduced_required(tag) \
|
||||
required<boost::parameter::deduced<tag>
|
||||
|
||||
# if !BOOST_WORKAROUND(BOOST_MSVC, < 1300) && !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
|
||||
|
||||
# if BOOST_WORKAROUND(BOOST_MSVC, == 1300)
|
||||
# define BOOST_PARAMETER_PREDICATE_TYPE(p) void*(*) (void* p)
|
||||
# else
|
||||
# define BOOST_PARAMETER_PREDICATE_TYPE(p) void p
|
||||
# endif
|
||||
# if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
|
||||
|
||||
# define BOOST_PARAMETER_FUNCTION_PARAMETERS_M(r,tag_namespace,i,elem) \
|
||||
BOOST_PP_COMMA_IF(i) \
|
||||
@@ -521,24 +473,9 @@ struct funptr_predicate<void**>
|
||||
) \
|
||||
) \
|
||||
, typename boost::parameter::aux::unwrap_predicate< \
|
||||
BOOST_PARAMETER_PREDICATE_TYPE(BOOST_PARAMETER_FN_ARG_PRED(elem)) \
|
||||
void BOOST_PARAMETER_FN_ARG_PRED(elem) \
|
||||
>::type \
|
||||
>
|
||||
# elif BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
||||
# define BOOST_PARAMETER_FUNCTION_PARAMETERS_M(r,tag_namespace,i,elem) \
|
||||
BOOST_PP_COMMA_IF(i) \
|
||||
boost::parameter::BOOST_PP_CAT( \
|
||||
BOOST_PARAMETER_FUNCTION_PARAMETERS_QUALIFIER_ \
|
||||
, BOOST_PARAMETER_FN_ARG_QUALIFIER(elem) \
|
||||
)( \
|
||||
tag_namespace::BOOST_PARAMETER_FUNCTION_KEYWORD( \
|
||||
BOOST_PARAMETER_FN_ARG_KEYWORD(elem) \
|
||||
) \
|
||||
) \
|
||||
, boost::parameter::aux::funptr_predicate< \
|
||||
void* BOOST_PARAMETER_FN_ARG_PRED(elem) \
|
||||
> \
|
||||
>
|
||||
# elif BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
|
||||
# define BOOST_PARAMETER_FUNCTION_PARAMETERS_M(r,tag_namespace,i,elem) \
|
||||
BOOST_PP_COMMA_IF(i) \
|
||||
@@ -583,21 +520,6 @@ struct funptr_predicate<void**>
|
||||
typedef typename BOOST_PARAMETER_PARENTHESIZED_TYPE(result) type; \
|
||||
};
|
||||
|
||||
# if BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
|
||||
|
||||
# define BOOST_PARAMETER_FUNCTION_RESULT(result, name, args) \
|
||||
BOOST_PARAMETER_FUNCTION_RESULT_(result, name, args) \
|
||||
template <> \
|
||||
struct BOOST_PARAMETER_FUNCTION_RESULT_NAME(name)<int> \
|
||||
{ typedef int type; };
|
||||
|
||||
# else
|
||||
|
||||
# define BOOST_PARAMETER_FUNCTION_RESULT(result, name, args) \
|
||||
BOOST_PARAMETER_FUNCTION_RESULT_(result, name, args)
|
||||
|
||||
# endif
|
||||
|
||||
// Defines implementation function
|
||||
# define BOOST_PARAMETER_FUNCTION_IMPL_HEAD(name) \
|
||||
template <class Args> \
|
||||
@@ -701,6 +623,7 @@ struct funptr_predicate<void**>
|
||||
) \
|
||||
] \
|
||||
, BOOST_PARAMETER_FN_ARG_PRED(arg) \
|
||||
, Args \
|
||||
)
|
||||
|
||||
# define BOOST_PARAMETER_FUNCTION_DEFAULT_FUNCTION_BODY(name, n, split_args, tag_namespace) \
|
||||
@@ -728,6 +651,7 @@ 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_) \
|
||||
@@ -843,6 +767,7 @@ 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
|
||||
@@ -893,7 +818,7 @@ struct funptr_predicate<void**>
|
||||
BOOST_PARAMETER_MEMBER_FUNCTION_STATIC(name) \
|
||||
ResultType BOOST_PARAMETER_FUNCTION_DEFAULT_NAME(name)( \
|
||||
ResultType(*)() \
|
||||
, Args const& args \
|
||||
, Args const& \
|
||||
, int \
|
||||
BOOST_PARAMETER_FUNCTION_DEFAULT_ARGUMENTS( \
|
||||
BOOST_PARAMETER_FUNCTION_DEFAULT_FUNCTION_ARG \
|
||||
@@ -912,7 +837,7 @@ struct funptr_predicate<void**>
|
||||
|
||||
// Defines the result metafunction and the parameters specialization.
|
||||
# define BOOST_PARAMETER_FUNCTION_HEAD(result, name, tag_namespace, args) \
|
||||
BOOST_PARAMETER_FUNCTION_RESULT(result, name, args) \
|
||||
BOOST_PARAMETER_FUNCTION_RESULT_(result, name, args) \
|
||||
\
|
||||
BOOST_PARAMETER_FUNCTION_PARAMETERS(tag_namespace, name, args) \
|
||||
BOOST_PARAMETER_FUNCTION_PARAMETERS_NAME(name); \
|
||||
@@ -1018,18 +943,6 @@ struct funptr_predicate<void**>
|
||||
BOOST_PP_COMMA_IF(i) elem& BOOST_PP_CAT(a, i)
|
||||
/**/
|
||||
|
||||
# if BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
|
||||
|
||||
// Older MSVC can't do what's necessary to handle commas in base names; just
|
||||
// use a typedef instead if you have a base name that contains commas.
|
||||
# define BOOST_PARAMETER_PARENTHESIZED_BASE(x) BOOST_PP_SEQ_HEAD(x)
|
||||
|
||||
# else
|
||||
|
||||
# define BOOST_PARAMETER_PARENTHESIZED_BASE(x) BOOST_PARAMETER_PARENTHESIZED_TYPE(x)
|
||||
|
||||
# endif
|
||||
|
||||
# define BOOST_PARAMETER_FUNCTION_FWD_CONSTRUCTOR00(z, n, r, data, elem) \
|
||||
BOOST_PP_IF( \
|
||||
n \
|
||||
@@ -1054,7 +967,7 @@ struct funptr_predicate<void**>
|
||||
, n \
|
||||
) \
|
||||
) \
|
||||
: BOOST_PARAMETER_PARENTHESIZED_BASE(BOOST_PP_TUPLE_ELEM(6,3,data)) ( \
|
||||
: BOOST_PARAMETER_PARENTHESIZED_TYPE(BOOST_PP_TUPLE_ELEM(6,3,data)) ( \
|
||||
BOOST_PP_CAT(constructor_parameters, __LINE__)()( \
|
||||
BOOST_PP_ENUM_PARAMS_Z(z, n, a) \
|
||||
) \
|
||||
@@ -1145,18 +1058,7 @@ struct funptr_predicate<void**>
|
||||
, (const ParameterArgumentType ## i)(ParameterArgumentType ## i) \
|
||||
, (const ParameterArgumentType ## i) \
|
||||
))
|
||||
// MSVC6.5 lets us bind rvalues to T&.
|
||||
# elif BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
||||
# define BOOST_PARAMETER_FUNCTION_FWD_COMBINATION(r, _, i, elem) \
|
||||
(BOOST_PP_IF( \
|
||||
BOOST_PARAMETER_FUNCTION_IS_KEYWORD_QUALIFIER( \
|
||||
BOOST_PARAMETER_FN_ARG_NAME(elem) \
|
||||
) \
|
||||
, (ParameterArgumentType ## i) \
|
||||
, (const ParameterArgumentType ## i) \
|
||||
))
|
||||
// No partial ordering. This feature doesn't work.
|
||||
// This is exactly the same as for VC6.5, but we might change it later.
|
||||
# else
|
||||
# define BOOST_PARAMETER_FUNCTION_FWD_COMBINATION(r, _, i, elem) \
|
||||
(BOOST_PP_IF( \
|
||||
|
||||
@@ -1,735 +0,0 @@
|
||||
// Copyright Daniel Wallin 2006. 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_PYTHON_060209_HPP
|
||||
# define BOOST_PARAMETER_PYTHON_060209_HPP
|
||||
|
||||
# include <boost/mpl/vector.hpp>
|
||||
# include <boost/mpl/fold.hpp>
|
||||
# include <boost/mpl/prior.hpp>
|
||||
# include <boost/mpl/shift_right.hpp>
|
||||
# include <boost/mpl/shift_left.hpp>
|
||||
# include <boost/mpl/bitand.hpp>
|
||||
# include <boost/mpl/pair.hpp>
|
||||
# include <boost/mpl/size.hpp>
|
||||
# include <boost/mpl/push_back.hpp>
|
||||
# include <boost/mpl/or.hpp>
|
||||
# include <boost/mpl/count_if.hpp>
|
||||
# include <boost/mpl/transform.hpp>
|
||||
# include <boost/mpl/front.hpp>
|
||||
# include <boost/mpl/iterator_range.hpp>
|
||||
# include <boost/mpl/next.hpp>
|
||||
# include <boost/mpl/begin_end.hpp>
|
||||
# include <boost/mpl/not.hpp>
|
||||
# include <boost/mpl/empty.hpp>
|
||||
# include <boost/python/def.hpp>
|
||||
# include <boost/python/make_constructor.hpp>
|
||||
# include <boost/python/init.hpp>
|
||||
# include <boost/python/to_python_converter.hpp>
|
||||
# include <boost/parameter/aux_/maybe.hpp>
|
||||
# include <boost/parameter/aux_/python/invoker.hpp>
|
||||
|
||||
namespace boost { namespace parameter { namespace python
|
||||
{
|
||||
namespace python_ = boost::python;
|
||||
}}}
|
||||
|
||||
namespace boost { namespace parameter { namespace python { namespace aux
|
||||
{
|
||||
|
||||
inline PyObject* unspecified_type()
|
||||
{
|
||||
static PyTypeObject unspecified = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /* ob_size */
|
||||
"Boost.Parameter.Unspecified", /* tp_name */
|
||||
PyType_Type.tp_basicsize, /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
0, /* tp_dealloc */
|
||||
0, /* tp_print */
|
||||
0, /* tp_getattr */
|
||||
0, /* tp_setattr */
|
||||
0, /* tp_compare */
|
||||
0, /* tp_repr */
|
||||
0, /* tp_as_number */
|
||||
0, /* tp_as_sequence */
|
||||
0, /* tp_as_mapping */
|
||||
0, /* tp_hash */
|
||||
0, /* tp_call */
|
||||
0, /* tp_str */
|
||||
0, /* tp_getattro */
|
||||
0, /* tp_setattro */
|
||||
0, /* tp_as_buffer */
|
||||
Py_TPFLAGS_DEFAULT, /* tp_flags */
|
||||
0, /* tp_doc */
|
||||
};
|
||||
|
||||
if (unspecified.ob_type == 0)
|
||||
{
|
||||
unspecified.ob_type = &PyType_Type;
|
||||
PyType_Ready(&unspecified);
|
||||
}
|
||||
|
||||
return (PyObject*)&unspecified;
|
||||
}
|
||||
|
||||
struct empty_tag {};
|
||||
|
||||
struct empty_tag_to_python
|
||||
{
|
||||
static PyObject* convert(empty_tag)
|
||||
{
|
||||
return python_::xincref(unspecified_type());
|
||||
}
|
||||
};
|
||||
|
||||
}}}} // namespace boost::parameter::python::aux
|
||||
|
||||
namespace boost { namespace python
|
||||
{
|
||||
|
||||
// Converts a Python value to a maybe<T>
|
||||
template <class T>
|
||||
struct arg_from_python<parameter::aux::maybe<T> >
|
||||
: arg_from_python<T>
|
||||
{
|
||||
arg_from_python(PyObject* p)
|
||||
: arg_from_python<T>(p)
|
||||
, empty(parameter::python::aux::unspecified_type() == p)
|
||||
{}
|
||||
|
||||
bool convertible() const
|
||||
{
|
||||
return empty || arg_from_python<T>::convertible();
|
||||
}
|
||||
|
||||
parameter::aux::maybe<T> operator()()
|
||||
{
|
||||
if (empty)
|
||||
{
|
||||
return parameter::aux::maybe<T>();
|
||||
}
|
||||
else
|
||||
{
|
||||
return parameter::aux::maybe<T>(
|
||||
arg_from_python<T>::operator()()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
bool empty;
|
||||
};
|
||||
|
||||
}} // namespace boost::python
|
||||
|
||||
namespace boost { namespace parameter { namespace python {
|
||||
|
||||
namespace aux
|
||||
{
|
||||
|
||||
template <class K>
|
||||
struct is_optional
|
||||
: mpl::not_<
|
||||
mpl::or_<typename K::required, typename K::optimized_default>
|
||||
>
|
||||
{};
|
||||
|
||||
template <class K, class Required, class Optimized, class T>
|
||||
struct arg_spec
|
||||
{
|
||||
typedef K keyword;
|
||||
typedef Required required;
|
||||
typedef T type;
|
||||
typedef Optimized optimized_default;
|
||||
};
|
||||
|
||||
template <class K, class T, class Optimized = mpl::false_>
|
||||
struct make_arg_spec_impl
|
||||
{
|
||||
typedef arg_spec<
|
||||
typename K::first, typename K::second, Optimized, T
|
||||
> type;
|
||||
};
|
||||
|
||||
template <class K, class T>
|
||||
struct make_arg_spec_impl<K, T, typename K::third>
|
||||
{
|
||||
typedef arg_spec<
|
||||
typename K::first, typename K::second, typename K::third, T
|
||||
> type;
|
||||
};
|
||||
|
||||
template <class K, class T>
|
||||
struct make_arg_spec
|
||||
: make_arg_spec_impl<K, T>
|
||||
{
|
||||
};
|
||||
|
||||
template <class Spec, class State>
|
||||
struct combinations_op
|
||||
{
|
||||
typedef typename State::second bits;
|
||||
typedef typename State::first result0;
|
||||
|
||||
typedef typename mpl::if_<
|
||||
mpl::or_<
|
||||
typename Spec::required
|
||||
, typename Spec::optimized_default
|
||||
, mpl::bitand_<bits, mpl::long_<1> >
|
||||
>
|
||||
, typename mpl::push_back<result0, Spec>::type
|
||||
, result0
|
||||
>::type result;
|
||||
|
||||
typedef typename mpl::if_<
|
||||
mpl::or_<
|
||||
typename Spec::required
|
||||
, typename Spec::optimized_default
|
||||
>
|
||||
, bits
|
||||
, typename mpl::shift_right<bits, mpl::long_<1> >::type
|
||||
>::type next_bits;
|
||||
|
||||
typedef mpl::pair<
|
||||
result
|
||||
, next_bits
|
||||
> type;
|
||||
};
|
||||
|
||||
// Used as start value in the recursive arg() composition below.
|
||||
struct no_keywords
|
||||
{
|
||||
template <class T>
|
||||
T const& operator,(T const& x) const
|
||||
{
|
||||
return x;
|
||||
}
|
||||
};
|
||||
|
||||
template <class Def, class F, class Iter, class End, class Keywords>
|
||||
void def_combination_aux0(
|
||||
Def def, F f, Iter, End, Keywords const& keywords, mpl::false_)
|
||||
{
|
||||
typedef typename mpl::deref<Iter>::type spec;
|
||||
typedef typename spec::keyword kw;
|
||||
|
||||
def_combination_aux(
|
||||
def, f, typename mpl::next<Iter>::type(), End()
|
||||
, (
|
||||
keywords, boost::python::arg(kw::keyword_name())
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
template <class Def, class F, class Iter, class End, class Keywords>
|
||||
void def_combination_aux0(
|
||||
Def def, F f, Iter, End, Keywords const& keywords, mpl::true_)
|
||||
{
|
||||
typedef typename mpl::deref<Iter>::type spec;
|
||||
typedef typename spec::keyword kw;
|
||||
|
||||
def_combination_aux(
|
||||
def, f, typename mpl::next<Iter>::type(), End()
|
||||
, (
|
||||
keywords, boost::python::arg(kw::keyword_name()) = empty_tag()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
inline void initialize_converter()
|
||||
{
|
||||
static python_::to_python_converter<empty_tag, empty_tag_to_python> x;
|
||||
}
|
||||
|
||||
template <class Def, class F, class Iter, class End, class Keywords>
|
||||
void def_combination_aux(
|
||||
Def def, F f, Iter, End, Keywords const& keywords)
|
||||
{
|
||||
typedef typename mpl::deref<Iter>::type spec;
|
||||
|
||||
typedef typename mpl::and_<
|
||||
typename spec::optimized_default
|
||||
, mpl::not_<typename spec::required>
|
||||
>::type optimized_default;
|
||||
|
||||
def_combination_aux0(
|
||||
def, f, Iter(), End(), keywords, optimized_default()
|
||||
);
|
||||
}
|
||||
|
||||
template <class Def, class F, class End, class Keywords>
|
||||
void def_combination_aux(
|
||||
Def def, F f, End, End, Keywords const& keywords)
|
||||
{
|
||||
def(f, keywords);
|
||||
}
|
||||
|
||||
template <class Def, class F, class End>
|
||||
void def_combination_aux(
|
||||
Def def, F f, End, End, no_keywords const&)
|
||||
{
|
||||
def(f);
|
||||
}
|
||||
|
||||
template <
|
||||
class Def, class Specs, class Bits, class Invoker
|
||||
>
|
||||
void def_combination(
|
||||
Def def, Specs*, Bits, Invoker*)
|
||||
{
|
||||
typedef typename mpl::fold<
|
||||
Specs
|
||||
, mpl::pair<mpl::vector0<>, Bits>
|
||||
, combinations_op<mpl::_2, mpl::_1>
|
||||
>::type combination0;
|
||||
|
||||
typedef typename combination0::first combination;
|
||||
|
||||
typedef typename mpl::apply_wrap1<
|
||||
Invoker, combination
|
||||
>::type invoker;
|
||||
|
||||
def_combination_aux(
|
||||
def
|
||||
, &invoker::execute
|
||||
, typename mpl::begin<combination>::type()
|
||||
, typename mpl::end<combination>::type()
|
||||
, no_keywords()
|
||||
);
|
||||
}
|
||||
|
||||
template <
|
||||
class Def, class Specs, class Bits, class End, class Invoker
|
||||
>
|
||||
void def_combinations(
|
||||
Def def, Specs*, Bits, End, Invoker*)
|
||||
{
|
||||
initialize_converter();
|
||||
|
||||
def_combination(def, (Specs*)0, Bits(), (Invoker*)0);
|
||||
|
||||
def_combinations(
|
||||
def
|
||||
, (Specs*)0
|
||||
, mpl::long_<Bits::value + 1>()
|
||||
, End()
|
||||
, (Invoker*)0
|
||||
);
|
||||
}
|
||||
|
||||
template <
|
||||
class Def, class Specs, class End, class Invoker
|
||||
>
|
||||
void def_combinations(
|
||||
Def, Specs*, End, End, Invoker*)
|
||||
{}
|
||||
|
||||
struct not_specified {};
|
||||
|
||||
template <class CallPolicies>
|
||||
struct call_policies_as_options
|
||||
{
|
||||
call_policies_as_options(CallPolicies const& call_policies)
|
||||
: call_policies(call_policies)
|
||||
{}
|
||||
|
||||
CallPolicies const& policies() const
|
||||
{
|
||||
return call_policies;
|
||||
}
|
||||
|
||||
char const* doc() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
CallPolicies call_policies;
|
||||
};
|
||||
|
||||
template <class Class, class Options = not_specified>
|
||||
struct def_class
|
||||
{
|
||||
def_class(Class& cl, char const* name, Options options = Options())
|
||||
: cl(cl)
|
||||
, name(name)
|
||||
, options(options)
|
||||
{}
|
||||
|
||||
template <class F>
|
||||
void def(F f, not_specified const*) const
|
||||
{
|
||||
cl.def(name, f);
|
||||
}
|
||||
|
||||
template <class F>
|
||||
void def(F f, void const*) const
|
||||
{
|
||||
cl.def(name, f, options.doc(), options.policies());
|
||||
}
|
||||
|
||||
template <class F>
|
||||
void operator()(F f) const
|
||||
{
|
||||
this->def(f, &options);
|
||||
}
|
||||
|
||||
template <class F, class Keywords>
|
||||
void def(F f, Keywords const& keywords, not_specified const*) const
|
||||
{
|
||||
cl.def(name, f, keywords);
|
||||
}
|
||||
|
||||
template <class F, class Keywords>
|
||||
void def(F f, Keywords const& keywords, void const*) const
|
||||
{
|
||||
cl.def(name, f, keywords, options.doc(), options.policies());
|
||||
}
|
||||
|
||||
template <class F, class Keywords>
|
||||
void operator()(F f, Keywords const& keywords) const
|
||||
{
|
||||
this->def(f, keywords, &options);
|
||||
}
|
||||
|
||||
Class& cl;
|
||||
char const* name;
|
||||
Options options;
|
||||
};
|
||||
|
||||
template <class Class, class CallPolicies = boost::python::default_call_policies>
|
||||
struct def_init
|
||||
{
|
||||
def_init(Class& cl, CallPolicies call_policies = CallPolicies())
|
||||
: cl(cl)
|
||||
, call_policies(call_policies)
|
||||
{}
|
||||
|
||||
template <class F>
|
||||
void operator()(F f) const
|
||||
{
|
||||
cl.def(
|
||||
"__init__"
|
||||
, boost::python::make_constructor(f, call_policies)
|
||||
);
|
||||
}
|
||||
|
||||
template <class F, class Keywords>
|
||||
void operator()(F f, Keywords const& keywords) const
|
||||
{
|
||||
cl.def(
|
||||
"__init__"
|
||||
, boost::python::make_constructor(f, call_policies, keywords)
|
||||
);
|
||||
}
|
||||
|
||||
Class& cl;
|
||||
CallPolicies call_policies;
|
||||
};
|
||||
|
||||
struct def_function
|
||||
{
|
||||
def_function(char const* name)
|
||||
: name(name)
|
||||
{}
|
||||
|
||||
template <class F>
|
||||
void operator()(F f) const
|
||||
{
|
||||
boost::python::def(name, f);
|
||||
}
|
||||
|
||||
template <class F, class Keywords>
|
||||
void operator()(F f, Keywords const& keywords) const
|
||||
{
|
||||
boost::python::def(name, f, keywords);
|
||||
}
|
||||
|
||||
char const* name;
|
||||
};
|
||||
|
||||
} // namespace aux
|
||||
|
||||
template <class M, class Signature>
|
||||
void def(char const* name, Signature)
|
||||
{
|
||||
typedef mpl::iterator_range<
|
||||
typename mpl::next<
|
||||
typename mpl::begin<Signature>::type
|
||||
>::type
|
||||
, typename mpl::end<Signature>::type
|
||||
> arg_types;
|
||||
|
||||
typedef typename mpl::transform<
|
||||
typename M::keywords
|
||||
, arg_types
|
||||
, aux::make_arg_spec<mpl::_1, mpl::_2>
|
||||
, mpl::back_inserter<mpl::vector0<> >
|
||||
>::type arg_specs;
|
||||
|
||||
typedef typename mpl::count_if<
|
||||
arg_specs
|
||||
, aux::is_optional<mpl::_1>
|
||||
>::type optional_arity;
|
||||
|
||||
typedef typename mpl::front<Signature>::type result_type;
|
||||
typedef typename mpl::shift_left<mpl::long_<1>, optional_arity>::type upper;
|
||||
|
||||
aux::def_combinations(
|
||||
aux::def_function(name)
|
||||
, (arg_specs*)0
|
||||
, mpl::long_<0>()
|
||||
, mpl::long_<upper::value>()
|
||||
, (aux::make_invoker<M, result_type>*)0
|
||||
);
|
||||
}
|
||||
|
||||
template <class M, class Class, class Signature>
|
||||
void def(Class& cl, char const* name, Signature)
|
||||
{
|
||||
typedef mpl::iterator_range<
|
||||
typename mpl::next<
|
||||
typename mpl::begin<Signature>::type
|
||||
>::type
|
||||
, typename mpl::end<Signature>::type
|
||||
> arg_types;
|
||||
|
||||
typedef typename mpl::transform<
|
||||
typename M::keywords
|
||||
, arg_types
|
||||
, aux::make_arg_spec<mpl::_1, mpl::_2>
|
||||
, mpl::back_inserter<mpl::vector0<> >
|
||||
>::type arg_specs;
|
||||
|
||||
typedef typename mpl::count_if<
|
||||
arg_specs
|
||||
, aux::is_optional<mpl::_1>
|
||||
>::type optional_arity;
|
||||
|
||||
typedef typename mpl::front<Signature>::type result_type;
|
||||
typedef typename mpl::shift_left<mpl::long_<1>, optional_arity>::type upper;
|
||||
|
||||
aux::def_combinations(
|
||||
aux::def_class<Class>(cl, name)
|
||||
, (arg_specs*)0
|
||||
, mpl::long_<0>()
|
||||
, mpl::long_<upper::value>()
|
||||
, (aux::make_invoker<M, result_type>*)0
|
||||
);
|
||||
}
|
||||
|
||||
namespace aux
|
||||
{
|
||||
|
||||
template <class K>
|
||||
struct keyword
|
||||
{
|
||||
typedef K type;
|
||||
};
|
||||
|
||||
template <class K>
|
||||
struct keyword<K*>
|
||||
{
|
||||
typedef K type;
|
||||
};
|
||||
|
||||
template <class K>
|
||||
struct keyword<K**>
|
||||
{
|
||||
typedef K type;
|
||||
};
|
||||
|
||||
template <class K>
|
||||
struct required
|
||||
{
|
||||
typedef mpl::true_ type;
|
||||
};
|
||||
|
||||
template <class K>
|
||||
struct required<K*>
|
||||
{
|
||||
typedef mpl::false_ type;
|
||||
};
|
||||
|
||||
template <class K>
|
||||
struct optimized
|
||||
{
|
||||
typedef mpl::true_ type;
|
||||
};
|
||||
|
||||
template <class K>
|
||||
struct optimized<K**>
|
||||
{
|
||||
typedef mpl::false_ type;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct make_kw_spec;
|
||||
|
||||
template <class K, class T>
|
||||
struct make_kw_spec<K(T)>
|
||||
{
|
||||
typedef arg_spec<
|
||||
typename keyword<K>::type
|
||||
, typename required<K>::type
|
||||
, typename optimized<K>::type
|
||||
, T
|
||||
> type;
|
||||
};
|
||||
|
||||
} // namespace aux
|
||||
|
||||
template <class ParameterSpecs, class CallPolicies = boost::python::default_call_policies>
|
||||
struct init
|
||||
: boost::python::def_visitor<init<ParameterSpecs, CallPolicies> >
|
||||
{
|
||||
init(CallPolicies call_policies = CallPolicies())
|
||||
: call_policies(call_policies)
|
||||
{}
|
||||
|
||||
template <class CallPolicies1>
|
||||
init<ParameterSpecs, CallPolicies1>
|
||||
operator[](CallPolicies1 const& call_policies) const
|
||||
{
|
||||
return init<ParameterSpecs, CallPolicies1>(call_policies);
|
||||
}
|
||||
|
||||
template <class Class>
|
||||
void visit_aux(Class& cl, mpl::true_) const
|
||||
{
|
||||
cl.def(boost::python::init<>()[call_policies]);
|
||||
}
|
||||
|
||||
template <class Class>
|
||||
void visit_aux(Class& cl, mpl::false_) const
|
||||
{
|
||||
typedef typename mpl::transform<
|
||||
ParameterSpecs
|
||||
, aux::make_kw_spec<mpl::_>
|
||||
, mpl::back_inserter<mpl::vector0<> >
|
||||
>::type arg_specs;
|
||||
|
||||
typedef typename mpl::count_if<
|
||||
arg_specs
|
||||
, aux::is_optional<mpl::_>
|
||||
>::type optional_arity;
|
||||
|
||||
typedef typename mpl::shift_left<mpl::long_<1>, optional_arity>::type upper;
|
||||
|
||||
aux::def_combinations(
|
||||
aux::def_init<Class, CallPolicies>(cl, call_policies)
|
||||
, (arg_specs*)0
|
||||
, mpl::long_<0>()
|
||||
, mpl::long_<upper::value>()
|
||||
, (aux::make_init_invoker<typename Class::wrapped_type>*)0
|
||||
);
|
||||
}
|
||||
|
||||
template <class Class>
|
||||
void visit(Class& cl) const
|
||||
{
|
||||
visit_aux(cl, mpl::empty<ParameterSpecs>());
|
||||
}
|
||||
|
||||
CallPolicies call_policies;
|
||||
};
|
||||
|
||||
template <class ParameterSpecs, class CallPolicies = boost::python::default_call_policies>
|
||||
struct call
|
||||
: boost::python::def_visitor<call<ParameterSpecs, CallPolicies> >
|
||||
{
|
||||
call(CallPolicies const& call_policies = CallPolicies())
|
||||
: call_policies(call_policies)
|
||||
{}
|
||||
|
||||
template <class CallPolicies1>
|
||||
call<ParameterSpecs, CallPolicies1>
|
||||
operator[](CallPolicies1 const& call_policies) const
|
||||
{
|
||||
return call<ParameterSpecs, CallPolicies1>(call_policies);
|
||||
}
|
||||
|
||||
template <class Class>
|
||||
void visit(Class& cl) const
|
||||
{
|
||||
typedef mpl::iterator_range<
|
||||
typename mpl::next<
|
||||
typename mpl::begin<ParameterSpecs>::type
|
||||
>::type
|
||||
, typename mpl::end<ParameterSpecs>::type
|
||||
> arg_types;
|
||||
|
||||
typedef typename mpl::front<ParameterSpecs>::type result_type;
|
||||
|
||||
typedef typename mpl::transform<
|
||||
arg_types
|
||||
, aux::make_kw_spec<mpl::_>
|
||||
, mpl::back_inserter<mpl::vector0<> >
|
||||
>::type arg_specs;
|
||||
|
||||
typedef typename mpl::count_if<
|
||||
arg_specs
|
||||
, aux::is_optional<mpl::_>
|
||||
>::type optional_arity;
|
||||
|
||||
typedef typename mpl::shift_left<mpl::long_<1>, optional_arity>::type upper;
|
||||
|
||||
typedef aux::call_policies_as_options<CallPolicies> options;
|
||||
|
||||
aux::def_combinations(
|
||||
aux::def_class<Class, options>(cl, "__call__", options(call_policies))
|
||||
, (arg_specs*)0
|
||||
, mpl::long_<0>()
|
||||
, mpl::long_<upper::value>()
|
||||
, (aux::make_call_invoker<typename Class::wrapped_type, result_type>*)0
|
||||
);
|
||||
}
|
||||
|
||||
CallPolicies call_policies;
|
||||
};
|
||||
|
||||
template <class Fwd, class ParameterSpecs>
|
||||
struct function
|
||||
: boost::python::def_visitor<function<Fwd, ParameterSpecs> >
|
||||
{
|
||||
template <class Class, class Options>
|
||||
void visit(Class& cl, char const* name, Options const& options) const
|
||||
{
|
||||
typedef mpl::iterator_range<
|
||||
typename mpl::next<
|
||||
typename mpl::begin<ParameterSpecs>::type
|
||||
>::type
|
||||
, typename mpl::end<ParameterSpecs>::type
|
||||
> arg_types;
|
||||
|
||||
typedef typename mpl::front<ParameterSpecs>::type result_type;
|
||||
|
||||
typedef typename mpl::transform<
|
||||
arg_types
|
||||
, aux::make_kw_spec<mpl::_>
|
||||
, mpl::back_inserter<mpl::vector0<> >
|
||||
>::type arg_specs;
|
||||
|
||||
typedef typename mpl::count_if<
|
||||
arg_specs
|
||||
, aux::is_optional<mpl::_>
|
||||
>::type optional_arity;
|
||||
|
||||
typedef typename mpl::shift_left<mpl::long_<1>, optional_arity>::type upper;
|
||||
|
||||
aux::def_combinations(
|
||||
aux::def_class<Class, Options>(cl, name, options)
|
||||
, (arg_specs*)0
|
||||
, mpl::long_<0>()
|
||||
, mpl::long_<upper::value>()
|
||||
, (aux::make_member_invoker<
|
||||
Fwd, result_type, typename Class::wrapped_type
|
||||
>*)0
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
}}} // namespace boost::parameter::python
|
||||
|
||||
#endif // BOOST_PARAMETER_PYTHON_060209_HPP
|
||||
|
||||
30
include/boost/parameter/value_type.hpp
Executable file → Normal file
30
include/boost/parameter/value_type.hpp
Executable file → Normal file
@@ -12,18 +12,13 @@
|
||||
# include <boost/parameter/aux_/void.hpp>
|
||||
# include <boost/type_traits/is_same.hpp>
|
||||
|
||||
# if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
||||
# include <boost/mpl/eval_if.hpp>
|
||||
# endif
|
||||
|
||||
namespace boost { namespace parameter {
|
||||
|
||||
// A metafunction that, given an argument pack, returns the type of
|
||||
// the parameter identified by the given keyword. If no such
|
||||
// parameter has been specified, returns Default
|
||||
|
||||
# if BOOST_WORKAROUND(BOOST_MSVC, <= 1300) \
|
||||
|| BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
|
||||
# if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
|
||||
template <class Parameters, class Keyword, class Default>
|
||||
struct value_type0
|
||||
{
|
||||
@@ -41,14 +36,9 @@ struct value_type0
|
||||
# endif
|
||||
|
||||
template <class Parameters, class Keyword, class Default = void_>
|
||||
# if !BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
||||
struct value_type
|
||||
# else
|
||||
struct value_type_eti
|
||||
# endif
|
||||
{
|
||||
# if BOOST_WORKAROUND(BOOST_MSVC, <= 1300) \
|
||||
|| BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
|
||||
# if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
|
||||
typedef typename mpl::eval_if<
|
||||
mpl::is_placeholder<Parameters>
|
||||
, mpl::identity<int>
|
||||
@@ -67,24 +57,8 @@ struct value_type_eti
|
||||
));
|
||||
# endif
|
||||
|
||||
# if !BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
||||
BOOST_MPL_AUX_LAMBDA_SUPPORT(3,value_type,(Parameters,Keyword,Default))
|
||||
# endif
|
||||
};
|
||||
|
||||
# if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
||||
template <class Parameters, class Keyword, class Default = void_>
|
||||
struct value_type
|
||||
{
|
||||
typedef typename mpl::eval_if<
|
||||
is_same<Parameters, int>
|
||||
, mpl::identity<int>
|
||||
, value_type_eti<Parameters, Keyword, Default>
|
||||
>::type type;
|
||||
|
||||
BOOST_MPL_AUX_LAMBDA_SUPPORT(3,value_type,(Parameters,Keyword,Default))
|
||||
};
|
||||
# endif
|
||||
|
||||
// A metafunction that, given an argument pack, returns the type of
|
||||
// the parameter identified by the given keyword. If no such
|
||||
|
||||
0
index.html
Executable file → Normal file
0
index.html
Executable file → Normal file
17
meta/libraries.json
Normal file
17
meta/libraries.json
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"key": "parameter",
|
||||
"name": "Parameter",
|
||||
"authors": [
|
||||
"David Abrahams",
|
||||
"Daniel Wallin"
|
||||
],
|
||||
"description": "Boost.Parameter Library - Write functions that accept arguments by name.",
|
||||
"category": [
|
||||
"Emulation",
|
||||
"Programming"
|
||||
],
|
||||
"maintainers": [
|
||||
"David Abrahams <dave -at- boost-consulting.com>",
|
||||
"Daniel Wallin <daniel -at- boostpro.com>"
|
||||
]
|
||||
}
|
||||
0
test/basics.cpp
Executable file → Normal file
0
test/basics.cpp
Executable file → Normal file
0
test/basics.hpp
Executable file → Normal file
0
test/basics.hpp
Executable file → Normal file
0
test/deduced.cpp
Executable file → Normal file
0
test/deduced.cpp
Executable file → Normal file
0
test/deduced.hpp
Executable file → Normal file
0
test/deduced.hpp
Executable file → Normal file
0
test/deduced_dependent_predicate.cpp
Executable file → Normal file
0
test/deduced_dependent_predicate.cpp
Executable file → Normal file
0
test/deduced_unmatched_arg.cpp
Executable file → Normal file
0
test/deduced_unmatched_arg.cpp
Executable file → Normal file
0
test/duplicates.cpp
Executable file → Normal file
0
test/duplicates.cpp
Executable file → Normal file
0
test/earwicker.cpp
Executable file → Normal file
0
test/earwicker.cpp
Executable file → Normal file
0
test/efficiency.cpp
Executable file → Normal file
0
test/efficiency.cpp
Executable file → Normal file
@@ -1,8 +1,6 @@
|
||||
|
||||
#line 1711 "../../../../libs/parameter/doc/index.rst"
|
||||
#include <boost/parameter.hpp>
|
||||
#include <iostream>
|
||||
#line 1700 "../../../../libs/parameter/doc/index.rst"
|
||||
BOOST_PARAMETER_NAME(index)
|
||||
|
||||
template <class ArgumentPack>
|
||||
@@ -14,7 +12,6 @@ int print_index(ArgumentPack const& args)
|
||||
|
||||
int x = print_index(_index = 3); // prints "index = 3"
|
||||
|
||||
#line 1719 "../../../../libs/parameter/doc/index.rst"
|
||||
BOOST_PARAMETER_NAME(name)
|
||||
|
||||
template <class ArgumentPack>
|
||||
@@ -27,13 +24,11 @@ int print_name_and_index(ArgumentPack const& args)
|
||||
int y = print_name_and_index((_index = 3, _name = "jones"));
|
||||
|
||||
|
||||
#line 1754 "../../../../libs/parameter/doc/index.rst"
|
||||
namespace parameter = boost::parameter;
|
||||
using parameter::required;
|
||||
using parameter::optional;
|
||||
using boost::is_convertible;
|
||||
using boost::mpl::_;
|
||||
#line 1740 "../../../../libs/parameter/doc/index.rst"
|
||||
parameter::parameters<
|
||||
required<tag::name, is_convertible<_,char const*> >
|
||||
, optional<tag::index, is_convertible<_,int> >
|
||||
@@ -47,7 +42,6 @@ int z0 = print_name_and_index( spec(sam, twelve) );
|
||||
int z1 = print_name_and_index(
|
||||
spec(_index=12, _name="sam")
|
||||
);
|
||||
#line 1761 "../../../../libs/parameter/doc/index.rst"
|
||||
int main()
|
||||
{}
|
||||
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
|
||||
#line 1354 "../../../../libs/parameter/doc/index.rst"
|
||||
#include <boost/parameter.hpp>
|
||||
#line 1340 "../../../../libs/parameter/doc/index.rst"
|
||||
namespace boost { namespace python {
|
||||
|
||||
template <
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
|
||||
#line 1029 "../../../../libs/parameter/doc/index.rst"
|
||||
#include <boost/parameter.hpp>
|
||||
|
||||
BOOST_PARAMETER_NAME(name)
|
||||
@@ -31,7 +30,6 @@ default_call_policies some_policies;
|
||||
|
||||
void f()
|
||||
{}
|
||||
#line 996 "../../../../libs/parameter/doc/index.rst"
|
||||
namespace mpl = boost::mpl;
|
||||
|
||||
BOOST_PARAMETER_FUNCTION(
|
||||
@@ -64,17 +62,13 @@ BOOST_PARAMETER_FUNCTION(
|
||||
}
|
||||
|
||||
|
||||
#line 1078 "../../../../libs/parameter/doc/index.rst"
|
||||
int main()
|
||||
{
|
||||
#line 1075 "../../../../libs/parameter/doc/index.rst"
|
||||
def("f", &f, some_policies, "Documentation for f");
|
||||
def("f", &f, "Documentation for f", some_policies);
|
||||
|
||||
#line 1088 "../../../../libs/parameter/doc/index.rst"
|
||||
def(
|
||||
"f", &f
|
||||
, _policies = some_policies, "Documentation for f");
|
||||
#line 1091 "../../../../libs/parameter/doc/index.rst"
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
|
||||
#line 1524 "../../../../libs/parameter/doc/index.rst"
|
||||
#include <boost/parameter.hpp>
|
||||
#include <boost/mpl/is_sequence.hpp>
|
||||
#include <boost/noncopyable.hpp>
|
||||
#include <memory>
|
||||
#include <boost/config.hpp>
|
||||
|
||||
using namespace boost::parameter;
|
||||
using boost::mpl::_;
|
||||
@@ -16,7 +16,6 @@ BOOST_PARAMETER_TEMPLATE_KEYWORD(held_type)
|
||||
BOOST_PARAMETER_TEMPLATE_KEYWORD(copyable)
|
||||
|
||||
}}
|
||||
#line 1513 "../../../../libs/parameter/doc/index.rst"
|
||||
namespace boost { namespace python {
|
||||
|
||||
namespace detail { struct bases_base {}; }
|
||||
@@ -28,10 +27,8 @@ struct bases : detail::bases_base
|
||||
}}
|
||||
|
||||
|
||||
#line 1567 "../../../../libs/parameter/doc/index.rst"
|
||||
#include <boost/type_traits/is_class.hpp>
|
||||
namespace boost { namespace python {
|
||||
#line 1545 "../../../../libs/parameter/doc/index.rst"
|
||||
typedef parameter::parameters<
|
||||
required<tag::class_type, is_class<_> >
|
||||
|
||||
@@ -53,7 +50,6 @@ typedef parameter::parameters<
|
||||
, parameter::optional<deduced<tag::copyable>, is_same<noncopyable,_> >
|
||||
|
||||
> class_signature;
|
||||
#line 1571 "../../../../libs/parameter/doc/index.rst"
|
||||
template <
|
||||
class A0
|
||||
, class A1 = parameter::void_
|
||||
@@ -85,16 +81,22 @@ struct class_
|
||||
|
||||
|
||||
|
||||
#line 1611 "../../../../libs/parameter/doc/index.rst"
|
||||
struct B {};
|
||||
struct D {};
|
||||
|
||||
using boost::python::bases;
|
||||
#line 1607 "../../../../libs/parameter/doc/index.rst"
|
||||
typedef boost::python::class_<B, boost::noncopyable> c1;
|
||||
|
||||
#if defined(BOOST_NO_CXX11_SMART_PTR)
|
||||
|
||||
typedef boost::python::class_<D, std::auto_ptr<D>, bases<B> > c2;
|
||||
#line 1617 "../../../../libs/parameter/doc/index.rst"
|
||||
|
||||
#else
|
||||
|
||||
typedef boost::python::class_<D, std::unique_ptr<D>, bases<B> > c2;
|
||||
|
||||
#endif
|
||||
|
||||
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>));
|
||||
@@ -104,8 +106,19 @@ BOOST_MPL_ASSERT((
|
||||
|
||||
BOOST_MPL_ASSERT((boost::is_same<c2::class_type, D>));
|
||||
BOOST_MPL_ASSERT((boost::is_same<c2::base_list, bases<B> >));
|
||||
|
||||
#if defined(BOOST_NO_CXX11_SMART_PTR)
|
||||
|
||||
BOOST_MPL_ASSERT((
|
||||
boost::is_same<c2::held_type, std::auto_ptr<D> >
|
||||
));
|
||||
BOOST_MPL_ASSERT((boost::is_same<c2::copyable, void>));
|
||||
|
||||
#else
|
||||
|
||||
BOOST_MPL_ASSERT((
|
||||
boost::is_same<c2::held_type, std::unique_ptr<D> >
|
||||
));
|
||||
|
||||
#endif
|
||||
|
||||
BOOST_MPL_ASSERT((boost::is_same<c2::copyable, void>));
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
|
||||
#line 730 "../../../../libs/parameter/doc/index.rst"
|
||||
#include <boost/parameter.hpp>
|
||||
#include <iostream>
|
||||
|
||||
@@ -8,7 +7,6 @@ BOOST_PARAMETER_NAME(visitor)
|
||||
BOOST_PARAMETER_NAME(root_vertex)
|
||||
BOOST_PARAMETER_NAME(index_map)
|
||||
BOOST_PARAMETER_NAME(color_map)
|
||||
#line 702 "../../../../libs/parameter/doc/index.rst"
|
||||
#include <boost/graph/depth_first_search.hpp> // for dfs_visitor
|
||||
|
||||
BOOST_PARAMETER_FUNCTION(
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
#line 397 "../../../../libs/parameter/doc/index.rst"
|
||||
#include <boost/parameter/name.hpp>
|
||||
|
||||
namespace graphs
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
|
||||
#line 424 "../../../../libs/parameter/doc/index.rst"
|
||||
#include <boost/parameter/keyword.hpp>
|
||||
#line 413 "../../../../libs/parameter/doc/index.rst"
|
||||
namespace graphs
|
||||
{
|
||||
namespace tag { struct graph; } // keyword tag type
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
|
||||
#line 1382 "../../../../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>
|
||||
#include <boost/config.hpp>
|
||||
|
||||
using namespace boost::parameter;
|
||||
|
||||
@@ -20,7 +20,6 @@ struct bases
|
||||
{};
|
||||
|
||||
}}
|
||||
#line 1369 "../../../../libs/parameter/doc/index.rst"
|
||||
namespace boost { namespace python {
|
||||
|
||||
using boost::mpl::_;
|
||||
@@ -34,7 +33,6 @@ typedef parameter::parameters<
|
||||
|
||||
}}
|
||||
|
||||
#line 1421 "../../../../libs/parameter/doc/index.rst"
|
||||
namespace boost { namespace python {
|
||||
|
||||
template <
|
||||
@@ -67,7 +65,6 @@ struct class_
|
||||
}}
|
||||
|
||||
|
||||
#line 1 "None"
|
||||
using boost::python::class_type;
|
||||
using boost::python::copyable;
|
||||
using boost::python::held_type;
|
||||
@@ -76,16 +73,24 @@ using boost::python::bases;
|
||||
|
||||
struct B {};
|
||||
struct D {};
|
||||
#line 1462 "../../../../libs/parameter/doc/index.rst"
|
||||
typedef boost::python::class_<
|
||||
class_type<B>, copyable<boost::noncopyable>
|
||||
> c1;
|
||||
|
||||
typedef boost::python::class_<
|
||||
|
||||
#if defined(BOOST_NO_CXX11_SMART_PTR)
|
||||
|
||||
D, held_type<std::auto_ptr<D> >, base_list<bases<B> >
|
||||
|
||||
#else
|
||||
|
||||
D, held_type<std::unique_ptr<D> >, base_list<bases<B> >
|
||||
|
||||
#endif
|
||||
|
||||
> c2;
|
||||
|
||||
#line 1482 "../../../../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>));
|
||||
@@ -95,7 +100,19 @@ BOOST_MPL_ASSERT((
|
||||
|
||||
BOOST_MPL_ASSERT((boost::is_same<c2::class_type, D>));
|
||||
BOOST_MPL_ASSERT((boost::is_same<c2::base_list, bases<B> >));
|
||||
|
||||
#if defined(BOOST_NO_CXX11_SMART_PTR)
|
||||
|
||||
BOOST_MPL_ASSERT((
|
||||
boost::is_same<c2::held_type, std::auto_ptr<D> >
|
||||
));
|
||||
|
||||
#else
|
||||
|
||||
BOOST_MPL_ASSERT((
|
||||
boost::is_same<c2::held_type, std::unique_ptr<D> >
|
||||
));
|
||||
|
||||
#endif
|
||||
|
||||
BOOST_MPL_ASSERT((boost::is_same<c2::copyable, void>));
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
|
||||
#line 1797 "../../../../libs/parameter/doc/index.rst"
|
||||
#include <boost/parameter.hpp>
|
||||
#include <cassert>
|
||||
#line 1780 "../../../../libs/parameter/doc/index.rst"
|
||||
BOOST_PARAMETER_NAME(name)
|
||||
BOOST_PARAMETER_NAME(index)
|
||||
|
||||
@@ -19,7 +17,6 @@ int deduce_arg_types(ArgumentPack const& args)
|
||||
{
|
||||
return deduce_arg_types_impl(args[_name], args[_index|42]);
|
||||
}
|
||||
#line 1801 "../../../../libs/parameter/doc/index.rst"
|
||||
int a1 = deduce_arg_types((_name = "foo"));
|
||||
int a2 = deduce_arg_types((_name = "foo", _index = 3));
|
||||
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
|
||||
#line 1830 "../../../../libs/parameter/doc/index.rst"
|
||||
#include <boost/parameter.hpp>
|
||||
#include <boost/type_traits/remove_reference.hpp>
|
||||
#include <cassert>
|
||||
|
||||
namespace parameter = boost::parameter;
|
||||
#line 1819 "../../../../libs/parameter/doc/index.rst"
|
||||
BOOST_PARAMETER_NAME(index)
|
||||
|
||||
template <class ArgumentPack>
|
||||
@@ -16,7 +14,6 @@ twice_index(ArgumentPack const& args)
|
||||
}
|
||||
|
||||
int six = twice_index(_index = 3);
|
||||
#line 1838 "../../../../libs/parameter/doc/index.rst"
|
||||
int main()
|
||||
{
|
||||
assert(six == 6);
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
|
||||
#line 1670 "../../../../libs/parameter/doc/index.rst"
|
||||
#include <boost/parameter.hpp>
|
||||
#line 1660 "../../../../libs/parameter/doc/index.rst"
|
||||
BOOST_PARAMETER_NAME((pass_foo, keywords) foo)
|
||||
|
||||
BOOST_PARAMETER_FUNCTION(
|
||||
@@ -12,7 +10,6 @@ BOOST_PARAMETER_FUNCTION(
|
||||
}
|
||||
|
||||
int x = f(pass_foo = 41);
|
||||
#line 1671 "../../../../libs/parameter/doc/index.rst"
|
||||
int main()
|
||||
{}
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
|
||||
#line 620 "../../../../libs/parameter/doc/index.rst"
|
||||
#include <boost/parameter.hpp>
|
||||
|
||||
namespace boost
|
||||
@@ -20,7 +19,6 @@ BOOST_PARAMETER_NAME(color_map)
|
||||
|
||||
BOOST_PARAMETER_FUNCTION((void), f, tag,
|
||||
(required (graph, *))
|
||||
#line 612 "../../../../libs/parameter/doc/index.rst"
|
||||
(optional
|
||||
(visitor, *, boost::dfs_visitor<>())
|
||||
(root_vertex, *, *vertices(graph).first)
|
||||
@@ -28,6 +26,5 @@ BOOST_PARAMETER_FUNCTION((void), f, tag,
|
||||
(in_out(color_map), *,
|
||||
default_color_map(num_vertices(graph), index_map) )
|
||||
)
|
||||
#line 642 "../../../../libs/parameter/doc/index.rst"
|
||||
) {}
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#line 274 "../../../../libs/parameter/doc/index.rst"
|
||||
#include <boost/parameter/keyword.hpp>
|
||||
#line 283 "../../../../libs/parameter/doc/index.rst"
|
||||
using boost::parameter::keyword;
|
||||
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
|
||||
#line 1878 "../../../../libs/parameter/doc/index.rst"
|
||||
#include <boost/parameter.hpp>
|
||||
#include <string>
|
||||
|
||||
namespace parameter = boost::parameter;
|
||||
#line 1861 "../../../../libs/parameter/doc/index.rst"
|
||||
BOOST_PARAMETER_NAME(s1)
|
||||
BOOST_PARAMETER_NAME(s2)
|
||||
BOOST_PARAMETER_NAME(s3)
|
||||
@@ -21,7 +19,6 @@ std::string f(ArgumentPack const& args)
|
||||
}
|
||||
|
||||
std::string x = f((_s1="hello,", _s2=" world", _s3="hi world"));
|
||||
#line 1884 "../../../../libs/parameter/doc/index.rst"
|
||||
int main()
|
||||
{}
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
|
||||
#line 1912 "../../../../libs/parameter/doc/index.rst"
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/ref.hpp>
|
||||
#include <boost/parameter.hpp>
|
||||
@@ -17,12 +16,10 @@ std::string f(ArgumentPack const& args)
|
||||
{
|
||||
std::string const& s1 = args[_s1];
|
||||
std::string const& s2 = args[_s2];
|
||||
#line 1905 "../../../../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 1930 "../../../../libs/parameter/doc/index.rst"
|
||||
return s3;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
|
||||
#line 2051 "../../../../libs/parameter/doc/index.rst"
|
||||
#line 2054 "../../../../libs/parameter/doc/index.rst"
|
||||
#include <boost/parameter.hpp>
|
||||
#include <iostream>
|
||||
#line 2040 "../../../../libs/parameter/doc/index.rst"
|
||||
namespace lib
|
||||
{
|
||||
BOOST_PARAMETER_NAME(name)
|
||||
@@ -18,8 +15,6 @@ namespace lib
|
||||
return index;
|
||||
}
|
||||
}
|
||||
#line 2067 "../../../../libs/parameter/doc/index.rst"
|
||||
int x = lib::f(lib::_name = "jill", lib::_index = 1);
|
||||
#line 2071 "../../../../libs/parameter/doc/index.rst"
|
||||
int main() {}
|
||||
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
|
||||
#line 2069 "../../../../libs/parameter/doc/index.rst"
|
||||
#line 2054 "../../../../libs/parameter/doc/index.rst"
|
||||
#include <boost/parameter.hpp>
|
||||
#include <iostream>
|
||||
#line 2040 "../../../../libs/parameter/doc/index.rst"
|
||||
namespace lib
|
||||
{
|
||||
BOOST_PARAMETER_NAME(name)
|
||||
@@ -18,11 +15,9 @@ namespace lib
|
||||
return index;
|
||||
}
|
||||
}
|
||||
#line 2080 "../../../../libs/parameter/doc/index.rst"
|
||||
using lib::_name;
|
||||
using lib::_index;
|
||||
|
||||
int x = lib::f(_name = "jill", _index = 1);
|
||||
#line 2089 "../../../../libs/parameter/doc/index.rst"
|
||||
int main() {}
|
||||
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
|
||||
#line 2083 "../../../../libs/parameter/doc/index.rst"
|
||||
#line 2054 "../../../../libs/parameter/doc/index.rst"
|
||||
#include <boost/parameter.hpp>
|
||||
#include <iostream>
|
||||
#line 2040 "../../../../libs/parameter/doc/index.rst"
|
||||
namespace lib
|
||||
{
|
||||
BOOST_PARAMETER_NAME(name)
|
||||
@@ -18,9 +15,7 @@ namespace lib
|
||||
return index;
|
||||
}
|
||||
}
|
||||
#line 2097 "../../../../libs/parameter/doc/index.rst"
|
||||
using namespace lib;
|
||||
int x = f(_name = "jill", _index = 3);
|
||||
#line 2103 "../../../../libs/parameter/doc/index.rst"
|
||||
int main() {}
|
||||
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
|
||||
#line 2130 "../../../../libs/parameter/doc/index.rst"
|
||||
#include <boost/parameter.hpp>
|
||||
#include <iostream>
|
||||
#line 2112 "../../../../libs/parameter/doc/index.rst"
|
||||
namespace lib
|
||||
{
|
||||
namespace keywords
|
||||
@@ -21,9 +19,7 @@ namespace lib
|
||||
}
|
||||
}
|
||||
|
||||
#line 2139 "../../../../libs/parameter/doc/index.rst"
|
||||
using namespace lib::keywords;
|
||||
int y = lib::f(_name = "bob", _index = 2);
|
||||
#line 2141 "../../../../libs/parameter/doc/index.rst"
|
||||
int main() {}
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
|
||||
#line 571 "../../../../libs/parameter/doc/index.rst"
|
||||
#include <boost/parameter.hpp>
|
||||
|
||||
namespace boost
|
||||
@@ -19,13 +18,11 @@ BOOST_PARAMETER_NAME(color_map)
|
||||
|
||||
BOOST_PARAMETER_FUNCTION((void), f, tag,
|
||||
(required (graph, *))
|
||||
#line 563 "../../../../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 "../../../../libs/parameter/doc/index.rst"
|
||||
) {}
|
||||
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
|
||||
#line 1215 "../../../../libs/parameter/doc/index.rst"
|
||||
#include <boost/parameter.hpp>
|
||||
#include <iostream>
|
||||
#line 1201 "../../../../libs/parameter/doc/index.rst"
|
||||
BOOST_PARAMETER_NAME(name)
|
||||
BOOST_PARAMETER_NAME(index)
|
||||
|
||||
@@ -17,7 +15,6 @@ struct myclass_impl
|
||||
}
|
||||
};
|
||||
|
||||
#line 1228 "../../../../libs/parameter/doc/index.rst"
|
||||
struct myclass : myclass_impl
|
||||
{
|
||||
BOOST_PARAMETER_CONSTRUCTOR(
|
||||
@@ -26,12 +23,9 @@ struct myclass : myclass_impl
|
||||
};
|
||||
|
||||
|
||||
#line 1242 "../../../../libs/parameter/doc/index.rst"
|
||||
int main() {
|
||||
#line 1239 "../../../../libs/parameter/doc/index.rst"
|
||||
myclass x("bob", 3); // positional
|
||||
myclass y(_index = 12, _name = "sally"); // named
|
||||
myclass z("june"); // positional/defaulted
|
||||
#line 1242 "../../../../libs/parameter/doc/index.rst"
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
|
||||
#line 1121 "../../../../libs/parameter/doc/index.rst"
|
||||
#include <boost/parameter.hpp>
|
||||
#include <iostream>
|
||||
using namespace boost::parameter;
|
||||
#line 1109 "../../../../libs/parameter/doc/index.rst"
|
||||
BOOST_PARAMETER_NAME(arg1)
|
||||
BOOST_PARAMETER_NAME(arg2)
|
||||
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
|
||||
#line 1144 "../../../../libs/parameter/doc/index.rst"
|
||||
#include <boost/parameter.hpp>
|
||||
|
||||
BOOST_PARAMETER_NAME(arg1)
|
||||
BOOST_PARAMETER_NAME(arg2)
|
||||
using namespace boost::parameter;
|
||||
#line 1133 "../../../../libs/parameter/doc/index.rst"
|
||||
struct callable2
|
||||
{
|
||||
BOOST_PARAMETER_CONST_MEMBER_FUNCTION(
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
|
||||
#line 903 "../../../../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)
|
||||
@@ -9,33 +10,44 @@ BOOST_PARAMETER_NAME((_index_map, graphs) index_map)
|
||||
BOOST_PARAMETER_NAME((_color_map, graphs) color_map)
|
||||
|
||||
using boost::mpl::_;
|
||||
// We first need to define a few metafunction that we use in the
|
||||
// predicates below.
|
||||
|
||||
namespace boost
|
||||
template <class G>
|
||||
struct traversal_category
|
||||
{
|
||||
struct incidence_graph_tag {};
|
||||
struct vertex_list_graph_tag {};
|
||||
typedef typename boost::graph_traits<G>::traversal_category type;
|
||||
};
|
||||
|
||||
int vertex_index = 0;
|
||||
template <class G>
|
||||
struct vertex_descriptor
|
||||
{
|
||||
typedef typename boost::graph_traits<G>::vertex_descriptor type;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct graph_traits
|
||||
{
|
||||
typedef int traversal_category;
|
||||
typedef int vertex_descriptor;
|
||||
};
|
||||
template <class G>
|
||||
struct value_type
|
||||
{
|
||||
typedef typename boost::property_traits<G>::value_type type;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct property_traits
|
||||
{
|
||||
typedef int value_type;
|
||||
typedef int key_type;
|
||||
};
|
||||
template <class G>
|
||||
struct key_type
|
||||
{
|
||||
typedef typename boost::property_traits<G>::key_type type;
|
||||
};
|
||||
|
||||
template <class T = int>
|
||||
struct dfs_visitor
|
||||
{};
|
||||
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];
|
||||
}
|
||||
#line 859 "../../../../libs/parameter/doc/index.rst"
|
||||
|
||||
BOOST_PARAMETER_FUNCTION(
|
||||
(void), depth_first_search, graphs
|
||||
|
||||
@@ -43,12 +55,10 @@ BOOST_PARAMETER_FUNCTION(
|
||||
(graph
|
||||
, *(boost::mpl::and_<
|
||||
boost::is_convertible<
|
||||
boost::graph_traits<_>::traversal_category
|
||||
, boost::incidence_graph_tag
|
||||
traversal_category<_>, boost::incidence_graph_tag
|
||||
>
|
||||
, boost::is_convertible<
|
||||
boost::graph_traits<_>::traversal_category
|
||||
, boost::vertex_list_graph_tag
|
||||
traversal_category<_>, boost::vertex_list_graph_tag
|
||||
>
|
||||
>) ))
|
||||
|
||||
@@ -56,29 +66,38 @@ BOOST_PARAMETER_FUNCTION(
|
||||
(visitor, *, boost::dfs_visitor<>()) // not checkable
|
||||
|
||||
(root_vertex
|
||||
, (typename boost::graph_traits<graphs::graph::_>::vertex_descriptor)
|
||||
, (vertex_descriptor<graphs::graph::_>)
|
||||
, *vertices(graph).first)
|
||||
|
||||
(index_map
|
||||
, *(boost::mpl::and_<
|
||||
boost::is_integral<
|
||||
boost::property_traits<_>::value_type
|
||||
>
|
||||
boost::is_integral<value_type<_> >
|
||||
, boost::is_same<
|
||||
typename boost::graph_traits<graphs::graph::_>::vertex_descriptor
|
||||
, boost::property_traits<_>::key_type
|
||||
vertex_descriptor<graphs::graph::_>, key_type<_>
|
||||
>
|
||||
>)
|
||||
, get(boost::vertex_index,graph))
|
||||
|
||||
(in_out(color_map)
|
||||
, *(boost::is_same<
|
||||
typename boost::graph_traits<graphs::graph::_>::vertex_descriptor
|
||||
, boost::property_traits<_>::key_type
|
||||
vertex_descriptor<graphs::graph::_>, key_type<_>
|
||||
>)
|
||||
, default_color_map(num_vertices(graph), index_map) )
|
||||
)
|
||||
)
|
||||
#line 940 "../../../../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);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
|
||||
#line 540 "../../../../libs/parameter/doc/index.rst"
|
||||
#include <boost/parameter.hpp>
|
||||
|
||||
BOOST_PARAMETER_NAME(graph)
|
||||
|
||||
BOOST_PARAMETER_FUNCTION((void), f, tag,
|
||||
#line 531 "../../../../libs/parameter/doc/index.rst"
|
||||
(required (graph, *) )
|
||||
#line 547 "../../../../libs/parameter/doc/index.rst"
|
||||
) {}
|
||||
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
|
||||
#line 1173 "../../../../libs/parameter/doc/index.rst"
|
||||
#include <boost/parameter.hpp>
|
||||
#include <iostream>
|
||||
using namespace boost::parameter;
|
||||
#line 1162 "../../../../libs/parameter/doc/index.rst"
|
||||
BOOST_PARAMETER_NAME(arg1)
|
||||
|
||||
struct somebody
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
|
||||
#line 1304 "../../../../libs/parameter/doc/index.rst"
|
||||
#include <boost/parameter.hpp>
|
||||
#line 1296 "../../../../libs/parameter/doc/index.rst"
|
||||
namespace boost { namespace python {
|
||||
|
||||
BOOST_PARAMETER_TEMPLATE_KEYWORD(class_type)
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
|
||||
#line 1320 "../../../../libs/parameter/doc/index.rst"
|
||||
#include <boost/parameter.hpp>
|
||||
#line 1311 "../../../../libs/parameter/doc/index.rst"
|
||||
namespace boost { namespace python {
|
||||
|
||||
namespace tag { struct class_type; } // keyword tag type
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
|
||||
#line 35 "../../../../libs/parameter/doc/index.rst"
|
||||
#include <boost/parameter.hpp>
|
||||
|
||||
namespace test
|
||||
@@ -31,7 +30,6 @@ namespace test
|
||||
}
|
||||
using namespace test;
|
||||
int x =
|
||||
#line 19
|
||||
new_window("alert", _width=10, _titlebar=false);
|
||||
|
||||
smart_ptr<
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
|
||||
#line 472 "../../../../libs/parameter/doc/index.rst"
|
||||
#include <boost/parameter/name.hpp>
|
||||
|
||||
BOOST_PARAMETER_NAME(graph)
|
||||
@@ -17,7 +16,6 @@ struct dfs_visitor
|
||||
int vertex_index = 0;
|
||||
|
||||
}
|
||||
#line 446 "../../../../libs/parameter/doc/index.rst"
|
||||
#include <boost/parameter/preprocessor.hpp>
|
||||
|
||||
namespace graphs
|
||||
|
||||
2
test/macros.cpp
Executable file → Normal file
2
test/macros.cpp
Executable file → Normal file
@@ -52,6 +52,6 @@ int main()
|
||||
, index = boost::ref(x), name = "foo"
|
||||
);
|
||||
|
||||
return 0;
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
|
||||
0
test/maybe.cpp
Executable file → Normal file
0
test/maybe.cpp
Executable file → Normal file
0
test/mpl.cpp
Executable file → Normal file
0
test/mpl.cpp
Executable file → Normal file
0
test/normalized_argument_types.cpp
Executable file → Normal file
0
test/normalized_argument_types.cpp
Executable file → Normal file
0
test/ntp.cpp
Executable file → Normal file
0
test/ntp.cpp
Executable file → Normal file
0
test/optional_deduced_sfinae.cpp
Executable file → Normal file
0
test/optional_deduced_sfinae.cpp
Executable file → Normal file
2
test/preprocessor.cpp
Executable file → Normal file
2
test/preprocessor.cpp
Executable file → Normal file
@@ -477,6 +477,6 @@ int main()
|
||||
, test::index = 2
|
||||
);
|
||||
|
||||
return 0;
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
|
||||
0
test/preprocessor_deduced.cpp
Executable file → Normal file
0
test/preprocessor_deduced.cpp
Executable file → Normal file
1
test/python_test.cpp
Executable file → Normal file
1
test/python_test.cpp
Executable file → Normal file
@@ -2,6 +2,7 @@
|
||||
// subject to the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <math.h>
|
||||
#include <boost/python.hpp>
|
||||
#include <boost/parameter/preprocessor.hpp>
|
||||
#include <boost/parameter/keyword.hpp>
|
||||
|
||||
0
test/sfinae.cpp
Executable file → Normal file
0
test/sfinae.cpp
Executable file → Normal file
0
test/singular.cpp
Executable file → Normal file
0
test/singular.cpp
Executable file → Normal file
0
test/timings.txt
Executable file → Normal file
0
test/timings.txt
Executable file → Normal file
0
test/tutorial.cpp
Executable file → Normal file
0
test/tutorial.cpp
Executable file → Normal file
0
test/unwrap_cv_reference.cpp
Executable file → Normal file
0
test/unwrap_cv_reference.cpp
Executable file → Normal file
Reference in New Issue
Block a user