mirror of
https://github.com/boostorg/parameter.git
synced 2026-01-19 16:32:13 +00:00
Compare commits
115 Commits
boost-1.34
...
svn-branch
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7981ef509c | ||
|
|
7689b5b9d0 | ||
|
|
a28883d9ad | ||
|
|
45bac7b579 | ||
|
|
e4e6ba52c4 | ||
|
|
6bb4b0ef8b | ||
|
|
e0416b8343 | ||
|
|
f8a1b652bc | ||
|
|
f7611b8a1f | ||
|
|
493a8b28a5 | ||
|
|
32ec272b6d | ||
|
|
4c8c0cce93 | ||
|
|
8fc7ba81cc | ||
|
|
5b2b1a47f8 | ||
|
|
f3764c539e | ||
|
|
b67fbdff8f | ||
|
|
0e263f5602 | ||
|
|
3c815b31fe | ||
|
|
dbbe37b8c1 | ||
|
|
ce712b8f30 | ||
|
|
913fa2eb44 | ||
|
|
12c873d3e4 | ||
|
|
164c48c018 | ||
|
|
2ac8833532 | ||
|
|
6556e278c6 | ||
|
|
1a9e89cb8d | ||
|
|
6d53a2b914 | ||
|
|
c7296b9a05 | ||
|
|
6a5d61ce3c | ||
|
|
e887f199e0 | ||
|
|
e7bd42b07a | ||
|
|
b9248d774f | ||
|
|
763a09c5aa | ||
|
|
07987bc97c | ||
|
|
b59c238a83 | ||
|
|
9dfa5a8d9e | ||
|
|
3d0bdf694c | ||
|
|
b5c6e05ea0 | ||
|
|
cc2a478afc | ||
|
|
1dab8a1008 | ||
|
|
4facdaafc3 | ||
|
|
5190f65321 | ||
|
|
0335832574 | ||
|
|
b9f287ea52 | ||
|
|
28f98ecbf0 | ||
|
|
4e8c8ced0f | ||
|
|
5baef32925 | ||
|
|
cc8ca29980 | ||
|
|
e2405e2d00 | ||
|
|
1cba9bd634 | ||
|
|
e58e928af4 | ||
|
|
c3e842fc4c | ||
|
|
ab57984c04 | ||
|
|
a8dc2bbd25 | ||
|
|
bb838edb2f | ||
|
|
74b777612e | ||
|
|
ea4457878c | ||
|
|
1f3fb08086 | ||
|
|
702ca6af6e | ||
|
|
225a38b68a | ||
|
|
de756246e7 | ||
|
|
de67d5fe6d | ||
|
|
40332972ca | ||
|
|
47292301e7 | ||
|
|
7a5a21dacc | ||
|
|
04aaeef41d | ||
|
|
5a0bad4224 | ||
|
|
07f167eed3 | ||
|
|
b34aa49ceb | ||
|
|
f5dbd06b32 | ||
|
|
9bcd7c2fec | ||
|
|
7f2abce0d4 | ||
|
|
b7036ee04f | ||
|
|
36d25230e6 | ||
|
|
d298a327b5 | ||
|
|
8162166037 | ||
|
|
dbcf8de808 | ||
|
|
07893af4c5 | ||
|
|
2070231553 | ||
|
|
5b1971f1ef | ||
|
|
988bb4b365 | ||
|
|
64bfddc3a7 | ||
|
|
2a0397c1b2 | ||
|
|
decd9ac9fd | ||
|
|
a181afc699 | ||
|
|
a6db5788f6 | ||
|
|
d37e7cd513 | ||
|
|
6dd64214c2 | ||
|
|
96d3e0fd07 | ||
|
|
ac398b0e50 | ||
|
|
3f1f0657f6 | ||
|
|
abae0c8d21 | ||
|
|
892a599999 | ||
|
|
acbf69fdb6 | ||
|
|
566e886887 | ||
|
|
ae05e30eac | ||
|
|
310998435c | ||
|
|
647265bfd3 | ||
|
|
76af708b1f | ||
|
|
deb606ef59 | ||
|
|
721b294842 | ||
|
|
f40418cf9a | ||
|
|
b12dbd9f6a | ||
|
|
6087feef11 | ||
|
|
e7d652f208 | ||
|
|
51c3dd4cb1 | ||
|
|
8cf35658bd | ||
|
|
ee2b252418 | ||
|
|
45d320a434 | ||
|
|
76067ad5d2 | ||
|
|
15b0729181 | ||
|
|
23d30d9ea6 | ||
|
|
012e0abd22 | ||
|
|
225ee5072e | ||
|
|
384add2571 |
@@ -95,81 +95,81 @@ or copy at <a class="reference" href="http://www.boost.org/LICENSE_1_0.txt">http
|
||||
<div class="contents topic">
|
||||
<p class="topic-title first"><a id="table-of-contents" name="table-of-contents"><strong>Table of Contents</strong></a></p>
|
||||
<ul class="auto-toc simple">
|
||||
<li><a class="reference" href="#motivation" id="id23" name="id23">1 Motivation</a><ul class="auto-toc">
|
||||
<li><a class="reference" href="#named-function-parameters" id="id24" name="id24">1.1 Named Function Parameters</a></li>
|
||||
<li><a class="reference" href="#deduced-function-parameters" id="id25" name="id25">1.2 Deduced Function Parameters</a></li>
|
||||
<li><a class="reference" href="#class-template-parameter-support" id="id26" name="id26">1.3 Class Template Parameter Support</a></li>
|
||||
<li><a class="reference" href="#motivation" id="id21" name="id21">1 Motivation</a><ul class="auto-toc">
|
||||
<li><a class="reference" href="#named-function-parameters" id="id22" name="id22">1.1 Named Function Parameters</a></li>
|
||||
<li><a class="reference" href="#deduced-function-parameters" id="id23" name="id23">1.2 Deduced Function Parameters</a></li>
|
||||
<li><a class="reference" href="#class-template-parameter-support" id="id24" name="id24">1.3 Class Template Parameter Support</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a class="reference" href="#tutorial" id="id27" name="id27">2 Tutorial</a><ul class="auto-toc">
|
||||
<li><a class="reference" href="#parameter-enabled-functions" id="id28" name="id28">2.1 Parameter-Enabled Functions</a><ul class="auto-toc">
|
||||
<li><a class="reference" href="#headers-and-namespaces" id="id29" name="id29">2.1.1 Headers And Namespaces</a></li>
|
||||
<li><a class="reference" href="#the-abstract-interface-to-dfs" id="id30" name="id30">2.1.2 The Abstract Interface to <tt class="docutils literal"><span class="pre">depth_first_search</span></tt></a></li>
|
||||
<li><a class="reference" href="#defining-the-keywords" id="id31" name="id31">2.1.3 Defining the Keywords</a></li>
|
||||
<li><a class="reference" href="#writing-the-function" id="id32" name="id32">2.1.4 Writing the Function</a></li>
|
||||
<li><a class="reference" href="#function-signatures" id="id33" name="id33">2.1.5 Function Signatures</a><ul class="auto-toc">
|
||||
<li><a class="reference" href="#required-parameters" id="id34" name="id34">2.1.5.1 Required Parameters</a></li>
|
||||
<li><a class="reference" href="#optional-parameters" id="id35" name="id35">2.1.5.2 Optional Parameters</a></li>
|
||||
<li><a class="reference" href="#handling-out-parameters" id="id36" name="id36">2.1.5.3 Handling “Out” Parameters</a></li>
|
||||
<li><a class="reference" href="#positional-arguments" id="id37" name="id37">2.1.5.4 Positional Arguments</a></li>
|
||||
<li><a class="reference" href="#default-expression-evaluation" id="id38" name="id38">2.1.5.5 Default Expression Evaluation</a></li>
|
||||
<li><a class="reference" href="#signature-matching-and-overloading" id="id39" name="id39">2.1.5.6 Signature Matching and Overloading</a><ul class="auto-toc">
|
||||
<li><a class="reference" href="#adding-type-requirements" id="id40" name="id40">2.1.5.6.1 Adding Type Requirements</a></li>
|
||||
<li><a class="reference" href="#predicate-requirements" id="id41" name="id41">2.1.5.6.2 Predicate Requirements</a></li>
|
||||
<li><a class="reference" href="#tutorial" id="id25" name="id25">2 Tutorial</a><ul class="auto-toc">
|
||||
<li><a class="reference" href="#parameter-enabled-functions" id="id26" name="id26">2.1 Parameter-Enabled Functions</a><ul class="auto-toc">
|
||||
<li><a class="reference" href="#headers-and-namespaces" id="id27" name="id27">2.1.1 Headers And Namespaces</a></li>
|
||||
<li><a class="reference" href="#the-abstract-interface-to-dfs" id="id28" name="id28">2.1.2 The Abstract Interface to <tt class="docutils literal"><span class="pre">depth_first_search</span></tt></a></li>
|
||||
<li><a class="reference" href="#defining-the-keywords" id="id29" name="id29">2.1.3 Defining the Keywords</a></li>
|
||||
<li><a class="reference" href="#writing-the-function" id="id30" name="id30">2.1.4 Writing the Function</a></li>
|
||||
<li><a class="reference" href="#function-signatures" id="id31" name="id31">2.1.5 Function Signatures</a><ul class="auto-toc">
|
||||
<li><a class="reference" href="#required-parameters" id="id32" name="id32">2.1.5.1 Required Parameters</a></li>
|
||||
<li><a class="reference" href="#optional-parameters" id="id33" name="id33">2.1.5.2 Optional Parameters</a></li>
|
||||
<li><a class="reference" href="#handling-out-parameters" id="id34" name="id34">2.1.5.3 Handling “Out” Parameters</a></li>
|
||||
<li><a class="reference" href="#positional-arguments" id="id35" name="id35">2.1.5.4 Positional Arguments</a></li>
|
||||
<li><a class="reference" href="#default-expression-evaluation" id="id36" name="id36">2.1.5.5 Default Expression Evaluation</a></li>
|
||||
<li><a class="reference" href="#signature-matching-and-overloading" id="id37" name="id37">2.1.5.6 Signature Matching and Overloading</a><ul class="auto-toc">
|
||||
<li><a class="reference" href="#adding-type-requirements" id="id38" name="id38">2.1.5.6.1 Adding Type Requirements</a></li>
|
||||
<li><a class="reference" href="#predicate-requirements" id="id39" name="id39">2.1.5.6.2 Predicate Requirements</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a class="reference" href="#deduced-parameters" id="id42" name="id42">2.1.5.7 Deduced Parameters</a></li>
|
||||
<li><a class="reference" href="#deduced-parameters" id="id40" name="id40">2.1.5.7 Deduced Parameters</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a class="reference" href="#parameter-enabled-member-functions" id="id43" name="id43">2.2 Parameter-Enabled Member Functions</a></li>
|
||||
<li><a class="reference" href="#parameter-enabled-constructors" id="id44" name="id44">2.3 Parameter-Enabled Constructors</a></li>
|
||||
<li><a class="reference" href="#parameter-enabled-class-templates" id="id45" name="id45">2.4 Parameter-Enabled Class Templates</a><ul class="auto-toc">
|
||||
<li><a class="reference" href="#named-template-parameters" id="id46" name="id46">2.4.1 Named Template Parameters</a><ul class="auto-toc">
|
||||
<li><a class="reference" href="#template-keywords" id="id47" name="id47">2.4.1.1 Template Keywords</a></li>
|
||||
<li><a class="reference" href="#class-template-skeleton" id="id48" name="id48">2.4.1.2 Class Template Skeleton</a></li>
|
||||
<li><a class="reference" href="#class-template-signatures" id="id49" name="id49">2.4.1.3 Class Template Signatures</a></li>
|
||||
<li><a class="reference" href="#argument-packs-and-parameter-extraction" id="id50" name="id50">2.4.1.4 Argument Packs and Parameter Extraction</a></li>
|
||||
<li><a class="reference" href="#parameter-enabled-member-functions" id="id41" name="id41">2.2 Parameter-Enabled Member Functions</a></li>
|
||||
<li><a class="reference" href="#parameter-enabled-constructors" id="id42" name="id42">2.3 Parameter-Enabled Constructors</a></li>
|
||||
<li><a class="reference" href="#parameter-enabled-class-templates" id="id43" name="id43">2.4 Parameter-Enabled Class Templates</a><ul class="auto-toc">
|
||||
<li><a class="reference" href="#named-template-parameters" id="id44" name="id44">2.4.1 Named Template Parameters</a><ul class="auto-toc">
|
||||
<li><a class="reference" href="#template-keywords" id="id45" name="id45">2.4.1.1 Template Keywords</a></li>
|
||||
<li><a class="reference" href="#class-template-skeleton" id="id46" name="id46">2.4.1.2 Class Template Skeleton</a></li>
|
||||
<li><a class="reference" href="#class-template-signatures" id="id47" name="id47">2.4.1.3 Class Template Signatures</a></li>
|
||||
<li><a class="reference" href="#argument-packs-and-parameter-extraction" id="id48" name="id48">2.4.1.4 Argument Packs and Parameter Extraction</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a class="reference" href="#exercising-the-code-so-far" id="id51" name="id51">2.4.2 Exercising the Code So Far</a></li>
|
||||
<li><a class="reference" href="#deduced-template-parameters" id="id52" name="id52">2.4.3 Deduced Template Parameters</a></li>
|
||||
<li><a class="reference" href="#exercising-the-code-so-far" id="id49" name="id49">2.4.2 Exercising the Code So Far</a></li>
|
||||
<li><a class="reference" href="#deduced-template-parameters" id="id50" name="id50">2.4.3 Deduced Template Parameters</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a class="reference" href="#advanced-topics" id="id53" name="id53">3 Advanced Topics</a><ul class="auto-toc">
|
||||
<li><a class="reference" href="#fine-grained-name-control" id="id54" name="id54">3.1 Fine-Grained Name Control</a></li>
|
||||
<li><a class="reference" href="#more-argumentpacks" id="id55" name="id55">3.2 More <span class="concept">ArgumentPack</span>s</a><ul class="auto-toc">
|
||||
<li><a class="reference" href="#building-argumentpacks" id="id56" name="id56">3.2.1 Building <span class="concept">ArgumentPack</span>s</a></li>
|
||||
<li><a class="reference" href="#extracting-parameter-types" id="id57" name="id57">3.2.2 Extracting Parameter Types</a></li>
|
||||
<li><a class="reference" href="#lazy-default-computation" id="id58" name="id58">3.2.3 Lazy Default Computation</a></li>
|
||||
<li><a class="reference" href="#advanced-topics" id="id51" name="id51">3 Advanced Topics</a><ul class="auto-toc">
|
||||
<li><a class="reference" href="#fine-grained-name-control" id="id52" name="id52">3.1 Fine-Grained Name Control</a></li>
|
||||
<li><a class="reference" href="#more-argumentpacks" id="id53" name="id53">3.2 More <span class="concept">ArgumentPack</span>s</a><ul class="auto-toc">
|
||||
<li><a class="reference" href="#building-argumentpacks" id="id54" name="id54">3.2.1 Building <span class="concept">ArgumentPack</span>s</a></li>
|
||||
<li><a class="reference" href="#extracting-parameter-types" id="id55" name="id55">3.2.2 Extracting Parameter Types</a></li>
|
||||
<li><a class="reference" href="#lazy-default-computation" id="id56" name="id56">3.2.3 Lazy Default Computation</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a class="reference" href="#best-practices" id="id59" name="id59">4 Best Practices</a><ul class="auto-toc">
|
||||
<li><a class="reference" href="#keyword-naming" id="id60" name="id60">4.1 Keyword Naming</a></li>
|
||||
<li><a class="reference" href="#namespaces" id="id61" name="id61">4.2 Namespaces</a></li>
|
||||
<li><a class="reference" href="#documentation" id="id62" name="id62">4.3 Documentation</a></li>
|
||||
<li><a class="reference" href="#best-practices" id="id57" name="id57">4 Best Practices</a><ul class="auto-toc">
|
||||
<li><a class="reference" href="#keyword-naming" id="id58" name="id58">4.1 Keyword Naming</a></li>
|
||||
<li><a class="reference" href="#namespaces" id="id59" name="id59">4.2 Namespaces</a></li>
|
||||
<li><a class="reference" href="#documentation" id="id60" name="id60">4.3 Documentation</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a class="reference" href="#portability-considerations" id="id63" name="id63">5 Portability Considerations</a><ul class="auto-toc">
|
||||
<li><a class="reference" href="#no-sfinae-support" id="id64" name="id64">5.1 No SFINAE Support</a></li>
|
||||
<li><a class="reference" href="#no-support-for-result-of" id="id65" name="id65">5.2 No Support for <tt class="docutils literal"><span class="pre">result_of</span></tt></a></li>
|
||||
<li><a class="reference" href="#compiler-can-t-see-references-in-unnamed-namespace" id="id66" name="id66">5.3 Compiler Can't See References In Unnamed Namespace</a></li>
|
||||
<li><a class="reference" href="#portability-considerations" id="id61" name="id61">5 Portability Considerations</a><ul class="auto-toc">
|
||||
<li><a class="reference" href="#no-sfinae-support" id="id62" name="id62">5.1 No SFINAE Support</a></li>
|
||||
<li><a class="reference" href="#no-support-for-result-of" id="id63" name="id63">5.2 No Support for <tt class="docutils literal"><span class="pre">result_of</span></tt></a></li>
|
||||
<li><a class="reference" href="#compiler-can-t-see-references-in-unnamed-namespace" id="id64" name="id64">5.3 Compiler Can't See References In Unnamed Namespace</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a class="reference" href="#python-binding" id="id67" name="id67">6 Python Binding</a></li>
|
||||
<li><a class="reference" href="#reference" id="id68" name="id68">7 Reference</a></li>
|
||||
<li><a class="reference" href="#glossary" id="id69" name="id69">8 Glossary</a></li>
|
||||
<li><a class="reference" href="#acknowledgements" id="id70" name="id70">9 Acknowledgements</a></li>
|
||||
<li><a class="reference" href="#python-binding" id="id65" name="id65">6 Python Binding</a></li>
|
||||
<li><a class="reference" href="#reference" id="id66" name="id66">7 Reference</a></li>
|
||||
<li><a class="reference" href="#glossary" id="id67" name="id67">8 Glossary</a></li>
|
||||
<li><a class="reference" href="#acknowledgements" id="id68" name="id68">9 Acknowledgements</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<hr class="docutils" />
|
||||
<div class="section">
|
||||
<h1><a class="toc-backref" href="#id23" id="motivation" name="motivation">1 Motivation</a></h1>
|
||||
<h1><a class="toc-backref" href="#id21" id="motivation" name="motivation">1 Motivation</a></h1>
|
||||
<p>In C++, <a class="reference" href="#arguments">arguments</a> are normally given meaning by their positions
|
||||
with respect to a <a class="reference" href="#parameter">parameter</a> list: the first argument passed maps
|
||||
onto the first parameter in a function's definition, and so on.
|
||||
@@ -219,7 +219,7 @@ arguments either, leading to hard-to-find bugs.</p>
|
||||
</ul>
|
||||
<!-- @ignore(3) -->
|
||||
<div class="section">
|
||||
<h2><a class="toc-backref" href="#id24" id="named-function-parameters" name="named-function-parameters">1.1 Named Function Parameters</a></h2>
|
||||
<h2><a class="toc-backref" href="#id22" id="named-function-parameters" name="named-function-parameters">1.1 Named Function Parameters</a></h2>
|
||||
<div class="compound">
|
||||
<p class="compound-first">This library addresses the problems outlined above by associating
|
||||
each parameter name with a keyword object. Now users can identify
|
||||
@@ -231,7 +231,7 @@ window* w = new_window("alert box", <strong>movable_=</strong>false);
|
||||
<!-- @ignore() -->
|
||||
</div>
|
||||
<div class="section">
|
||||
<h2><a class="toc-backref" href="#id25" id="deduced-function-parameters" name="deduced-function-parameters">1.2 Deduced Function Parameters</a></h2>
|
||||
<h2><a class="toc-backref" href="#id23" id="deduced-function-parameters" name="deduced-function-parameters">1.2 Deduced Function Parameters</a></h2>
|
||||
<div class="compound">
|
||||
<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
|
||||
@@ -252,7 +252,7 @@ names.</p>
|
||||
<!-- @ignore() -->
|
||||
</div>
|
||||
<div class="section">
|
||||
<h2><a class="toc-backref" href="#id26" id="class-template-parameter-support" name="class-template-parameter-support">1.3 Class Template Parameter Support</a></h2>
|
||||
<h2><a class="toc-backref" href="#id24" id="class-template-parameter-support" name="class-template-parameter-support">1.3 Class Template Parameter Support</a></h2>
|
||||
<div class="compound">
|
||||
<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
|
||||
@@ -278,12 +278,12 @@ smart_ptr<<strong>Client</strong>, <strong>shared</strong>> q;
|
||||
</div>
|
||||
</div>
|
||||
<div class="section">
|
||||
<h1><a class="toc-backref" href="#id27" id="tutorial" name="tutorial">2 Tutorial</a></h1>
|
||||
<h1><a class="toc-backref" href="#id25" id="tutorial" name="tutorial">2 Tutorial</a></h1>
|
||||
<p>This tutorial shows all the basics—how to build both named- and deduced-parameter
|
||||
interfaces to function templates and class templates—and several
|
||||
more advanced idioms as well.</p>
|
||||
<div class="section">
|
||||
<h2><a class="toc-backref" href="#id28" id="parameter-enabled-functions" name="parameter-enabled-functions">2.1 Parameter-Enabled Functions</a></h2>
|
||||
<h2><a class="toc-backref" href="#id26" id="parameter-enabled-functions" name="parameter-enabled-functions">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" href="../../../graph/index.html">Boost Graph library</a>'s
|
||||
<a class="reference" 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="id2" name="id2"><sup>1</sup></a></p>
|
||||
@@ -298,7 +298,7 @@ streamline the implementation of named parameter interfaces,
|
||||
improve their participation in overload resolution, and optimize
|
||||
their runtime efficiency. -->
|
||||
<div class="section">
|
||||
<h3><a class="toc-backref" href="#id29" id="headers-and-namespaces" name="headers-and-namespaces">2.1.1 Headers And Namespaces</a></h3>
|
||||
<h3><a class="toc-backref" href="#id27" id="headers-and-namespaces" name="headers-and-namespaces">2.1.1 Headers And Namespaces</a></h3>
|
||||
<p>Most components of the Parameter library are declared in a
|
||||
header named for the component. For example,</p>
|
||||
<pre class="literal-block">
|
||||
@@ -324,7 +324,7 @@ namespace parameter = boost::parameter;
|
||||
<tt class="docutils literal"><span class="pre">boost::parameter::xxx</span></tt>.</p>
|
||||
</div>
|
||||
<div class="section">
|
||||
<h3><a class="toc-backref" href="#id30" id="the-abstract-interface-to-dfs" name="the-abstract-interface-to-dfs">2.1.2 The Abstract Interface to <tt class="docutils literal"><span class="pre">depth_first_search</span></tt></a></h3>
|
||||
<h3><a class="toc-backref" href="#id28" id="the-abstract-interface-to-dfs" name="the-abstract-interface-to-dfs">2.1.2 The Abstract Interface to <tt class="docutils literal"><span class="pre">depth_first_search</span></tt></a></h3>
|
||||
<p>The Graph library's <tt class="docutils literal"><span class="pre">depth_first_search</span></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>
|
||||
@@ -342,7 +342,7 @@ void depth_first_search(
|
||||
<!-- @ignore() -->
|
||||
<p>However, most of the parameters have a useful default value, as
|
||||
shown in the table below.</p>
|
||||
<table border="1" class="docutils table" id="default-expressions">
|
||||
<table border="1" class="docutils" id="default-expressions">
|
||||
<span id="parameter-table"></span><caption><a id="default-expressions" name="default-expressions"><span id="parameter-table"></span><tt class="docutils literal"><span class="pre">depth_first_search</span></tt> Parameters</a></caption>
|
||||
<colgroup>
|
||||
<col width="17%" />
|
||||
@@ -401,7 +401,7 @@ columns above. For the purposes of this exercise, you don't need
|
||||
to understand them in detail.</p>
|
||||
</div>
|
||||
<div class="section">
|
||||
<h3><a class="toc-backref" href="#id31" id="defining-the-keywords" name="defining-the-keywords">2.1.3 Defining the Keywords</a></h3>
|
||||
<h3><a class="toc-backref" href="#id29" id="defining-the-keywords" name="defining-the-keywords">2.1.3 Defining the Keywords</a></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
|
||||
arguments for which the default is appropriate:</p>
|
||||
@@ -462,7 +462,7 @@ templates that are instantiated in multiple translation
|
||||
units (MSVC6.x users see <a class="reference" href="#compiler-can-t-see-references-in-unnamed-namespace">this note</a>).</p>
|
||||
</div>
|
||||
<div class="section">
|
||||
<h3><a class="toc-backref" href="#id32" id="writing-the-function" name="writing-the-function">2.1.4 Writing the Function</a></h3>
|
||||
<h3><a class="toc-backref" href="#id30" id="writing-the-function" name="writing-the-function">2.1.4 Writing the Function</a></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>
|
||||
@@ -524,7 +524,7 @@ match the function's parameter names.</li>
|
||||
</ol>
|
||||
</div>
|
||||
<div class="section">
|
||||
<h3><a class="toc-backref" href="#id33" id="function-signatures" name="function-signatures">2.1.5 Function Signatures</a></h3>
|
||||
<h3><a class="toc-backref" href="#id31" id="function-signatures" name="function-signatures">2.1.5 Function Signatures</a></h3>
|
||||
<p>Function signatures are described as one or two adjacent
|
||||
parenthesized terms (a <a class="reference" href="../../../preprocessor/index.html">Boost.Preprocessor</a> <a class="reference" 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
|
||||
@@ -532,7 +532,7 @@ 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
|
||||
parameters are optional.</p>
|
||||
<div class="section">
|
||||
<h4><a class="toc-backref" href="#id34" id="required-parameters" name="required-parameters">2.1.5.1 Required Parameters</a></h4>
|
||||
<h4><a class="toc-backref" href="#id32" id="required-parameters" name="required-parameters">2.1.5.1 Required Parameters</a></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>
|
||||
clause—as a series of two-element tuples describing each parameter
|
||||
@@ -560,14 +560,15 @@ BOOST_PARAMETER_FUNCTION((void), f, tag,
|
||||
<!-- @test('compile') -->
|
||||
</div>
|
||||
<div class="section">
|
||||
<h4><a class="toc-backref" href="#id35" id="optional-parameters" name="optional-parameters">2.1.5.2 Optional Parameters</a></h4>
|
||||
<h4><a class="toc-backref" href="#id33" id="optional-parameters" name="optional-parameters">2.1.5.2 Optional Parameters</a></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
|
||||
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>
|
||||
<pre class="compound-last literal-block">
|
||||
(optional <strong> (visitor, *, boost::dfs_visitor<>())
|
||||
(optional
|
||||
<strong>(visitor, *, boost::dfs_visitor<>())
|
||||
(root_vertex, *, *vertices(graph).first)
|
||||
(index_map, *, get(boost::vertex_index,graph))
|
||||
(in_out(color_map), *,
|
||||
@@ -600,7 +601,7 @@ BOOST_PARAMETER_FUNCTION((void), f, tag,
|
||||
<!-- @test('compile') -->
|
||||
</div>
|
||||
<div class="section">
|
||||
<h4><a class="toc-backref" href="#id36" id="handling-out-parameters" name="handling-out-parameters">2.1.5.3 Handling “Out” Parameters</a></h4>
|
||||
<h4><a class="toc-backref" href="#id34" id="handling-out-parameters" name="handling-out-parameters">2.1.5.3 Handling “Out” Parameters</a></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
|
||||
a <em>C++ reference</em>, bound either to an actual argument passed by
|
||||
@@ -612,9 +613,9 @@ indicate that <tt class="docutils literal"><span class="pre">color_map</span></t
|
||||
its name in <tt class="docutils literal"><span class="pre">in_out(…)</span></tt>:</p>
|
||||
<pre class="compound-last literal-block">
|
||||
(optional
|
||||
(visitor, *, boost::dfs_visitor<>())
|
||||
(root_vertex, *, *vertices(graph).first)
|
||||
(index_map, *, get(boost::vertex_index,graph))
|
||||
(visitor, *, boost::dfs_visitor<>())
|
||||
(root_vertex, *, *vertices(graph).first)
|
||||
(index_map, *, get(boost::vertex_index,graph))
|
||||
(<strong>in_out(color_map)</strong>, *,
|
||||
default_color_map(num_vertices(graph), index_map) )
|
||||
)
|
||||
@@ -650,7 +651,7 @@ difference between <tt class="docutils literal"><span class="pre">out</span></tt
|
||||
both so you can make your interfaces more self-documenting.</p>
|
||||
</div>
|
||||
<div class="section">
|
||||
<h4><a class="toc-backref" href="#id37" id="positional-arguments" name="positional-arguments">2.1.5.4 Positional Arguments</a></h4>
|
||||
<h4><a class="toc-backref" href="#id35" id="positional-arguments" name="positional-arguments">2.1.5.4 Positional Arguments</a></h4>
|
||||
<p>When arguments are passed positionally (without the use of
|
||||
keywords), they will be mapped onto parameters in the order the
|
||||
parameters are given in the signature, so for example in this
|
||||
@@ -663,7 +664,7 @@ graphs::depth_first_search(x, y);
|
||||
be interpreted as a visitor.</p>
|
||||
</div>
|
||||
<div class="section">
|
||||
<h4><a class="toc-backref" href="#id38" id="default-expression-evaluation" name="default-expression-evaluation">2.1.5.5 Default Expression Evaluation</a></h4>
|
||||
<h4><a class="toc-backref" href="#id36" id="default-expression-evaluation" name="default-expression-evaluation">2.1.5.5 Default Expression Evaluation</a></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>,
|
||||
@@ -737,7 +738,7 @@ BOOST_PARAMETER_NAME(color_map)''') -->
|
||||
<!-- @test('compile') -->
|
||||
</div>
|
||||
<div class="section">
|
||||
<h4><a class="toc-backref" href="#id39" id="signature-matching-and-overloading" name="signature-matching-and-overloading">2.1.5.6 Signature Matching and Overloading</a></h4>
|
||||
<h4><a class="toc-backref" href="#id37" id="signature-matching-and-overloading" name="signature-matching-and-overloading">2.1.5.6 Signature Matching and Overloading</a></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
|
||||
our function, provided we pass <em>something</em> for the required
|
||||
@@ -765,7 +766,7 @@ signatures have been the subject of much discussion, especially
|
||||
in the presence of <a class="reference" href="http://anubis.dkuug.dk/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
|
||||
types<a class="footnote-reference" href="#using" id="id7" name="id7"><sup>7</sup></a>, but suppose we <em>want</em> it to found via ADL?</li>
|
||||
types<a class="footnote-reference" href="#using" id="id7" name="id7"><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
|
||||
@@ -791,7 +792,7 @@ depth_first_search(boost::adjacency_list<>(), 2, "hello");
|
||||
</pre>
|
||||
<!-- @ignore() -->
|
||||
<div class="section">
|
||||
<h5><a class="toc-backref" href="#id40" id="adding-type-requirements" name="adding-type-requirements">2.1.5.6.1 Adding Type Requirements</a></h5>
|
||||
<h5><a class="toc-backref" href="#id38" id="adding-type-requirements" name="adding-type-requirements">2.1.5.6.1 Adding Type Requirements</a></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" href="#parameter-table">requirement</a> that it match the
|
||||
@@ -818,7 +819,7 @@ general, to access the type of any parameter <em>foo</em>, write <em>foo</em><tt
|
||||
</div>
|
||||
</div>
|
||||
<div class="section">
|
||||
<h5><a class="toc-backref" href="#id41" id="predicate-requirements" name="predicate-requirements">2.1.5.6.2 Predicate Requirements</a></h5>
|
||||
<h5><a class="toc-backref" href="#id39" id="predicate-requirements" name="predicate-requirements">2.1.5.6.2 Predicate Requirements</a></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
|
||||
type matching. Instead, they must be described in terms of <a class="reference" href="../../../mpl/doc/refmanual/metafunction.html">MPL
|
||||
@@ -921,7 +922,7 @@ with <a class="reference" href="http://www.generic-programming.org/software/Conc
|
||||
</div>
|
||||
</div>
|
||||
<div class="section">
|
||||
<h4><a class="toc-backref" href="#id42" id="deduced-parameters" name="deduced-parameters">2.1.5.7 Deduced Parameters</a></h4>
|
||||
<h4><a class="toc-backref" href="#id40" id="deduced-parameters" name="deduced-parameters">2.1.5.7 Deduced Parameters</a></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" href="../../../python/doc/v2/def.html"><tt class="docutils literal"><span class="pre">def</span></tt></a> function from <a class="reference" href="../../../python/doc/index.html">Boost.Python</a>. Its signature is
|
||||
@@ -966,14 +967,14 @@ BOOST_PARAMETER_FUNCTION(
|
||||
(docstring, (char const*), "")
|
||||
|
||||
(keywords
|
||||
, *(is_keyword_expression<mpl::_>) // see<a class="footnote-reference" href="#is-keyword-expression" id="id12" name="id12"><sup>6</sup></a>
|
||||
, *(is_keyword_expression<mpl::_>) // see<a class="footnote-reference" href="#is-keyword-expression" id="id12" name="id12"><sup>5</sup></a>
|
||||
, no_keywords())
|
||||
|
||||
(policies
|
||||
, *(mpl::not_<
|
||||
mpl::or_<
|
||||
boost::is_convertible<mpl::_, char const*>
|
||||
, is_keyword_expression<mpl::_> // see<a class="footnote-reference" href="#is-keyword-expression" id="id13" name="id13"><sup>6</sup></a>
|
||||
, is_keyword_expression<mpl::_> // see<a class="footnote-reference" href="#is-keyword-expression" id="id13" name="id13"><sup>5</sup></a>
|
||||
>
|
||||
>)
|
||||
, default_call_policies()
|
||||
@@ -1022,15 +1023,15 @@ 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"><span class="pre">(deduced …)</span></tt> clause always contains a ``(required …)``
|
||||
and/or an ``(optional …)`` subclause, and must follow any
|
||||
<tt class="docutils literal"><span class="pre">(required …)</span></tt> or ``(optional …)`` clauses indicating
|
||||
nondeduced parameters at the outer level.</p>
|
||||
</div>
|
||||
<p>With the declaration above, the following two calls are equivalent:</p>
|
||||
<pre class="literal-block">
|
||||
def("f", f, <strong>some_policies</strong>, <strong>"Documentation for f"</strong>);
|
||||
def("f", f, <strong>"Documentation for f"</strong>, <strong>some_policies</strong>);
|
||||
def("f", &f, <strong>some_policies</strong>, <strong>"Documentation for f"</strong>);
|
||||
def("f", &f, <strong>"Documentation for f"</strong>, <strong>some_policies</strong>);
|
||||
</pre>
|
||||
<!-- @example.prepend('''
|
||||
int main()
|
||||
@@ -1040,7 +1041,7 @@ for some reason, convertible to <tt class="docutils literal"><span class="pre">c
|
||||
specify the parameter name explicitly, as follows:</p>
|
||||
<pre class="literal-block">
|
||||
def(
|
||||
"f", f
|
||||
"f", &f
|
||||
, <strong>_policies = some_policies</strong>, "Documentation for f");
|
||||
</pre>
|
||||
<!-- @example.append('}') -->
|
||||
@@ -1049,7 +1050,7 @@ def(
|
||||
</div>
|
||||
</div>
|
||||
<div class="section">
|
||||
<h2><a class="toc-backref" href="#id43" id="parameter-enabled-member-functions" name="parameter-enabled-member-functions">2.2 Parameter-Enabled Member Functions</a></h2>
|
||||
<h2><a class="toc-backref" href="#id41" id="parameter-enabled-member-functions" name="parameter-enabled-member-functions">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
|
||||
@@ -1068,7 +1069,8 @@ struct callable2
|
||||
};
|
||||
</pre>
|
||||
<!-- @example.prepend('''
|
||||
#include <boost/parameter.hpp>''') -->
|
||||
#include <boost/parameter.hpp>
|
||||
#include <iostream>''') -->
|
||||
<!-- @test('compile') -->
|
||||
<p>These macros don't directly allow a function's interface to be
|
||||
separated from its implementation, but you can always forward
|
||||
@@ -1093,7 +1095,7 @@ BOOST_PARAMETER_NAME(arg2)''') -->
|
||||
<!-- @test('compile') -->
|
||||
</div>
|
||||
<div class="section">
|
||||
<h2><a class="toc-backref" href="#id44" id="parameter-enabled-constructors" name="parameter-enabled-constructors">2.3 Parameter-Enabled Constructors</a></h2>
|
||||
<h2><a class="toc-backref" href="#id42" id="parameter-enabled-constructors" name="parameter-enabled-constructors">2.3 Parameter-Enabled Constructors</a></h2>
|
||||
<p>The lack of a “delegating constructor”
|
||||
feature in C++
|
||||
(<a class="reference" href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n1986.pdf">http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n1986.pdf</a>)
|
||||
@@ -1154,7 +1156,7 @@ myclass z("june"); // positional/defaulted
|
||||
section.</p>
|
||||
</div>
|
||||
<div class="section">
|
||||
<h2><a class="toc-backref" href="#id45" id="parameter-enabled-class-templates" name="parameter-enabled-class-templates">2.4 Parameter-Enabled Class Templates</a></h2>
|
||||
<h2><a class="toc-backref" href="#id43" id="parameter-enabled-class-templates" name="parameter-enabled-class-templates">2.4 Parameter-Enabled Class Templates</a></h2>
|
||||
<p>In this section we'll use Boost.Parameter to build <a class="reference" href="../../../python/doc/index.html">Boost.Python</a>'s <a class="reference" href="http://www.boost.org/libs/python/doc/v2/class.html#class_-spec">class_</a> template, whose “signature” is:</p>
|
||||
<pre class="literal-block">
|
||||
template class<
|
||||
@@ -1166,7 +1168,7 @@ class class_;
|
||||
<!-- @ignore() -->
|
||||
<p>Only the first argument, <tt class="docutils literal"><span class="pre">ValueType</span></tt>, is required.</p>
|
||||
<div class="section">
|
||||
<h3><a class="toc-backref" href="#id46" id="named-template-parameters" name="named-template-parameters">2.4.1 Named Template Parameters</a></h3>
|
||||
<h3><a class="toc-backref" href="#id44" id="named-template-parameters" name="named-template-parameters">2.4.1 Named Template Parameters</a></h3>
|
||||
<p>First, we'll build an interface that allows users to pass arguments
|
||||
positionally or by name:</p>
|
||||
<pre class="literal-block">
|
||||
@@ -1183,7 +1185,7 @@ class_<
|
||||
</pre>
|
||||
<!-- @ignore() -->
|
||||
<div class="section">
|
||||
<h4><a class="toc-backref" href="#id47" id="template-keywords" name="template-keywords">2.4.1.1 Template Keywords</a></h4>
|
||||
<h4><a class="toc-backref" href="#id45" id="template-keywords" name="template-keywords">2.4.1.1 Template Keywords</a></h4>
|
||||
<p>The first step is to define keywords for each template parameter:</p>
|
||||
<pre class="literal-block">
|
||||
namespace boost { namespace python {
|
||||
@@ -1216,7 +1218,7 @@ struct class_type
|
||||
<em>parameter passing template</em> named <tt class="docutils literal"><span class="pre">class_type</span></tt>.</p>
|
||||
</div>
|
||||
<div class="section">
|
||||
<h4><a class="toc-backref" href="#id48" id="class-template-skeleton" name="class-template-skeleton">2.4.1.2 Class Template Skeleton</a></h4>
|
||||
<h4><a class="toc-backref" href="#id46" id="class-template-skeleton" name="class-template-skeleton">2.4.1.2 Class Template Skeleton</a></h4>
|
||||
<p>The next step is to define the skeleton of our class template,
|
||||
which has three optional parameters. Because the user may pass
|
||||
arguments in any order, we don't know the actual identities of
|
||||
@@ -1245,7 +1247,7 @@ struct class_
|
||||
<!-- @test('compile') -->
|
||||
</div>
|
||||
<div class="section">
|
||||
<h4><a class="toc-backref" href="#id49" id="class-template-signatures" name="class-template-signatures">2.4.1.3 Class Template Signatures</a></h4>
|
||||
<h4><a class="toc-backref" href="#id47" id="class-template-signatures" name="class-template-signatures">2.4.1.3 Class Template Signatures</a></h4>
|
||||
<p>Next, we need to build a type, known as a <a class="reference" href="reference.html#parameterspec"><span class="concept">ParameterSpec</span></a>,
|
||||
describing the “signature” of <tt class="docutils literal"><span class="pre">boost::python::class_</span></tt>. A
|
||||
<a class="reference" href="reference.html#parameterspec"><span class="concept">ParameterSpec</span></a> enumerates the required and optional parameters in
|
||||
@@ -1288,7 +1290,7 @@ struct bases
|
||||
}}''') -->
|
||||
</div>
|
||||
<div class="section">
|
||||
<h4><a class="toc-backref" href="#id50" id="argument-packs-and-parameter-extraction" name="argument-packs-and-parameter-extraction"><span id="binding-intro"></span>2.4.1.4 Argument Packs and Parameter Extraction</a></h4>
|
||||
<h4><a class="toc-backref" href="#id48" id="argument-packs-and-parameter-extraction" name="argument-packs-and-parameter-extraction"><span id="binding-intro"></span>2.4.1.4 Argument Packs and Parameter Extraction</a></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" href="reference.html#argumentpack"><span class="concept">ArgumentPack</span></a> type, and then use the library's <tt class="docutils literal"><span class="pre">binding<</span>
|
||||
<span class="pre">…</span> <span class="pre">></span></tt> metafunction to extract “logical parameters”. Note that
|
||||
@@ -1329,7 +1331,7 @@ struct class_
|
||||
</div>
|
||||
</div>
|
||||
<div class="section">
|
||||
<h3><a class="toc-backref" href="#id51" id="exercising-the-code-so-far" name="exercising-the-code-so-far">2.4.2 Exercising the Code So Far</a></h3>
|
||||
<h3><a class="toc-backref" href="#id49" id="exercising-the-code-so-far" name="exercising-the-code-so-far">2.4.2 Exercising the Code So Far</a></h3>
|
||||
<div class="compound">
|
||||
<p class="compound-first">Revisiting our original examples,</p>
|
||||
<pre class="compound-middle literal-block">
|
||||
@@ -1370,7 +1372,7 @@ BOOST_MPL_ASSERT((boost::is_same<c2::copyable, void>));
|
||||
<!-- @test('compile', howmany='all') -->
|
||||
</div>
|
||||
<div class="section">
|
||||
<h3><a class="toc-backref" href="#id52" id="deduced-template-parameters" name="deduced-template-parameters">2.4.3 Deduced Template Parameters</a></h3>
|
||||
<h3><a class="toc-backref" href="#id50" id="deduced-template-parameters" name="deduced-template-parameters">2.4.3 Deduced Template Parameters</a></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
|
||||
@@ -1497,11 +1499,11 @@ BOOST_MPL_ASSERT((boost::is_same<c2::copyable, void>));''') -->
|
||||
</div>
|
||||
</div>
|
||||
<div class="section">
|
||||
<h1><a class="toc-backref" href="#id53" id="advanced-topics" name="advanced-topics">3 Advanced Topics</a></h1>
|
||||
<h1><a class="toc-backref" href="#id51" id="advanced-topics" name="advanced-topics">3 Advanced Topics</a></h1>
|
||||
<p>At this point, you should have a good grasp of the basics. In this
|
||||
section we'll cover some more esoteric uses of the library.</p>
|
||||
<div class="section">
|
||||
<h2><a class="toc-backref" href="#id54" id="fine-grained-name-control" name="fine-grained-name-control">3.1 Fine-Grained Name Control</a></h2>
|
||||
<h2><a class="toc-backref" href="#id52" id="fine-grained-name-control" name="fine-grained-name-control">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
|
||||
something other than the keyword type namespace, there's another
|
||||
@@ -1532,14 +1534,14 @@ int main()
|
||||
section on <a class="reference" href="#keyword-naming">best practices for keyword object naming</a>.</p>
|
||||
</div>
|
||||
<div class="section">
|
||||
<h2><a class="toc-backref" href="#id55" id="more-argumentpacks" name="more-argumentpacks">3.2 More <span class="concept">ArgumentPack</span>s</a></h2>
|
||||
<h2><a class="toc-backref" href="#id53" id="more-argumentpacks" name="more-argumentpacks">3.2 More <span class="concept">ArgumentPack</span>s</a></h2>
|
||||
<p>We've already seen <span class="concept">ArgumentPack</span>s when we looked at
|
||||
<a class="reference" href="#parameter-enabled-constructors">parameter-enabled constructors</a> and <a class="reference" href="#binding-intro">class templates</a>. As you
|
||||
might have guessed, <span class="concept">ArgumentPack</span>s actually lie at the heart of
|
||||
everything this library does; in this section we'll examine ways to
|
||||
build and manipulate them more effectively.</p>
|
||||
<div class="section">
|
||||
<h3><a class="toc-backref" href="#id56" id="building-argumentpacks" name="building-argumentpacks">3.2.1 Building <span class="concept">ArgumentPack</span>s</a></h3>
|
||||
<h3><a class="toc-backref" href="#id54" id="building-argumentpacks" name="building-argumentpacks">3.2.1 Building <span class="concept">ArgumentPack</span>s</a></h3>
|
||||
<p>The simplest <span class="concept">ArgumentPack</span> is the result of assigning into a
|
||||
keyword object:</p>
|
||||
<pre class="literal-block">
|
||||
@@ -1585,7 +1587,10 @@ parameter::parameters<
|
||||
, optional<tag::index, is_convertible<_,int> >
|
||||
> spec;
|
||||
|
||||
int z0 = print_name_and_index( <strong>spec(</strong>"sam", 12<strong>)</strong> );
|
||||
char const sam[] = "sam";
|
||||
int twelve = 12;
|
||||
|
||||
int z0 = print_name_and_index( <strong>spec(</strong>sam, twelve<strong>)</strong> );
|
||||
|
||||
int z1 = print_name_and_index(
|
||||
<strong>spec(</strong>_index=12, _name="sam"<strong>)</strong>
|
||||
@@ -1601,9 +1606,11 @@ using boost::mpl::_;''') -->
|
||||
int main()
|
||||
{}''') -->
|
||||
<!-- @test('run', howmany='all') -->
|
||||
<p>Note that because of the <a class="reference" 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>
|
||||
can't accept non-const rvalues.</p>
|
||||
</div>
|
||||
<div class="section">
|
||||
<h3><a class="toc-backref" href="#id57" id="extracting-parameter-types" name="extracting-parameter-types">3.2.2 Extracting Parameter Types</a></h3>
|
||||
<h3><a class="toc-backref" href="#id55" id="extracting-parameter-types" name="extracting-parameter-types">3.2.2 Extracting Parameter Types</a></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
|
||||
simplest and least error-prone approach is to forward them to a
|
||||
@@ -1648,7 +1655,9 @@ case we can use the <tt class="docutils literal"><span class="pre">binding<</
|
||||
BOOST_PARAMETER_NAME(index)
|
||||
|
||||
template <class ArgumentPack>
|
||||
typename parameter::binding<ArgumentPack, tag::index, int>::type
|
||||
typename remove_reference<
|
||||
typename parameter::binding<ArgumentPack, tag::index, int>::type
|
||||
>::type
|
||||
twice_index(ArgumentPack const& args)
|
||||
{
|
||||
return 2 * args[_index|42];
|
||||
@@ -1656,21 +1665,40 @@ twice_index(ArgumentPack const& args)
|
||||
|
||||
int six = twice_index(_index = 3);
|
||||
</pre>
|
||||
<!-- TODO: binding<> returns a reference. We should use value_type<> here. -->
|
||||
<!-- @example.prepend('''
|
||||
#include <boost/parameter.hpp>
|
||||
#include <boost/type_traits/remove_reference.hpp>
|
||||
#include <cassert>
|
||||
|
||||
namespace parameter = boost::parameter;''') -->
|
||||
namespace parameter = boost::parameter;
|
||||
using boost::remove_reference;''') -->
|
||||
<p>Note that the <tt class="docutils literal"><span class="pre">remove_reference<</span> <span class="pre">…</span> <span class="pre">></span></tt> dance is necessary because
|
||||
<tt class="docutils literal"><span class="pre">binding<</span> <span class="pre">…</span> <span class="pre">></span></tt> will return a reference type when the argument
|
||||
is bound in the argument pack. If we don't strip the reference we
|
||||
end up returning a reference to the temporary created in the <tt class="docutils literal"><span class="pre">2*…</span></tt>
|
||||
expression. A convenient shortcut would be to use the <tt class="docutils literal"><span class="pre">value_type<</span> <span class="pre">…</span> <span class="pre">></span></tt>
|
||||
metafunction:</p>
|
||||
<pre class="literal-block">
|
||||
template <class ArgumentPack>
|
||||
typename <strong>parameter::value_type<ArgumentPack, tag::index, int></strong>::type
|
||||
twice_index(ArgumentPack const& args)
|
||||
{
|
||||
return 2 * args[_index|42];
|
||||
}
|
||||
</pre>
|
||||
<!-- @example.wrap('namespace with_value_type {', '''
|
||||
int six = twice_index(_index = 3);
|
||||
}''') -->
|
||||
<!-- @example.append('''
|
||||
int main()
|
||||
{
|
||||
assert(six == 6);
|
||||
assert(with_value_type::six == 6);
|
||||
}''') -->
|
||||
<!-- @test('run') -->
|
||||
<!-- @test('run', howmany='all') -->
|
||||
</div>
|
||||
<div class="section">
|
||||
<h3><a class="toc-backref" href="#id58" id="lazy-default-computation" name="lazy-default-computation">3.2.3 Lazy Default Computation</a></h3>
|
||||
<h3><a class="toc-backref" href="#id56" id="lazy-default-computation" name="lazy-default-computation">3.2.3 Lazy Default Computation</a></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
|
||||
@@ -1706,19 +1734,27 @@ int main()
|
||||
<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
|
||||
remedy that, we can compute the default value <em>lazily</em> (that is,
|
||||
only on demand), by combining the logical-or (“``||``”) operator
|
||||
with a function object built by the Boost <a class="reference" href="../../../lambda/index.html">Lambda</a> library:<a class="footnote-reference" href="#bind" id="id17" name="id17"><sup>5</sup></a></p>
|
||||
only on demand), by using <tt class="docutils literal"><span class="pre">boost::bind()</span></tt> to create a function
|
||||
object.</p>
|
||||
<!-- danielw: I'm leaving the text below in the source, because we might -->
|
||||
<!-- want to change back to it after 1.34, and if I remove it now we -->
|
||||
<!-- might forget about it. -->
|
||||
<!-- by combining the logical-or (“``||``”) operator -->
|
||||
<!-- with a function object built by the Boost Lambda_ library: [#bind]_ -->
|
||||
<pre class="literal-block">
|
||||
namespace lambda = boost::lambda;
|
||||
using boost::bind;
|
||||
using boost::ref;
|
||||
|
||||
typename parameter::binding<
|
||||
ArgumentPack, tag::s3, std::string
|
||||
>::type s3 = args[_s3 <strong>|| (lambda::var(s1)+lambda::var(s2))</strong> ];
|
||||
>::type s3 = args[_s3 <strong>|| bind(std::plus<std::string>(), ref(s1), ref(s2))</strong> ];
|
||||
</pre>
|
||||
<!-- @example.prepend('''
|
||||
#include <boost/lambda/lambda.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/ref.hpp>
|
||||
#include <boost/parameter.hpp>
|
||||
#include <string>
|
||||
#include <functional>
|
||||
|
||||
namespace parameter = boost::parameter;
|
||||
|
||||
@@ -1740,6 +1776,7 @@ std::string x = f((_s1="hello,", _s2=" world", _s3="hi world"));
|
||||
int main()
|
||||
{}''') -->
|
||||
<!-- @test('run') -->
|
||||
<!-- .. _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
|
||||
@@ -1748,20 +1785,24 @@ argument is only evaluated if its first argument is <tt class="docutils literal"
|
||||
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>
|
||||
</div>
|
||||
<p>The expression <tt class="docutils literal"><span class="pre">lambda::var(s1)+lambda::var(s2)</span></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 the caller.</p>
|
||||
<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
|
||||
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
|
||||
the caller.</p>
|
||||
<!-- The expression ``lambda::var(s1)+lambda::var(s2)`` yields a -->
|
||||
<!-- *function object* that, when invoked, adds the two strings -->
|
||||
<!-- together. That function will only be invoked if no ``s3`` argument -->
|
||||
<!-- is supplied by the caller. -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section">
|
||||
<h1><a class="toc-backref" href="#id59" id="best-practices" name="best-practices">4 Best Practices</a></h1>
|
||||
<h1><a class="toc-backref" href="#id57" id="best-practices" name="best-practices">4 Best Practices</a></h1>
|
||||
<p>By now you should have a fairly good idea of how to use the
|
||||
Parameter library. This section points out a few more-marginal
|
||||
issues that will help you use the library more effectively.</p>
|
||||
<div class="section">
|
||||
<h2><a class="toc-backref" href="#id60" id="keyword-naming" name="keyword-naming">4.1 Keyword Naming</a></h2>
|
||||
<h2><a class="toc-backref" href="#id58" id="keyword-naming" name="keyword-naming">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
|
||||
of all our keyword objects in order to avoid the following
|
||||
usually-silent bug:</p>
|
||||
@@ -1814,7 +1855,7 @@ compiler—might become irretrievably ambiguous with those in our
|
||||
unnamed namespace.</p>
|
||||
</div>
|
||||
<div class="section">
|
||||
<h2><a class="toc-backref" href="#id61" id="namespaces" name="namespaces">4.2 Namespaces</a></h2>
|
||||
<h2><a class="toc-backref" href="#id59" id="namespaces" name="namespaces">4.2 Namespaces</a></h2>
|
||||
<p>In our examples we've always declared keyword objects in (an
|
||||
unnamed namespace within) the same namespace as the
|
||||
Boost.Parameter-enabled functions using those keywords:</p>
|
||||
@@ -1918,7 +1959,7 @@ int y = lib::f(_name = "bob", _index = 2);
|
||||
<!-- @test('run', howmany='all') -->
|
||||
</div>
|
||||
<div class="section">
|
||||
<h2><a class="toc-backref" href="#id62" id="documentation" name="documentation">4.3 Documentation</a></h2>
|
||||
<h2><a class="toc-backref" href="#id60" id="documentation" name="documentation">4.3 Documentation</a></h2>
|
||||
<p>The interface idioms enabled by Boost.Parameter are completely new
|
||||
(to C++), and as such are not served by pre-existing documentation
|
||||
conventions.</p>
|
||||
@@ -1932,13 +1973,13 @@ sharing.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section">
|
||||
<h1><a class="toc-backref" href="#id63" id="portability-considerations" name="portability-considerations">5 Portability Considerations</a></h1>
|
||||
<h1><a class="toc-backref" href="#id61" id="portability-considerations" name="portability-considerations">5 Portability Considerations</a></h1>
|
||||
<p>Use the <a class="reference" href="http://www.boost.org/regression/release/user/parameter.html">regression test results</a> for the latest Boost release of
|
||||
the Parameter library to see how it fares on your favorite
|
||||
compiler. Additionally, you may need to be aware of the following
|
||||
issues and workarounds for particular compilers.</p>
|
||||
<div class="section">
|
||||
<h2><a class="toc-backref" href="#id64" id="no-sfinae-support" name="no-sfinae-support">5.1 No SFINAE Support</a></h2>
|
||||
<h2><a class="toc-backref" href="#id62" id="no-sfinae-support" name="no-sfinae-support">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
|
||||
@@ -1986,7 +2027,7 @@ are unspecified, the workaround is to use
|
||||
.. |BOOST_PARAMETER_MATCH| replace:: ``BOOST_PARAMETER_MATCH`` -->
|
||||
</div>
|
||||
<div class="section">
|
||||
<h2><a class="toc-backref" href="#id66" id="compiler-can-t-see-references-in-unnamed-namespace" name="compiler-can-t-see-references-in-unnamed-namespace">5.3 Compiler Can't See References In Unnamed Namespace</a></h2>
|
||||
<h2><a class="toc-backref" href="#id64" id="compiler-can-t-see-references-in-unnamed-namespace" name="compiler-can-t-see-references-in-unnamed-namespace">5.3 Compiler Can't See References In Unnamed Namespace</a></h2>
|
||||
<p>If you use Microsoft Visual C++ 6.x, you may find that the compiler
|
||||
has trouble finding your keyword objects. This problem has been
|
||||
observed, but only on this one compiler, and it disappeared as the
|
||||
@@ -2007,17 +2048,17 @@ namespace graphs
|
||||
</div>
|
||||
</div>
|
||||
<div class="section">
|
||||
<h1><a class="toc-backref" href="#id67" id="python-binding" name="python-binding">6 Python Binding</a></h1>
|
||||
<h1><a class="toc-backref" href="#id65" id="python-binding" name="python-binding">6 Python Binding</a></h1>
|
||||
<p>Follow <a class="reference" href="python.html">this link</a> for documentation on how to expose
|
||||
Boost.Parameter-enabled functions to Python with <a class="reference" href="../../../python/doc/index.html">Boost.Python</a>.</p>
|
||||
</div>
|
||||
<div class="section">
|
||||
<h1><a class="toc-backref" href="#id68" id="reference" name="reference">7 Reference</a></h1>
|
||||
<h1><a class="toc-backref" href="#id66" id="reference" name="reference">7 Reference</a></h1>
|
||||
<p>Follow <a class="reference" href="reference.html">this link</a> to the Boost.Parameter reference
|
||||
documentation.</p>
|
||||
</div>
|
||||
<div class="section">
|
||||
<h1><a class="toc-backref" href="#id69" id="glossary" name="glossary">8 Glossary</a></h1>
|
||||
<h1><a class="toc-backref" href="#id67" id="glossary" name="glossary">8 Glossary</a></h1>
|
||||
<table class="docutils field-list" frame="void" id="arguments" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
@@ -2047,7 +2088,7 @@ int y = f(3);
|
||||
</table>
|
||||
</div>
|
||||
<div class="section">
|
||||
<h1><a class="toc-backref" href="#id70" id="acknowledgements" name="acknowledgements">9 Acknowledgements</a></h1>
|
||||
<h1><a class="toc-backref" href="#id68" id="acknowledgements" name="acknowledgements">9 Acknowledgements</a></h1>
|
||||
<p>The authors would like to thank all the Boosters who participated
|
||||
in the review of this library and its documentation, most
|
||||
especially our review manager, Doug Gregor.</p>
|
||||
@@ -2087,30 +2128,23 @@ library wouldn't suffer.</td></tr>
|
||||
<tr><td class="label"><a class="fn-backref" href="#id6" name="conceptcpp">[4]</a></td><td>This is a major motivation behind <a class="reference" href="http://www.generic-programming.org/software/ConceptGCC/">ConceptC++</a>.</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<table class="docutils footnote" frame="void" id="bind" rules="none">
|
||||
<colgroup><col class="label" /><col /></colgroup>
|
||||
<tbody valign="top">
|
||||
<tr><td class="label"><a class="fn-backref" href="#id17" name="bind">[5]</a></td><td><p class="first">The Lambda library is known not to work on <a class="reference" href="http://www.boost.org/regression/release/user/lambda.html">some
|
||||
less-conformant compilers</a>. When using one of those you could
|
||||
use <a class="reference" href="../../../bind/index.html">Boost.Bind</a> to generate the function object:</p>
|
||||
<pre class="last literal-block">
|
||||
boost::bind(std::plus<std::string>(),s1,s2)
|
||||
</pre>
|
||||
</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<!-- .. [#bind] The Lambda library is known not to work on `some -->
|
||||
<!-- less-conformant compilers`__. When using one of those you could -->
|
||||
<!-- use `Boost.Bind`_ to generate the function object:: -->
|
||||
<!-- boost::bind(std::plus<std::string>(),s1,s2) -->
|
||||
<table class="docutils footnote" frame="void" id="is-keyword-expression" rules="none">
|
||||
<colgroup><col class="label" /><col /></colgroup>
|
||||
<tbody valign="top">
|
||||
<tr><td class="label"><a name="is-keyword-expression">[6]</a></td><td><em>(<a class="fn-backref" href="#id12">1</a>, <a class="fn-backref" href="#id13">2</a>)</em> Here we're assuming there's a predicate
|
||||
<tr><td class="label"><a name="is-keyword-expression">[5]</a></td><td><em>(<a class="fn-backref" href="#id12">1</a>, <a class="fn-backref" href="#id13">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
|
||||
identify models of Boost.Python's KeywordExpression concept.</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<!-- .. __ http://www.boost.org/regression/release/user/lambda.html -->
|
||||
<table class="docutils footnote" frame="void" id="using" rules="none">
|
||||
<colgroup><col class="label" /><col /></colgroup>
|
||||
<tbody valign="top">
|
||||
<tr><td class="label"><a class="fn-backref" href="#id7" name="using">[7]</a></td><td><p class="first">You can always give the illusion that the function
|
||||
<tr><td class="label"><a class="fn-backref" href="#id7" name="using">[6]</a></td><td><p class="first">You can always give the illusion that the function
|
||||
lives in an outer namespace by applying a <em>using-declaration</em>:</p>
|
||||
<pre class="last literal-block">
|
||||
namespace foo_overloads
|
||||
@@ -2130,9 +2164,9 @@ lookup is due to Herb Sutter.
|
||||
<table class="docutils footnote" frame="void" id="sfinae" rules="none">
|
||||
<colgroup><col class="label" /><col /></colgroup>
|
||||
<tbody valign="top">
|
||||
<tr><td class="label"><a name="sfinae">[8]</a></td><td>This capability depends on your compiler's support for SFINAE.
|
||||
<tr><td class="label"><a name="sfinae">[7]</a></td><td>This capability depends on your compiler's support for SFINAE.
|
||||
<strong>SFINAE</strong>: <strong>S</strong>ubstitution <strong>F</strong>ailure <strong>I</strong>s
|
||||
<strong>N</strong>ot <strong>A</strong>n <strong>E</strong> rror. If type substitution during the
|
||||
<strong>N</strong>ot <strong>A</strong>n <strong>E</strong>rror. If type substitution during the
|
||||
instantiation of a function template results in an invalid type,
|
||||
no compilation error is emitted; instead the overload is removed
|
||||
from the overload set. By producing an invalid type in the
|
||||
@@ -2151,7 +2185,7 @@ information on SFINAE.</td></tr>
|
||||
</div>
|
||||
<div class="footer">
|
||||
<hr class="footer" />
|
||||
Generated on: 2007-01-03 17:02 UTC.
|
||||
Generated on: 2007-05-03 14:12 UTC.
|
||||
Generated by <a class="reference" href="http://docutils.sourceforge.net/">Docutils</a> from <a class="reference" href="http://docutils.sourceforge.net/rst.html">reStructuredText</a> source.
|
||||
|
||||
</div>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<title>The Boost Parameter Library Python Binding Documentation</title>
|
||||
<meta name="authors" content="Daniel Wallin" />
|
||||
<meta name="organization" content="Boost Consulting" />
|
||||
<meta name="date" content="2006-09-21" />
|
||||
<meta name="date" content="2006-12-14" />
|
||||
<meta name="copyright" content="Copyright David Abrahams, Daniel Wallin 2005. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)" />
|
||||
<link rel="stylesheet" href="rst.css" type="text/css" />
|
||||
</head>
|
||||
@@ -25,7 +25,7 @@
|
||||
<tr><th class="docinfo-name">Organization:</th>
|
||||
<td><a class="first last reference" href="http://www.boost-consulting.com">Boost Consulting</a></td></tr>
|
||||
<tr><th class="docinfo-name">Date:</th>
|
||||
<td>2006-09-21</td></tr>
|
||||
<td>2006-12-14</td></tr>
|
||||
<tr><th class="docinfo-name">Copyright:</th>
|
||||
<td>Copyright David Abrahams, Daniel Wallin
|
||||
2005. Distributed under the Boost Software License,
|
||||
@@ -42,19 +42,19 @@ functions, operators and constructors to Python.</p>
|
||||
<div class="contents topic">
|
||||
<p class="topic-title first"><a id="contents" name="contents">Contents</a></p>
|
||||
<ul class="simple">
|
||||
<li><a class="reference" href="#introduction" id="id8" name="id8">Introduction</a></li>
|
||||
<li><a class="reference" href="#tutorial" id="id9" name="id9">Tutorial</a></li>
|
||||
<li><a class="reference" href="#concept-parameterspec" id="id10" name="id10">concept <span class="concept">ParameterSpec</span></a></li>
|
||||
<li><a class="reference" href="#special-keywords" id="id11" name="id11"><em>special</em> keywords</a></li>
|
||||
<li><a class="reference" href="#class-template-init" id="id12" name="id12">class template <tt class="docutils literal"><span class="pre">init</span></tt></a></li>
|
||||
<li><a class="reference" href="#class-template-call" id="id13" name="id13">class template <tt class="docutils literal"><span class="pre">call</span></tt></a></li>
|
||||
<li><a class="reference" href="#class-template-function" id="id14" name="id14">class template <tt class="docutils literal"><span class="pre">function</span></tt></a></li>
|
||||
<li><a class="reference" href="#function-template-def" id="id15" name="id15">function template <tt class="docutils literal"><span class="pre">def</span></tt></a></li>
|
||||
<li><a class="reference" href="#portability" id="id16" name="id16">Portability</a></li>
|
||||
<li><a class="reference" href="#introduction" id="id7" name="id7">Introduction</a></li>
|
||||
<li><a class="reference" href="#tutorial" id="id8" name="id8">Tutorial</a></li>
|
||||
<li><a class="reference" href="#concept-parameterspec" id="id9" name="id9">concept <span class="concept">ParameterSpec</span></a></li>
|
||||
<li><a class="reference" href="#special-keywords" id="id10" name="id10"><em>special</em> keywords</a></li>
|
||||
<li><a class="reference" href="#class-template-init" id="id11" name="id11">class template <tt class="docutils literal"><span class="pre">init</span></tt></a></li>
|
||||
<li><a class="reference" href="#class-template-call" id="id12" name="id12">class template <tt class="docutils literal"><span class="pre">call</span></tt></a></li>
|
||||
<li><a class="reference" href="#class-template-function" id="id13" name="id13">class template <tt class="docutils literal"><span class="pre">function</span></tt></a></li>
|
||||
<li><a class="reference" href="#function-template-def" id="id14" name="id14">function template <tt class="docutils literal"><span class="pre">def</span></tt></a></li>
|
||||
<li><a class="reference" href="#portability" id="id15" name="id15">Portability</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section">
|
||||
<h1><a class="toc-backref" href="#id8" id="introduction" name="introduction">Introduction</a></h1>
|
||||
<h1><a class="toc-backref" href="#id7" id="introduction" name="introduction">Introduction</a></h1>
|
||||
<p><tt class="docutils literal"><span class="pre">boost/parameter/python.hpp</span></tt> introduces a group of <a class="reference" href="../../../python/doc/v2/def_visitor.html"><tt class="docutils literal"><span class="pre">def_visitors</span></tt></a> that can
|
||||
be used to easily expose Boost.Parameter-enabled member functions to Python with
|
||||
Boost.Python. It also provides a function template <tt class="docutils literal"><span class="pre">def()</span></tt> that can be used
|
||||
@@ -81,7 +81,7 @@ We will take a closer look at how this is done in the tutorial section below.</p
|
||||
<!-- function? -->
|
||||
</div>
|
||||
<div class="section">
|
||||
<h1><a class="toc-backref" href="#id9" id="tutorial" name="tutorial">Tutorial</a></h1>
|
||||
<h1><a class="toc-backref" href="#id8" id="tutorial" name="tutorial">Tutorial</a></h1>
|
||||
<p>In this section we will outline the steps needed to bind a simple
|
||||
Boost.Parameter-enabled member function to Python. Knowledge of the
|
||||
Boost.Parameter <a class="reference" href="index.html">macros</a> are required to understand this section.</p>
|
||||
@@ -124,7 +124,8 @@ Python we use the binding utility <tt class="docutils literal"><span class="pre"
|
||||
<tt class="docutils literal"><span class="pre">boost::parameter::python::function</span></tt> is a <a class="reference" href="../../../python/doc/v2/def_visitor.html"><tt class="docutils literal"><span class="pre">def_visitor</span></tt></a> that we'll instantiate
|
||||
and pass to <tt class="docutils literal"><span class="pre">boost::python::class_::def()</span></tt>.</p>
|
||||
<p>To use <tt class="docutils literal"><span class="pre">boost::parameter::python::function</span></tt> we first need to define
|
||||
a class with forwarding overloads.</p>
|
||||
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
|
||||
{
|
||||
@@ -188,7 +189,9 @@ forwarding overloads that we defined earlier. The second one is an <a class="ref
|
||||
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" 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>.</p>
|
||||
the <a class="reference" href="../../../mpl/doc/refmanual/sequences.html">MPL Sequence</a> is the return type of the function, in this case <tt class="docutils literal"><span class="pre">void</span></tt>,
|
||||
which is passed as the first argument to <tt class="docutils literal"><span class="pre">operator()</span></tt> in the forwarding
|
||||
class.</p>
|
||||
<!-- The
|
||||
pointer syntax means that the parameter is optional, so in this case
|
||||
``width`` and ``height`` are optional parameters. The third parameter
|
||||
@@ -240,7 +243,7 @@ types instead). -->
|
||||
</div>
|
||||
<hr class="docutils" />
|
||||
<div class="section">
|
||||
<h1><a class="toc-backref" href="#id10" id="concept-parameterspec" name="concept-parameterspec">concept <span class="concept">ParameterSpec</span></a></h1>
|
||||
<h1><a class="toc-backref" href="#id9" id="concept-parameterspec" name="concept-parameterspec">concept <span class="concept">ParameterSpec</span></a></h1>
|
||||
<p>A <span class="concept">ParameterSpec</span> is a function type <tt class="docutils literal"><span class="pre">K(T)</span></tt> that describes both the keyword tag,
|
||||
<tt class="docutils literal"><span class="pre">K</span></tt>, and the argument type, <tt class="docutils literal"><span class="pre">T</span></tt>, for a parameter.</p>
|
||||
<p><tt class="docutils literal"><span class="pre">K</span></tt> is either:</p>
|
||||
@@ -261,11 +264,12 @@ the <strong>arity range</strong> of <tt class="docutils literal"><span class="pr
|
||||
<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">
|
||||
<h1><a class="toc-backref" href="#id11" id="special-keywords" name="special-keywords"><em>special</em> keywords</a></h1>
|
||||
<h1><a class="toc-backref" href="#id10" id="special-keywords" name="special-keywords"><em>special</em> keywords</a></h1>
|
||||
<p>Sometimes it is desirable to have a default value for a parameter that differ
|
||||
in type from the parameter. This technique is useful for doing simple tag-dispatching
|
||||
based on the presence of a parameter. An <a class="reference" href="index.html#dispatching-based-on-the-presence-of-a-default">example</a> of this is given in the Boost.Parameter
|
||||
docs. The example uses a different technique, but could also have been written like this:</p>
|
||||
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
|
||||
{
|
||||
@@ -313,19 +317,21 @@ int main()
|
||||
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. 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>
|
||||
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" 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">
|
||||
<h1><a class="toc-backref" href="#id12" id="class-template-init" name="class-template-init">class template <tt class="docutils literal"><span class="pre">init</span></tt></a></h1>
|
||||
<h1><a class="toc-backref" href="#id11" id="class-template-init" name="class-template-init">class template <tt class="docutils literal"><span class="pre">init</span></tt></a></h1>
|
||||
<p>Defines a named parameter enabled constructor.</p>
|
||||
<pre class="literal-block">
|
||||
template <class ParameterSpecs>
|
||||
@@ -348,7 +354,7 @@ model of <span class="concept">ParameterSpec</span>.</p>
|
||||
<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 table">
|
||||
<table border="1" class="docutils">
|
||||
<colgroup>
|
||||
<col width="30%" />
|
||||
<col width="17%" />
|
||||
@@ -382,7 +388,7 @@ expressions:</p>
|
||||
uses CallPolicies when creating the binding.</p>
|
||||
</div>
|
||||
<div class="section">
|
||||
<h2><a id="id3" name="id3">Example</a></h2>
|
||||
<h2><a id="example" name="example">Example</a></h2>
|
||||
<pre class="literal-block">
|
||||
#include <boost/parameter/keyword.hpp>
|
||||
#include <boost/parameter/preprocessor.hpp>
|
||||
@@ -441,7 +447,7 @@ assert(args[y | 1] == 1);
|
||||
</div>
|
||||
<hr class="docutils" />
|
||||
<div class="section">
|
||||
<h1><a class="toc-backref" href="#id13" id="class-template-call" name="class-template-call">class template <tt class="docutils literal"><span class="pre">call</span></tt></a></h1>
|
||||
<h1><a class="toc-backref" href="#id12" id="class-template-call" name="class-template-call">class template <tt class="docutils literal"><span class="pre">call</span></tt></a></h1>
|
||||
<p>Defines a <tt class="docutils literal"><span class="pre">__call__</span></tt> operator, mapped to <tt class="docutils literal"><span class="pre">operator()</span></tt> in C++.</p>
|
||||
<pre class="literal-block">
|
||||
template <class ParameterSpecs>
|
||||
@@ -464,7 +470,7 @@ is the result type of <tt class="docutils literal"><span class="pre">c(…)</spa
|
||||
</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 table">
|
||||
<table border="1" class="docutils">
|
||||
<colgroup>
|
||||
<col width="24%" />
|
||||
<col width="26%" />
|
||||
@@ -494,12 +500,12 @@ instance of <tt class="docutils literal"><span class="pre">Class</span></tt>:</p
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section">
|
||||
<h2><a id="id4" name="id4"><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></a></h2>
|
||||
<h2><a id="id3" name="id3"><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></a></h2>
|
||||
<p>Returns a <tt class="docutils literal"><span class="pre">def_visitor</span></tt> equivalent to <tt class="docutils literal"><span class="pre">*this</span></tt>, except that it
|
||||
uses CallPolicies when creating the binding.</p>
|
||||
</div>
|
||||
<div class="section">
|
||||
<h2><a id="id5" name="id5">Example</a></h2>
|
||||
<h2><a id="id4" name="id4">Example</a></h2>
|
||||
<pre class="literal-block">
|
||||
#include <boost/parameter/keyword.hpp>
|
||||
#include <boost/parameter/preprocessor.hpp>
|
||||
@@ -568,7 +574,7 @@ return 0;
|
||||
</div>
|
||||
<hr class="docutils" />
|
||||
<div class="section">
|
||||
<h1><a class="toc-backref" href="#id14" id="class-template-function" name="class-template-function">class template <tt class="docutils literal"><span class="pre">function</span></tt></a></h1>
|
||||
<h1><a class="toc-backref" href="#id13" id="class-template-function" name="class-template-function">class template <tt class="docutils literal"><span class="pre">function</span></tt></a></h1>
|
||||
<p>Defines a named parameter enabled member function.</p>
|
||||
<pre class="literal-block">
|
||||
template <class Fwd, class ParameterSpecs>
|
||||
@@ -588,7 +594,7 @@ is the result type of <tt class="docutils literal"><span class="pre">c.f(…)</s
|
||||
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 table">
|
||||
<table border="1" class="docutils">
|
||||
<colgroup>
|
||||
<col width="39%" />
|
||||
<col width="18%" />
|
||||
@@ -620,7 +626,7 @@ are tagged arguments.</p>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section">
|
||||
<h2><a id="id6" name="id6">Example</a></h2>
|
||||
<h2><a id="id5" name="id5">Example</a></h2>
|
||||
<p>This example exports a member function <tt class="docutils literal"><span class="pre">f(int</span> <span class="pre">x,</span> <span class="pre">int</span> <span class="pre">y</span> <span class="pre">=</span> <span class="pre">…)</span></tt> to Python. The
|
||||
sequence of <span class="concept">ParameterSpec</span>'s <tt class="docutils literal"><span class="pre">mpl::vector2<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>
|
||||
@@ -684,7 +690,7 @@ assert(y == 1);
|
||||
</div>
|
||||
<hr class="docutils" />
|
||||
<div class="section">
|
||||
<h1><a class="toc-backref" href="#id15" id="function-template-def" name="function-template-def">function template <tt class="docutils literal"><span class="pre">def</span></tt></a></h1>
|
||||
<h1><a class="toc-backref" href="#id14" id="function-template-def" name="function-template-def">function template <tt class="docutils literal"><span class="pre">def</span></tt></a></h1>
|
||||
<p>Defines a named parameter enabled free function in the current Python scope.</p>
|
||||
<pre class="literal-block">
|
||||
template <class Fwd, class ParameterSpecs>
|
||||
@@ -699,7 +705,7 @@ except the first models <span class="concept">ParameterSpec</span>. The first el
|
||||
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 table">
|
||||
<table border="1" class="docutils">
|
||||
<colgroup>
|
||||
<col width="39%" />
|
||||
<col width="21%" />
|
||||
@@ -729,7 +735,7 @@ is the result type of <tt class="docutils literal"><span class="pre">f(…)</spa
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section">
|
||||
<h2><a id="id7" name="id7">Example</a></h2>
|
||||
<h2><a id="id6" name="id6">Example</a></h2>
|
||||
<p>This example exports a function <tt class="docutils literal"><span class="pre">f(int</span> <span class="pre">x,</span> <span class="pre">int</span> <span class="pre">y</span> <span class="pre">=</span> <span class="pre">…)</span></tt> to Python. The
|
||||
sequence of <span class="concept">ParameterSpec</span>'s <tt class="docutils literal"><span class="pre">mpl::vector2<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>
|
||||
@@ -766,14 +772,14 @@ BOOST_PYTHON_MODULE(…)
|
||||
</div>
|
||||
</div>
|
||||
<div class="section">
|
||||
<h1><a class="toc-backref" href="#id16" id="portability" name="portability">Portability</a></h1>
|
||||
<h1><a class="toc-backref" href="#id15" id="portability" name="portability">Portability</a></h1>
|
||||
<p>The Boost.Parameter Python binding library requires <em>partial template
|
||||
specialization</em>.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="footer">
|
||||
<hr class="footer" />
|
||||
Generated on: 2007-01-03 17:02 UTC.
|
||||
Generated on: 2007-01-03 16:40 UTC.
|
||||
Generated by <a class="reference" href="http://docutils.sourceforge.net/">Docutils</a> from <a class="reference" href="http://docutils.sourceforge.net/rst.html">reStructuredText</a> source.
|
||||
|
||||
</div>
|
||||
|
||||
@@ -39,67 +39,73 @@ or copy at <a class="reference" href="http://www.boost.org/LICENSE_1_0.txt">http
|
||||
<div class="contents topic">
|
||||
<p class="topic-title first"><a id="contents" name="contents">Contents</a></p>
|
||||
<ul class="auto-toc simple">
|
||||
<li><a class="reference" href="#preliminaries" id="id26" name="id26">1 Preliminaries</a><ul class="auto-toc">
|
||||
<li><a class="reference" href="#namespaces" id="id27" name="id27">1.1 Namespaces</a></li>
|
||||
<li><a class="reference" href="#exceptions" id="id28" name="id28">1.2 Exceptions</a></li>
|
||||
<li><a class="reference" href="#thread-safety" id="id29" name="id29">1.3 Thread Safety</a></li>
|
||||
<li><a class="reference" href="#typography" id="id30" name="id30">1.4 Typography</a></li>
|
||||
<li><a class="reference" href="#preliminaries" id="id30" name="id30">1 Preliminaries</a><ul class="auto-toc">
|
||||
<li><a class="reference" href="#namespaces" id="id31" name="id31">1.1 Namespaces</a></li>
|
||||
<li><a class="reference" href="#exceptions" id="id32" name="id32">1.2 Exceptions</a></li>
|
||||
<li><a class="reference" href="#thread-safety" id="id33" name="id33">1.3 Thread Safety</a></li>
|
||||
<li><a class="reference" href="#typography" id="id34" name="id34">1.4 Typography</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a class="reference" href="#terminology" id="id31" name="id31">2 Terminology</a></li>
|
||||
<li><a class="reference" href="#concepts" id="id32" name="id32">3 Concepts</a><ul class="auto-toc">
|
||||
<li><a class="reference" href="#argumentpack" id="id33" name="id33">3.1 <span class="concept">ArgumentPack</span></a></li>
|
||||
<li><a class="reference" href="#id5" id="id34" name="id34">3.2 <span class="concept">ParameterSpec</span></a></li>
|
||||
<li><a class="reference" href="#terminology" id="id35" name="id35">2 Terminology</a></li>
|
||||
<li><a class="reference" href="#concepts" id="id36" name="id36">3 Concepts</a><ul class="auto-toc">
|
||||
<li><a class="reference" href="#argumentpack" id="id37" name="id37">3.1 <span class="concept">ArgumentPack</span></a></li>
|
||||
<li><a class="reference" href="#id5" id="id38" name="id38">3.2 <span class="concept">ParameterSpec</span></a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a class="reference" href="#class-templates" id="id35" name="id35">4 Class Templates</a><ul class="auto-toc">
|
||||
<li><a class="reference" href="#id7" id="id36" name="id36">4.1 <tt class="docutils literal"><span class="pre">keyword</span></tt></a></li>
|
||||
<li><a class="reference" href="#parameters" id="id37" name="id37">4.2 <tt class="docutils literal"><span class="pre">parameters</span></tt></a></li>
|
||||
<li><a class="reference" href="#optional-required" id="id38" name="id38">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" href="#class-templates" id="id39" name="id39">4 Class Templates</a><ul class="auto-toc">
|
||||
<li><a class="reference" href="#id7" id="id40" name="id40">4.1 <tt class="docutils literal"><span class="pre">keyword</span></tt></a></li>
|
||||
<li><a class="reference" href="#parameters" id="id41" name="id41">4.2 <tt class="docutils literal"><span class="pre">parameters</span></tt></a></li>
|
||||
<li><a class="reference" href="#optional-required" id="id42" name="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" href="#deduced" id="id43" name="id43">4.4 <tt class="docutils literal"><span class="pre">deduced</span></tt></a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a class="reference" href="#metafunctions" id="id39" name="id39">5 Metafunctions</a><ul class="auto-toc">
|
||||
<li><a class="reference" href="#binding" id="id40" name="id40">5.1 <tt class="docutils literal"><span class="pre">binding</span></tt></a></li>
|
||||
<li><a class="reference" href="#lazy-binding" id="id41" name="id41">5.2 <tt class="docutils literal"><span class="pre">lazy_binding</span></tt></a></li>
|
||||
<li><a class="reference" href="#metafunctions" id="id44" name="id44">5 Metafunctions</a><ul class="auto-toc">
|
||||
<li><a class="reference" href="#binding" id="id45" name="id45">5.1 <tt class="docutils literal"><span class="pre">binding</span></tt></a></li>
|
||||
<li><a class="reference" href="#lazy-binding" id="id46" name="id46">5.2 <tt class="docutils literal"><span class="pre">lazy_binding</span></tt></a></li>
|
||||
<li><a class="reference" href="#value-type" id="id47" name="id47">5.3 <tt class="docutils literal"><span class="pre">value_type</span></tt></a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a class="reference" href="#code-generation-macros" id="id42" name="id42">6 Code Generation Macros</a><ul class="auto-toc">
|
||||
<li><a class="reference" href="#boost-parameter-function-result-name-tag-namespace-arguments" id="id43" name="id43">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" href="#boost-parameter-fun-r-n-l-h-p" id="id44" name="id44">6.2 <tt class="docutils literal"><span class="pre">BOOST_PARAMETER_FUN(r,n,l,h,p)</span></tt></a></li>
|
||||
<li><a class="reference" href="#boost-parameter-keyword-n-k" id="id45" name="id45">6.3 <tt class="docutils literal"><span class="pre">BOOST_PARAMETER_KEYWORD(n,k)</span></tt></a></li>
|
||||
<li><a class="reference" href="#boost-parameter-match-p-a-x" id="id46" name="id46">6.4 <tt class="docutils literal"><span class="pre">BOOST_PARAMETER_MATCH(p,a,x)</span></tt></a></li>
|
||||
<li><a class="reference" href="#code-generation-macros" id="id48" name="id48">6 Code Generation Macros</a><ul class="auto-toc">
|
||||
<li><a class="reference" href="#boost-parameter-function-result-name-tag-namespace-arguments" id="id49" name="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" href="#boost-parameter-member-function-result-name-tag-namespace-arguments" id="id50" name="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" href="#boost-parameter-constructor-cls-impl-tag-namespace-arguments" id="id51" name="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" href="#boost-parameter-name-name" id="id52" name="id52">6.4 <tt class="docutils literal"><span class="pre">BOOST_PARAMETER_NAME(name)</span></tt></a></li>
|
||||
<li><a class="reference" href="#boost-parameter-template-keyword-name" id="id53" name="id53">6.5 <tt class="docutils literal"><span class="pre">BOOST_PARAMETER_TEMPLATE_KEYWORD(name)</span></tt></a></li>
|
||||
<li><a class="reference" href="#boost-parameter-fun-r-n-l-h-p" id="id54" name="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" href="#boost-parameter-keyword-n-k" id="id55" name="id55">6.7 <tt class="docutils literal"><span class="pre">BOOST_PARAMETER_KEYWORD(n,k)</span></tt></a></li>
|
||||
<li><a class="reference" href="#boost-parameter-match-p-a-x" id="id56" name="id56">6.8 <tt class="docutils literal"><span class="pre">BOOST_PARAMETER_MATCH(p,a,x)</span></tt></a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a class="reference" href="#configuration-macros" id="id47" name="id47">7 Configuration Macros</a><ul class="auto-toc">
|
||||
<li><a class="reference" href="#boost-parameter-max-arity" id="id48" name="id48">7.1 <tt class="docutils literal"><span class="pre">BOOST_PARAMETER_MAX_ARITY</span></tt></a></li>
|
||||
<li><a class="reference" href="#configuration-macros" id="id57" name="id57">7 Configuration Macros</a><ul class="auto-toc">
|
||||
<li><a class="reference" href="#boost-parameter-max-arity" id="id58" name="id58">7.1 <tt class="docutils literal"><span class="pre">BOOST_PARAMETER_MAX_ARITY</span></tt></a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a class="reference" href="#tutorial" id="id49" name="id49">8 Tutorial</a></li>
|
||||
<li><a class="reference" href="#tutorial" id="id59" name="id59">8 Tutorial</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<hr class="docutils" />
|
||||
<div class="section">
|
||||
<h1><a class="toc-backref" href="#id26" id="preliminaries" name="preliminaries">1 Preliminaries</a></h1>
|
||||
<h1><a class="toc-backref" href="#id30" id="preliminaries" name="preliminaries">1 Preliminaries</a></h1>
|
||||
<p>This section covers some basic information you'll need to know in
|
||||
order to understand this reference</p>
|
||||
<div class="section">
|
||||
<h2><a class="toc-backref" href="#id27" id="namespaces" name="namespaces">1.1 Namespaces</a></h2>
|
||||
<h2><a class="toc-backref" href="#id31" id="namespaces" name="namespaces">1.1 Namespaces</a></h2>
|
||||
<p>In this document, all unqualified identifiers should be assumed to
|
||||
be defined in namespace <tt class="docutils literal"><span class="pre">boost::parameter</span></tt> unless otherwise
|
||||
specified.</p>
|
||||
</div>
|
||||
<div class="section">
|
||||
<h2><a class="toc-backref" href="#id28" id="exceptions" name="exceptions">1.2 Exceptions</a></h2>
|
||||
<h2><a class="toc-backref" href="#id32" id="exceptions" name="exceptions">1.2 Exceptions</a></h2>
|
||||
<p>No operation described in this document
|
||||
throws an exception unless otherwise specified.</p>
|
||||
</div>
|
||||
<div class="section">
|
||||
<h2><a class="toc-backref" href="#id29" id="thread-safety" name="thread-safety">1.3 Thread Safety</a></h2>
|
||||
<h2><a class="toc-backref" href="#id33" id="thread-safety" name="thread-safety">1.3 Thread Safety</a></h2>
|
||||
<p>All components of this library can be used safely from multiple
|
||||
threads without synchronization.<a class="footnote-reference" href="#thread" id="id2" name="id2"><sup>1</sup></a></p>
|
||||
</div>
|
||||
<div class="section">
|
||||
<h2><a class="toc-backref" href="#id30" id="typography" name="typography">1.4 Typography</a></h2>
|
||||
<h2><a class="toc-backref" href="#id34" id="typography" name="typography">1.4 Typography</a></h2>
|
||||
<p>Names written in <span class="concept">sans serif type</span> represent <a class="reference" href="../../../../more/generic_programming.html#concept">concepts</a>.</p>
|
||||
<p>In code blocks, <em>italic type</em> represents unspecified text that
|
||||
satisfies the requirements given in the detailed description that
|
||||
@@ -112,7 +118,7 @@ argument in the result.</p>
|
||||
</div>
|
||||
<hr class="docutils" />
|
||||
<div class="section">
|
||||
<h1><a class="toc-backref" href="#id31" id="terminology" name="terminology">2 Terminology</a></h1>
|
||||
<h1><a class="toc-backref" href="#id35" id="terminology" name="terminology">2 Terminology</a></h1>
|
||||
<dl class="docutils" id="kw">
|
||||
<dt>keyword</dt>
|
||||
<dd>The name of a function parameter.</dd>
|
||||
@@ -171,10 +177,10 @@ models <a class="reference" href="#argumentpack"><span class="concept">ArgumentP
|
||||
</div>
|
||||
<hr class="docutils" />
|
||||
<div class="section">
|
||||
<h1><a class="toc-backref" href="#id32" id="concepts" name="concepts">3 Concepts</a></h1>
|
||||
<h1><a class="toc-backref" href="#id36" id="concepts" name="concepts">3 Concepts</a></h1>
|
||||
<p>This section describes the generic type <a class="reference" href="../../../../more/generic_programming.html#concept">concepts</a> used by the Parameter library.</p>
|
||||
<div class="section">
|
||||
<h2><a class="toc-backref" href="#id33" id="argumentpack" name="argumentpack">3.1 <span class="concept">ArgumentPack</span></a></h2>
|
||||
<h2><a class="toc-backref" href="#id37" id="argumentpack" name="argumentpack">3.1 <span class="concept">ArgumentPack</span></a></h2>
|
||||
<p>An <span class="concept">ArgumentPack</span> is a collection of <a class="reference" href="#tagged-reference">tagged reference</a>s to the
|
||||
actual arguments passed to a function. Every <span class="concept">ArgumentPack</span> is
|
||||
also a valid MPL <a class="reference" href="../../../mpl/doc/refmanual/forward-sequence.html"><span class="concept">Forward Sequence</span></a> consisting of the <a class="reference" href="#keyword-tag-type">keyword tag type</a>s in its <a class="reference" href="#tagged-reference">tagged reference</a>s.</p>
|
||||
@@ -191,7 +197,7 @@ also a valid MPL <a class="reference" href="../../../mpl/doc/refmanual/forward-s
|
||||
</ul>
|
||||
<p>Any exceptions are thrown from the invocation of <tt class="docutils literal"><span class="pre">w</span></tt>'s <em>value</em>
|
||||
will be propagated to the caller.</p>
|
||||
<table border="1" class="docutils table">
|
||||
<table border="1" class="docutils">
|
||||
<caption><span class="concept">ArgumentPack</span> requirements</caption>
|
||||
<colgroup>
|
||||
<col width="11%" />
|
||||
@@ -243,7 +249,7 @@ all the elements of both <tt class="docutils literal"><span class="pre">x</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section">
|
||||
<h2><a class="toc-backref" href="#id34" id="id5" name="id5"><span id="parameterspec"></span>3.2 <span class="concept">ParameterSpec</span></a></h2>
|
||||
<h2><a class="toc-backref" href="#id38" id="id5" name="id5"><span id="parameterspec"></span>3.2 <span class="concept">ParameterSpec</span></a></h2>
|
||||
<p>A <span class="concept">ParameterSpec</span> describes the type requirements for arguments
|
||||
corresponding to a given <a class="reference" href="#kw">keyword</a> and indicates whether the argument
|
||||
is optional or required. The table below details the allowed forms
|
||||
@@ -254,7 +260,7 @@ argument type. In each row,</p>
|
||||
<li><tt class="docutils literal"><span class="pre">A</span></tt> is an <a class="reference" href="#intended-argument-type">intended argument type</a> associated with <tt class="docutils literal"><span class="pre">K</span></tt>, if any</li>
|
||||
<li><tt class="docutils literal"><span class="pre">F</span></tt> is a unary <a class="reference" href="../../../mpl/doc/refmanual/lambda-expression.html">MPL lambda expression</a></li>
|
||||
</ul>
|
||||
<table border="1" class="docutils table">
|
||||
<table border="1" class="docutils">
|
||||
<caption><span class="concept">ParameterSpec</span> allowed forms and conditions of satisfaction</caption>
|
||||
<colgroup>
|
||||
<col width="32%" />
|
||||
@@ -268,7 +274,7 @@ argument type. In each row,</p>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody valign="top">
|
||||
<tr><td><a class="reference" href="#keyword"><tt class="docutils literal"><span class="pre">keyword</span></tt></a><tt class="docutils literal"><span class="pre"><K></span></tt></td>
|
||||
<tr><td><tt class="docutils literal"><span class="pre">K</span></tt></td>
|
||||
<td>no</td>
|
||||
<td><em>n/a</em></td>
|
||||
</tr>
|
||||
@@ -290,9 +296,9 @@ arguments that will be matched by <a class="reference" href="index.html#forwardi
|
||||
</div>
|
||||
<hr class="docutils" />
|
||||
<div class="section">
|
||||
<h1><a class="toc-backref" href="#id35" id="class-templates" name="class-templates">4 Class Templates</a></h1>
|
||||
<h1><a class="toc-backref" href="#id39" id="class-templates" name="class-templates">4 Class Templates</a></h1>
|
||||
<div class="section">
|
||||
<h2><a class="toc-backref" href="#id36" id="id7" name="id7"><span id="keyword"></span>4.1 <tt class="docutils literal"><span class="pre">keyword</span></tt></a></h2>
|
||||
<h2><a class="toc-backref" href="#id40" id="id7" name="id7"><span id="keyword"></span>4.1 <tt class="docutils literal"><span class="pre">keyword</span></tt></a></h2>
|
||||
<p>The type of every <a class="reference" href="#keyword-object">keyword object</a> is a specialization of <tt class="docutils literal"><span class="pre">keyword</span></tt>.</p>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
@@ -390,7 +396,7 @@ simultaneously.</td>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="section">
|
||||
<h2><a class="toc-backref" href="#id37" id="parameters" name="parameters">4.2 <tt class="docutils literal"><span class="pre">parameters</span></tt></a></h2>
|
||||
<h2><a class="toc-backref" href="#id41" id="parameters" name="parameters">4.2 <tt class="docutils literal"><span class="pre">parameters</span></tt></a></h2>
|
||||
<p>Provides an interface for assembling the actual arguments to a
|
||||
<cite>forwarding function</cite> into an <span class="concept">ArgumentPack</span>, in which any
|
||||
<a class="reference" href="#positional">positional</a> arguments will be tagged according to the
|
||||
@@ -414,15 +420,15 @@ struct parameters
|
||||
};
|
||||
|
||||
template <class A0>
|
||||
<a class="reference" href="#argumentpack"><span class="concept">ArgumentPack</span></a> <a class="reference" href="#id13">operator()</a>(A0 const& a0) const;
|
||||
<a class="reference" href="#argumentpack"><span class="concept">ArgumentPack</span></a> <a class="reference" href="#id13">operator()</a>(A0& a0) const;
|
||||
|
||||
template <class A0, class A1>
|
||||
<a class="reference" href="#argumentpack"><span class="concept">ArgumentPack</span></a> <a class="reference" href="#id13">operator()</a>(A0 const& a0, A1 const& a1) const; <span class="vellipsis"> .
|
||||
.
|
||||
.
|
||||
</span>
|
||||
<a class="reference" href="#argumentpack"><span class="concept">ArgumentPack</span></a> <a class="reference" href="#id13">operator()</a>(A0& a0, A1& a1) const;
|
||||
|
||||
<span class="vellipsis">⋮</span>
|
||||
|
||||
template <class A0, class A1, …class Aβ>
|
||||
<a class="reference" href="#argumentpack"><span class="concept">ArgumentPack</span></a> <a class="reference" href="#id13">operator()</a>(A0 const& a0, A1 const& a1, …Aβ const& aβ) const;
|
||||
<a class="reference" href="#argumentpack"><span class="concept">ArgumentPack</span></a> <a class="reference" href="#id13">operator()</a>(A0& a0, A1& a1, …Aβ& aβ) const;
|
||||
};
|
||||
</pre>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
@@ -439,9 +445,9 @@ struct parameters
|
||||
follows, for any argument type <tt class="docutils literal"><span class="pre">A</span></tt><em>i</em>:</p>
|
||||
<blockquote class="last">
|
||||
<div class="line-block">
|
||||
<div class="line">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" href="#intended-argument-type">intended argument type</a></div>
|
||||
<div class="line"><br /></div>
|
||||
<div class="line-block">
|
||||
<div class="line">if <tt class="docutils literal"><span class="pre">A</span></tt><em>i</em> is a result type of <tt class="docutils literal"><span class="pre">keyword<T>::</span></tt><a class="reference" href="#operator"><tt class="docutils literal"><span class="pre">operator=</span></tt></a></div>
|
||||
<div class="line">then</div>
|
||||
<div class="line-block">
|
||||
@@ -449,6 +455,19 @@ follows, for any argument type <tt class="docutils literal"><span class="pre">A<
|
||||
</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" 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">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">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" 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>
|
||||
</div>
|
||||
<div class="line">else</div>
|
||||
<div class="line-block">
|
||||
<div class="line"><tt class="docutils literal"><span class="pre">K</span></tt><em>i</em> is <tt class="docutils literal"><span class="pre">P</span></tt><em>i</em>'s <a class="reference" href="#keyword-tag-type">keyword tag type</a>.</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -472,7 +491,7 @@ below), then <tt class="docutils literal"><span class="pre">parameters<P0,P1,
|
||||
every <em>j</em> in 0…β, either:</p>
|
||||
<ul class="last simple">
|
||||
<li><tt class="docutils literal"><span class="pre">P</span></tt><em>j</em> is the <em>unspecified</em> default</li>
|
||||
<li><strong>or</strong>, <tt class="docutils literal"><span class="pre">P</span></tt><em>j</em> is a specialization of <a class="reference" href="#keyword"><tt class="docutils literal"><span class="pre">keyword</span></tt></a>,</li>
|
||||
<li><strong>or</strong>, <tt class="docutils literal"><span class="pre">P</span></tt><em>j</em> is a <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" 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>
|
||||
@@ -489,10 +508,10 @@ every <em>j</em> in 0…β, either:</p>
|
||||
<dl class="docutils" id="id13">
|
||||
<dt><tt class="docutils literal"><span class="pre">operator()</span></tt></dt>
|
||||
<dd><pre class="first literal-block">
|
||||
template <class A0> <a class="reference" href="#argumentpack"><span class="concept">ArgumentPack</span></a> operator()(A0 const& a0) const; <span class="vellipsis"> .
|
||||
.
|
||||
.
|
||||
</span>
|
||||
template <class A0> <a class="reference" href="#argumentpack"><span class="concept">ArgumentPack</span></a> operator()(A0 const& a0) const;
|
||||
|
||||
<span class="vellipsis">⋮</span>
|
||||
|
||||
template <class A0, …class Aβ> <a class="reference" href="#argumentpack"><span class="concept">ArgumentPack</span></a> <a class="reference" href="#id13">operator()</a>(A0 const& a0, …Aβ const& aβ) const;
|
||||
</pre>
|
||||
<table class="last docutils field-list" frame="void" rules="none">
|
||||
@@ -512,7 +531,7 @@ template <class A0, …class Aβ> <a class="reference" href="#argumentpack
|
||||
</dl>
|
||||
</div>
|
||||
<div class="section">
|
||||
<h2><a class="toc-backref" href="#id38" id="optional-required" name="optional-required"><span id="required"></span><span id="optional"></span>4.3 <tt class="docutils literal"><span class="pre">optional</span></tt>, <tt class="docutils literal"><span class="pre">required</span></tt></a></h2>
|
||||
<h2><a class="toc-backref" href="#id42" id="optional-required" name="optional-required"><span id="required"></span><span id="optional"></span>4.3 <tt class="docutils literal"><span class="pre">optional</span></tt>, <tt class="docutils literal"><span class="pre">required</span></tt></a></h2>
|
||||
<p>These templates describe the requirements on a function parameter.</p>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
@@ -541,14 +560,31 @@ struct required;
|
||||
<p>The default value of <tt class="docutils literal"><span class="pre">Predicate</span></tt> is an unspecified <a class="reference" href="../../../mpl/doc/refmanual/metafunction.html"><span class="concept">Metafunction</span></a> that returns
|
||||
<tt class="docutils literal"><span class="pre">mpl::true_</span></tt> for any argument.</p>
|
||||
</div>
|
||||
<div class="section">
|
||||
<h2><a class="toc-backref" href="#id43" id="deduced" name="deduced">4.4 <tt class="docutils literal"><span class="pre">deduced</span></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>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field"><th class="field-name">Defined in:</th><td class="field-body"><a class="reference" href="../../../../boost/parameter/parameters.hpp">boost/parameter/parameters.hpp</a></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<pre class="literal-block">
|
||||
template <class Tag>
|
||||
struct deduced;
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
<hr class="docutils" />
|
||||
<div class="section">
|
||||
<h1><a class="toc-backref" href="#id39" id="metafunctions" name="metafunctions">5 Metafunctions</a></h1>
|
||||
<h1><a class="toc-backref" href="#id44" id="metafunctions" name="metafunctions">5 Metafunctions</a></h1>
|
||||
<p>A <a class="reference" href="../../../mpl/doc/refmanual/metafunction.html"><span class="concept">Metafunction</span></a> is conceptually a function that operates on, and
|
||||
returns, C++ types.</p>
|
||||
<div class="section">
|
||||
<h2><a class="toc-backref" href="#id40" id="binding" name="binding">5.1 <tt class="docutils literal"><span class="pre">binding</span></tt></a></h2>
|
||||
<h2><a class="toc-backref" href="#id45" id="binding" name="binding">5.1 <tt class="docutils literal"><span class="pre">binding</span></tt></a></h2>
|
||||
<p>Returns the result type of indexing an argument pack with a
|
||||
<a class="reference" href="#keyword-tag-type">keyword tag type</a> or with a <a class="reference" href="#tagged-default">tagged default</a>.</p>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
@@ -579,7 +615,7 @@ having <a class="reference" href="#keyword-tag-type">keyword tag type</a> <tt cl
|
||||
</table>
|
||||
</div>
|
||||
<div class="section">
|
||||
<h2><a class="toc-backref" href="#id41" id="lazy-binding" name="lazy-binding">5.2 <tt class="docutils literal"><span class="pre">lazy_binding</span></tt></a></h2>
|
||||
<h2><a class="toc-backref" href="#id46" id="lazy-binding" name="lazy-binding">5.2 <tt class="docutils literal"><span class="pre">lazy_binding</span></tt></a></h2>
|
||||
<p>Returns the result type of indexing an argument pack with a <a class="reference" href="#tagged-lazy-default">tagged lazy default</a>.</p>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
@@ -603,7 +639,46 @@ struct lazy_binding
|
||||
<tr class="field"><th class="field-name">Requires:</th><td class="field-body"><tt class="docutils literal"><span class="pre">A</span></tt> is a model of <a class="reference" href="#argumentpack"><span class="concept">ArgumentPack</span></a>.</td>
|
||||
</tr>
|
||||
<tr class="field"><th class="field-name">Returns:</th><td class="field-body">the reference type of the <a class="reference" href="#tagged-reference">tagged reference</a> in <tt class="docutils literal"><span class="pre">A</span></tt>
|
||||
having <a class="reference" href="#keyword-tag-type">keyword tag type</a> <tt class="docutils literal"><span class="pre">K</span></tt>, if any. If no such <a class="reference" href="#tagged-reference">tagged reference</a> exists, returns <tt class="docutils literal"><span class="pre">boost::</span></tt><a class="reference" href="../../../utility/utility.htm#result_of"><tt class="docutils literal"><span class="pre">result_of</span></tt></a><tt class="docutils literal"><span class="pre"><F()>::type</span></tt>.<a class="footnote-reference" href="#no-result-of" id="id17" name="id17"><sup>2</sup></a></td>
|
||||
having <a class="reference" href="#keyword-tag-type">keyword tag type</a> <tt class="docutils literal"><span class="pre">K</span></tt>, if any. If no such <a class="reference" href="#tagged-reference">tagged reference</a> exists, returns <tt class="docutils literal"><span class="pre">boost::</span></tt><a class="reference" href="../../../utility/utility.htm#result_of"><tt class="docutils literal"><span class="pre">result_of</span></tt></a><tt class="docutils literal"><span class="pre"><F()>::type</span></tt>.<a class="footnote-reference" href="#no-result-of" id="id18" name="id18"><sup>2</sup></a></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="section">
|
||||
<h2><a class="toc-backref" href="#id47" id="value-type" name="value-type">5.3 <tt class="docutils literal"><span class="pre">value_type</span></tt></a></h2>
|
||||
<p>Returns the result type of indexing an argument pack with a
|
||||
<a class="reference" href="#keyword-tag-type">keyword tag type</a> or with a <a class="reference" href="#tagged-default">tagged default</a>.</p>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field"><th class="field-name">Defined n:</th><td class="field-body"><a class="reference" href="../../../../boost/parameter/value_type.hpp">boost/parameter/value_type.hpp</a></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<pre class="literal-block">
|
||||
template <class A, class K, class D = void>
|
||||
struct value_type
|
||||
{
|
||||
typedef … type;
|
||||
};
|
||||
</pre>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field"><th class="field-name">Requires:</th><td class="field-body"><p class="first"><tt class="docutils literal"><span class="pre">A</span></tt> is a model of <a class="reference" href="#argumentpack"><span class="concept">ArgumentPack</span></a>.</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" href="#tagged-reference">tagged reference</a> in <tt class="docutils literal"><span class="pre">A</span></tt>
|
||||
having <a class="reference" href="#keyword-tag-type">keyword tag type</a> <tt class="docutils literal"><span class="pre">K</span></tt>, if any. If no such <a class="reference" href="#tagged-reference">tagged reference</a> exists, returns <tt class="docutils literal"><span class="pre">D</span></tt>. 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>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -611,11 +686,11 @@ having <a class="reference" href="#keyword-tag-type">keyword tag type</a> <tt cl
|
||||
</div>
|
||||
<hr class="docutils" />
|
||||
<div class="section">
|
||||
<h1><a class="toc-backref" href="#id42" id="code-generation-macros" name="code-generation-macros">6 Code Generation Macros</a></h1>
|
||||
<h1><a class="toc-backref" href="#id48" id="code-generation-macros" name="code-generation-macros">6 Code Generation Macros</a></h1>
|
||||
<p>Macros in this section can be used to ease the writing of code
|
||||
using the Parameter libray by eliminating repetitive boilerplate.</p>
|
||||
<div class="section">
|
||||
<h2><a class="toc-backref" href="#id43" id="boost-parameter-function-result-name-tag-namespace-arguments" name="boost-parameter-function-result-name-tag-namespace-arguments">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" id="boost-parameter-function-result-name-tag-namespace-arguments" name="boost-parameter-function-result-name-tag-namespace-arguments">6.1 <tt class="docutils literal"><span class="pre">BOOST_PARAMETER_FUNCTION(result,name,tag_namespace,arguments)</span></tt></a></h2>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
@@ -637,17 +712,20 @@ a list of <em>argument specifiers</em>, as defined below.</p>
|
||||
</tr>
|
||||
<tr class="field"><th class="field-name" colspan="2">Argument specifiers syntax:</th></tr>
|
||||
<tr><td> </td><td class="field-body"><pre class="first literal-block">
|
||||
argument-specifiers ::= specifier-group {specifier-group}
|
||||
argument-specifiers ::= <em>specifier-group</em> {<em>specifier-group</em>}
|
||||
|
||||
specifier-group ::= ( '(' 'optional' optional-specifier {optional-specifier} ')' ) |
|
||||
( '(' 'required' required-specifier {required-specifier} ')' )
|
||||
specifier-group0 ::= <em>specifier-group1</em> |
|
||||
( '<strong>(</strong>' '<strong>deduced</strong>' <em>specifier-group1</em> {<em>specifier-group1</em>} '<strong>)</strong>' )
|
||||
|
||||
optional-specifier ::= '(' name ',' restriction ',' default-value ')'
|
||||
required-specifier ::= '(' name ',' restriction ')'
|
||||
specifier-group1 ::= ( '<strong>(</strong>' '<strong>optional</strong>' <em>optional-specifier</em> {<em>optional-specifier</em>} '<strong>)</strong>' ) |
|
||||
( '<strong>(</strong>' '<strong>required</strong>' <em>required-specifier</em> {<em>required-specifier</em>} '<strong>)</strong>' )
|
||||
|
||||
restriction ::= ('*' '(' lambda-expression ')' ) |
|
||||
( '(' typename ')' ) |
|
||||
'*'
|
||||
optional-specifier ::= '<strong>(</strong>' <em>name</em> '<strong>,</strong>' <em>restriction</em> '<strong>,</strong>' <em>default-value</em> ')'
|
||||
required-specifier ::= '<strong>(</strong>' <em>name</em> '<strong>,</strong>' <em>restriction</em> ')'
|
||||
|
||||
restriction ::= ('<strong>*</strong>' '<strong>(</strong>' <em>lambda-expression</em> '<strong>)</strong>' ) |
|
||||
( '<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.
|
||||
@@ -706,10 +784,7 @@ template <class A0, …, class A<strong>n</strong>>
|
||||
<em>… forward to implementation …</em>
|
||||
}
|
||||
|
||||
<span class="vellipsis"> .
|
||||
.
|
||||
.
|
||||
</span>
|
||||
<span class="vellipsis">⋮</span>
|
||||
|
||||
template <class A0, …, class A<strong>m</strong>>
|
||||
<em>result type</em> <strong>name</strong>(
|
||||
@@ -739,7 +814,149 @@ ResultType boost_param_default_ ## __LINE__ ## <strong>name</strong>(
|
||||
</dl>
|
||||
</div>
|
||||
<div class="section">
|
||||
<h2><a class="toc-backref" href="#id44" id="boost-parameter-fun-r-n-l-h-p" name="boost-parameter-fun-r-n-l-h-p">6.2 <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="#id50" id="boost-parameter-member-function-result-name-tag-namespace-arguments" name="boost-parameter-member-function-result-name-tag-namespace-arguments">6.2 <tt class="docutils literal"><span class="pre">BOOST_PARAMETER_MEMBER_FUNCTION(result,name,tag_namespace,arguments)</span></tt></a></h2>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field"><th class="field-name">Defined in:</th><td class="field-body"><a class="reference" href="../../../../boost/parameter/preprocessor.hpp">boost/parameter/preprocessor.hpp</a></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p>See <tt class="docutils literal"><span class="pre">BOOST_PARAMETER_FUNCTION(result,name,tag_namespace,arguments)</span></tt></p>
|
||||
</div>
|
||||
<div class="section">
|
||||
<h2><a class="toc-backref" href="#id51" id="boost-parameter-constructor-cls-impl-tag-namespace-arguments" name="boost-parameter-constructor-cls-impl-tag-namespace-arguments">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>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field"><th class="field-name">Defined in:</th><td class="field-body"><a class="reference" href="../../../../boost/parameter/preprocessor.hpp">boost/parameter/preprocessor.hpp</a></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field"><th class="field-name">Requires:</th><td class="field-body"><p class="first"><tt class="docutils literal"><span class="pre">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
|
||||
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>
|
||||
</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>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<dl class="docutils">
|
||||
<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>
|
||||
</ul>
|
||||
<pre class="last literal-block">
|
||||
struct boost_param_params_ ## __LINE__ ## ctor
|
||||
: boost::parameter::parameters<
|
||||
<em>list of parameter specifications, based on arguments</em>
|
||||
>
|
||||
{};
|
||||
|
||||
typedef boost_param_params_ ## __LINE__ ## <strong>name</strong>
|
||||
constructor_parameters ## __LINE__;
|
||||
|
||||
template <class A0, …, class A<strong>n</strong>>
|
||||
<em>cls</em>(A0 const& a0, …, A<strong>n</strong> const& a<strong>n</strong>)
|
||||
: <em>impl</em>(constructor_parameters ## __LINE__(a0, …, a<strong>n</strong>))
|
||||
{}
|
||||
|
||||
<span class="vellipsis">⋮</span>
|
||||
|
||||
template <class A0, …, class A<strong>m</strong>>
|
||||
<em>cls</em>(A0 const& a0, …, A<strong>n</strong> const& a<strong>m</strong>)
|
||||
: <em>impl</em>(constructor_parameters ## __LINE__(a0, …, a<strong>m</strong>))
|
||||
{}
|
||||
</pre>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="section">
|
||||
<h2><a class="toc-backref" href="#id52" id="boost-parameter-name-name" name="boost-parameter-name-name">6.4 <tt class="docutils literal"><span class="pre">BOOST_PARAMETER_NAME(name)</span></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>
|
||||
<pre class="literal-block">
|
||||
(<em>tag-name</em>, <em>namespace-name</em>) <em>object-name</em>
|
||||
</pre>
|
||||
<p><strong>then</strong></p>
|
||||
<pre class="literal-block">
|
||||
namespace <em>namespace-name</em>
|
||||
{
|
||||
struct <em>tag-name</em>
|
||||
{
|
||||
static char const* keyword_name()
|
||||
{
|
||||
return ##<em>tag-name</em>;
|
||||
}
|
||||
|
||||
typedef <em>implementation defined</em> _;
|
||||
typedef <em>implementation defined</em> _1;
|
||||
};
|
||||
}
|
||||
|
||||
::boost::parameter::keyword<<em>tag-namespace</em>::<em>tag-name</em>> const& <em>object-name</em>
|
||||
= ::boost::parameter::keyword<<em>tag-namespace</em>::<em>tag-name</em>>::instance;
|
||||
</pre>
|
||||
<p><strong>Else</strong></p>
|
||||
<pre class="literal-block">
|
||||
namespace tag
|
||||
{
|
||||
struct <em>name</em>
|
||||
{
|
||||
static char const* keyword_name()
|
||||
{
|
||||
return ##<em>name</em>;
|
||||
}
|
||||
|
||||
typedef <em>implementation defined</em> _;
|
||||
typedef <em>implementation defined</em> _1;
|
||||
};
|
||||
}
|
||||
|
||||
::boost::parameter::keyword<tag::<em>name</em>> const& _<em>name</em>
|
||||
= ::boost::parameter::keyword<tag::<em>name</em>>::instance;
|
||||
</pre>
|
||||
</div>
|
||||
<div class="section">
|
||||
<h2><a class="toc-backref" href="#id53" id="boost-parameter-template-keyword-name" name="boost-parameter-template-keyword-name">6.5 <tt class="docutils literal"><span class="pre">BOOST_PARAMETER_TEMPLATE_KEYWORD(name)</span></tt></a></h2>
|
||||
<p>Expands to:</p>
|
||||
<pre class="literal-block">
|
||||
namespace tag
|
||||
{
|
||||
struct <em>name</em>;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
struct <em>name</em>
|
||||
: ::boost::parameter::template_keyword<tag::<em>name</em>, T>
|
||||
{};
|
||||
</pre>
|
||||
</div>
|
||||
<div class="section">
|
||||
<h2><a class="toc-backref" href="#id54" id="boost-parameter-fun-r-n-l-h-p" name="boost-parameter-fun-r-n-l-h-p">6.6 <tt class="docutils literal"><span class="pre">BOOST_PARAMETER_FUN(r,n,l,h,p)</span></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>
|
||||
</div>
|
||||
<p>Generates a sequence of <a class="reference" href="index.html#forwarding-functions">forwarding function</a> templates named
|
||||
<tt class="docutils literal"><span class="pre">n</span></tt>, with arities ranging from <tt class="docutils literal"><span class="pre">l</span></tt> to <tt class="docutils literal"><span class="pre">h</span></tt> , returning <tt class="docutils literal"><span class="pre">r</span></tt>,
|
||||
and using <tt class="docutils literal"><span class="pre">p</span></tt> to control overload resolution and assign tags to
|
||||
@@ -779,10 +996,10 @@ r name(
|
||||
, typename <strong>p</strong>::match<A1,A2,…A<strong>l</strong>,A##<a class="reference" href="../../../preprocessor/doc/ref/inc.html">BOOST_PP_INC</a>(<strong>l</strong>)>::type p = <strong>p</strong>())
|
||||
{
|
||||
return <strong>name</strong>_with_named_params(<strong>p</strong>(x1,x2,…x<strong>l</strong>,x##<a class="reference" href="../../../preprocessor/doc/ref/inc.html">BOOST_PP_INC</a>(<strong>l</strong>)));
|
||||
} <span class="vellipsis"> .
|
||||
.
|
||||
.
|
||||
</span>
|
||||
}
|
||||
|
||||
<span class="vellipsis">⋮</span>
|
||||
|
||||
template <class A1, class A2, …class A<strong>h</strong>>
|
||||
r name(
|
||||
A1 const& a1, A2 const& a2, …A<strong>h</strong> const& x<strong>h</strong>
|
||||
@@ -795,7 +1012,12 @@ r name(
|
||||
</dl>
|
||||
</div>
|
||||
<div class="section">
|
||||
<h2><a class="toc-backref" href="#id45" id="boost-parameter-keyword-n-k" name="boost-parameter-keyword-n-k">6.3 <tt class="docutils literal"><span class="pre">BOOST_PARAMETER_KEYWORD(n,k)</span></tt></a></h2>
|
||||
<h2><a class="toc-backref" href="#id55" id="boost-parameter-keyword-n-k" name="boost-parameter-keyword-n-k">6.7 <tt class="docutils literal"><span class="pre">BOOST_PARAMETER_KEYWORD(n,k)</span></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>
|
||||
</div>
|
||||
<p>Generates the declaration of a <a class="reference" href="#keyword-tag-type">keyword tag type</a> named <tt class="docutils literal"><span class="pre">k</span></tt> in
|
||||
namespace <tt class="docutils literal"><span class="pre">n</span></tt>, and a corresponding <a class="reference" href="#keyword-object">keyword object</a> definition in
|
||||
the enclosing namespace.</p>
|
||||
@@ -820,7 +1042,7 @@ namespace {
|
||||
</dl>
|
||||
</div>
|
||||
<div class="section">
|
||||
<h2><a class="toc-backref" href="#id46" id="boost-parameter-match-p-a-x" name="boost-parameter-match-p-a-x">6.4 <tt class="docutils literal"><span class="pre">BOOST_PARAMETER_MATCH(p,a,x)</span></tt></a></h2>
|
||||
<h2><a class="toc-backref" href="#id56" id="boost-parameter-match-p-a-x" name="boost-parameter-match-p-a-x">6.8 <tt class="docutils literal"><span class="pre">BOOST_PARAMETER_MATCH(p,a,x)</span></tt></a></h2>
|
||||
<p>Generates a defaulted parameter declaration for a <a class="reference" href="index.html#forwarding-functions">forwarding
|
||||
function</a>.</p>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
@@ -854,9 +1076,9 @@ typename <strong>p</strong>::match<<strong>A0</strong>,<strong>A1</strong>…
|
||||
</div>
|
||||
</div>
|
||||
<div class="section">
|
||||
<h1><a class="toc-backref" href="#id47" id="configuration-macros" name="configuration-macros">7 Configuration Macros</a></h1>
|
||||
<h1><a class="toc-backref" href="#id57" id="configuration-macros" name="configuration-macros">7 Configuration Macros</a></h1>
|
||||
<div class="section">
|
||||
<h2><a class="toc-backref" href="#id48" id="boost-parameter-max-arity" name="boost-parameter-max-arity">7.1 <tt class="docutils literal"><span class="pre">BOOST_PARAMETER_MAX_ARITY</span></tt></a></h2>
|
||||
<h2><a class="toc-backref" href="#id58" id="boost-parameter-max-arity" name="boost-parameter-max-arity">7.1 <tt class="docutils literal"><span class="pre">BOOST_PARAMETER_MAX_ARITY</span></tt></a></h2>
|
||||
<p>Determines the maximum number of arguments supported by the
|
||||
library. Will only be <tt class="docutils literal"><span class="pre">#defined</span></tt> by the library if it is not
|
||||
already <tt class="docutils literal"><span class="pre">#defined</span></tt>.</p>
|
||||
@@ -879,7 +1101,7 @@ already <tt class="docutils literal"><span class="pre">#defined</span></tt>.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section">
|
||||
<h1><a class="toc-backref" href="#id49" id="tutorial" name="tutorial">8 Tutorial</a></h1>
|
||||
<h1><a class="toc-backref" href="#id59" id="tutorial" name="tutorial">8 Tutorial</a></h1>
|
||||
<p>Follow <a class="reference" href="index.html#tutorial">this link</a> to the Boost.Parameter tutorial
|
||||
documentation.</p>
|
||||
<hr class="docutils" />
|
||||
@@ -897,7 +1119,7 @@ where it could make a difference.</td></tr>
|
||||
<table class="docutils footnote" frame="void" id="no-result-of" rules="none">
|
||||
<colgroup><col class="label" /><col /></colgroup>
|
||||
<tbody valign="top">
|
||||
<tr><td class="label"><a name="no-result-of">[2]</a></td><td><em>(<a class="fn-backref" href="#id11">1</a>, <a class="fn-backref" href="#id17">2</a>)</em> Where <a class="reference" href="../../../utility/utility.htm#BOOST_NO_RESULT_OF"><tt class="docutils literal"><span class="pre">BOOST_NO_RESULT_OF</span></tt></a> is <tt class="docutils literal"><span class="pre">#defined</span></tt>,
|
||||
<tr><td class="label"><a name="no-result-of">[2]</a></td><td><em>(<a class="fn-backref" href="#id11">1</a>, <a class="fn-backref" href="#id18">2</a>)</em> Where <a class="reference" href="../../../utility/utility.htm#BOOST_NO_RESULT_OF"><tt class="docutils literal"><span class="pre">BOOST_NO_RESULT_OF</span></tt></a> is <tt class="docutils literal"><span class="pre">#defined</span></tt>,
|
||||
<tt class="docutils literal"><span class="pre">boost::</span></tt><a class="reference" href="../../../utility/utility.htm#result_of"><tt class="docutils literal"><span class="pre">result_of</span></tt></a><tt class="docutils literal"><span class="pre"><F()>::type</span></tt> is replaced by
|
||||
<tt class="docutils literal"><span class="pre">F::result_type</span></tt>.</td></tr>
|
||||
</tbody>
|
||||
@@ -906,7 +1128,7 @@ where it could make a difference.</td></tr>
|
||||
</div>
|
||||
<div class="footer">
|
||||
<hr class="footer" />
|
||||
Generated on: 2007-01-03 17:02 UTC.
|
||||
Generated on: 2007-05-03 14:17 UTC.
|
||||
Generated by <a class="reference" href="http://docutils.sourceforge.net/">Docutils</a> from <a class="reference" href="http://docutils.sourceforge.net/rst.html">reStructuredText</a> source.
|
||||
|
||||
</div>
|
||||
|
||||
@@ -19,8 +19,12 @@ img {
|
||||
}
|
||||
|
||||
span.vellipsis {
|
||||
line-height: 30% ;
|
||||
font-size: 200% ;
|
||||
display: block;
|
||||
width: 5px;
|
||||
height: 22px;
|
||||
background: url("vellipsis.gif");
|
||||
margin-left: 3em;
|
||||
text-indent: -1000px;
|
||||
}
|
||||
|
||||
|
||||
|
||||
BIN
doc/html/vellipsis.gif
Executable file
BIN
doc/html/vellipsis.gif
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 62 B |
@@ -1067,8 +1067,8 @@ With the declaration above, the following two calls are equivalent:
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
def("f", f, **some_policies**, **"Documentation for f"**);
|
||||
def("f", f, **"Documentation for f"**, **some_policies**);
|
||||
def("f", &f, **some_policies**, **"Documentation for f"**);
|
||||
def("f", &f, **"Documentation for f"**, **some_policies**);
|
||||
|
||||
.. @example.prepend('''
|
||||
int main()
|
||||
@@ -1081,7 +1081,7 @@ specify the parameter name explicitly, as follows:
|
||||
.. parsed-literal::
|
||||
|
||||
def(
|
||||
"f", f
|
||||
"f", &f
|
||||
, **_policies = some_policies**, "Documentation for f");
|
||||
|
||||
.. @example.append('}')
|
||||
@@ -1114,7 +1114,8 @@ be used within the body of a class::
|
||||
};
|
||||
|
||||
.. @example.prepend('''
|
||||
#include <boost/parameter.hpp>''')
|
||||
#include <boost/parameter.hpp>
|
||||
#include <iostream>''')
|
||||
|
||||
.. @test('compile')
|
||||
|
||||
@@ -1701,7 +1702,10 @@ its function call operator:
|
||||
, optional<tag::\ index, is_convertible<_,int> >
|
||||
> spec;
|
||||
|
||||
int z0 = print_name_and_index( **spec(**\ "sam", 12\ **)** );
|
||||
char const sam[] = "sam";
|
||||
int twelve = 12;
|
||||
|
||||
int z0 = print_name_and_index( **spec(**\ sam, twelve\ **)** );
|
||||
|
||||
int z1 = print_name_and_index(
|
||||
**spec(**\ _index=12, _name="sam"\ **)**
|
||||
@@ -1720,6 +1724,11 @@ its function call operator:
|
||||
|
||||
.. @test('run', howmany='all')
|
||||
|
||||
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
|
||||
|
||||
Extracting Parameter Types
|
||||
==========================
|
||||
|
||||
@@ -1770,7 +1779,9 @@ case we can use the ``binding< … >`` metafunction introduced
|
||||
BOOST_PARAMETER_NAME(index)
|
||||
|
||||
template <class ArgumentPack>
|
||||
typename parameter::binding<ArgumentPack, tag::index, int>::type
|
||||
typename remove_reference<
|
||||
typename parameter::binding<ArgumentPack, tag::index, int>::type
|
||||
>::type
|
||||
twice_index(ArgumentPack const& args)
|
||||
{
|
||||
return 2 * args[_index|42];
|
||||
@@ -1778,21 +1789,44 @@ case we can use the ``binding< … >`` metafunction introduced
|
||||
|
||||
int six = twice_index(_index = 3);
|
||||
|
||||
.. TODO: binding<> returns a reference. We should use value_type<> here.
|
||||
|
||||
.. @example.prepend('''
|
||||
#include <boost/parameter.hpp>
|
||||
#include <boost/type_traits/remove_reference.hpp>
|
||||
#include <cassert>
|
||||
|
||||
namespace parameter = boost::parameter;''')
|
||||
namespace parameter = boost::parameter;
|
||||
using boost::remove_reference;''')
|
||||
|
||||
Note that the ``remove_reference< … >`` dance is necessary because
|
||||
``binding< … >`` will return a reference type when the argument
|
||||
is bound in the argument pack. If we don't strip the reference we
|
||||
end up returning a reference to the temporary created in the ``2 * …``
|
||||
expression. A convenient shortcut would be to use the ``value_type< … >``
|
||||
metafunction:
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
template <class ArgumentPack>
|
||||
typename **parameter::value_type<ArgumentPack, tag::index, int>**::type
|
||||
twice_index(ArgumentPack const& args)
|
||||
{
|
||||
return 2 * args[_index|42];
|
||||
}
|
||||
|
||||
.. @example.wrap('namespace with_value_type {', '''
|
||||
int six = twice_index(_index = 3);
|
||||
}''')
|
||||
|
||||
.. TODO: binding<> returns a reference. We should use value_type<> here.
|
||||
|
||||
.. @example.append('''
|
||||
int main()
|
||||
{
|
||||
assert(six == 6);
|
||||
assert(with_value_type::six == 6);
|
||||
}''')
|
||||
|
||||
.. @test('run')
|
||||
.. @test('run', howmany='all')
|
||||
|
||||
__ binding_intro_
|
||||
|
||||
@@ -1837,21 +1871,31 @@ when using |ArgumentPack|\ s explicitly, we need a tool other than
|
||||
In the example above, the string ``"hello, world"`` is constructed
|
||||
despite the fact that the user passed us a value for ``s3``. To
|
||||
remedy that, we can compute the default value *lazily* (that is,
|
||||
only on demand), by combining the logical-or (“``||``”) operator
|
||||
with a function object built by the Boost Lambda_ library: [#bind]_
|
||||
only on demand), by using ``boost::bind()`` to create a function
|
||||
object.
|
||||
|
||||
.. danielw: I'm leaving the text below in the source, because we might
|
||||
.. want to change back to it after 1.34, and if I remove it now we
|
||||
.. might forget about it.
|
||||
|
||||
.. by combining the logical-or (“``||``”) operator
|
||||
.. with a function object built by the Boost Lambda_ library: [#bind]_
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
namespace lambda = boost::lambda;
|
||||
using boost::bind;
|
||||
using boost::ref;
|
||||
|
||||
typename parameter::binding<
|
||||
ArgumentPack, tag::s3, std::string
|
||||
>::type s3 = args[_s3 **|| (lambda::var(s1)+lambda::var(s2))** ];
|
||||
>::type s3 = args[_s3 **|| bind(std::plus<std::string>(), ref(s1), ref(s2))** ];
|
||||
|
||||
.. @example.prepend('''
|
||||
#include <boost/lambda/lambda.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/ref.hpp>
|
||||
#include <boost/parameter.hpp>
|
||||
#include <string>
|
||||
#include <functional>
|
||||
|
||||
namespace parameter = boost::parameter;
|
||||
|
||||
@@ -1876,7 +1920,7 @@ with a function object built by the Boost Lambda_ library: [#bind]_
|
||||
|
||||
.. @test('run')
|
||||
|
||||
.. _Lambda: ../../../lambda/index.html
|
||||
.. .. _Lambda: ../../../lambda/index.html
|
||||
|
||||
.. sidebar:: Mnemonics
|
||||
|
||||
@@ -1886,10 +1930,15 @@ with a function object built by the Boost Lambda_ library: [#bind]_
|
||||
Similarly, in ``color_map[param||f]``, ``f`` is only invoked if
|
||||
no ``color_map`` argument was supplied.
|
||||
|
||||
The expression ``lambda::var(s1)+lambda::var(s2)`` yields a
|
||||
*function object* that, when invoked, adds the two strings
|
||||
together. That function will only be invoked if no ``s3`` argument
|
||||
is supplied by the caller.
|
||||
The expression ``bind(std::plus<std::string>(), ref(s1), ref(s2))`` yields
|
||||
a *function object* that, when invoked, adds the two strings together.
|
||||
That function will only be invoked if no ``s3`` argument is supplied by
|
||||
the caller.
|
||||
|
||||
.. The expression ``lambda::var(s1)+lambda::var(s2)`` yields a
|
||||
.. *function object* that, when invoked, adds the two strings
|
||||
.. together. That function will only be invoked if no ``s3`` argument
|
||||
.. is supplied by the caller.
|
||||
|
||||
================
|
||||
Best Practices
|
||||
@@ -2251,17 +2300,17 @@ __ ../../../graph/doc/bgl_named_params.html
|
||||
|
||||
.. _`ConceptC++`: http://www.generic-programming.org/software/ConceptGCC/
|
||||
|
||||
.. [#bind] The Lambda library is known not to work on `some
|
||||
less-conformant compilers`__. When using one of those you could
|
||||
use `Boost.Bind`_ to generate the function object::
|
||||
.. .. [#bind] The Lambda library is known not to work on `some
|
||||
.. less-conformant compilers`__. When using one of those you could
|
||||
.. use `Boost.Bind`_ to generate the function object::
|
||||
|
||||
boost::bind(std::plus<std::string>(),s1,s2)
|
||||
.. boost::bind(std::plus<std::string>(),s1,s2)
|
||||
|
||||
.. [#is_keyword_expression] Here we're assuming there's a predicate
|
||||
metafunction ``is_keyword_expression`` that can be used to
|
||||
identify models of Boost.Python's KeywordExpression concept.
|
||||
|
||||
__ http://www.boost.org/regression/release/user/lambda.html
|
||||
.. .. __ http://www.boost.org/regression/release/user/lambda.html
|
||||
.. _Boost.Bind: ../../../bind/index.html
|
||||
|
||||
|
||||
|
||||
@@ -132,7 +132,8 @@ Python we use the binding utility ``boost::parameter::python::function``.
|
||||
and pass to ``boost::python::class_::def()``.
|
||||
|
||||
To use ``boost::parameter::python::function`` we first need to define
|
||||
a class with forwarding overloads.
|
||||
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.
|
||||
|
||||
::
|
||||
|
||||
@@ -204,7 +205,9 @@ 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``.
|
||||
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
|
||||
@@ -295,8 +298,10 @@ the **arity range** of ``mpl::vector2<x(int),y*(int)>`` is ``[2,2]`` and the
|
||||
|
||||
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. 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:
|
||||
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::
|
||||
|
||||
@@ -351,18 +356,20 @@ docs. The example uses a different technique, but could also have been written l
|
||||
|
||||
.. @build()
|
||||
|
||||
.. _example: index.html#dispatching-based-on-the-presence-of-a-default
|
||||
.. .. _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. 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.
|
||||
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.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -253,7 +253,7 @@ argument type. In each row,
|
||||
+----------------------+--------------+--------------------------------+
|
||||
|Type |``A`` required|Condition ``A`` must satisfy |
|
||||
+======================+==============+================================+
|
||||
||keyword|_\ ``<K>`` |no |*n/a* |
|
||||
|``K`` |no |*n/a* |
|
||||
+----------------------+--------------+--------------------------------+
|
||||
||optional|_\ ``<K,F>``|no |``mpl::apply<F,A>::type::value``|
|
||||
| | |is ``true``. |
|
||||
@@ -381,16 +381,15 @@ __ ../../../../boost/parameter/parameters.hpp
|
||||
};
|
||||
|
||||
template <class A0>
|
||||
|ArgumentPack|_ `operator()`_\(A0 const& a0) const;
|
||||
|ArgumentPack|_ `operator()`_\(A0& a0) const;
|
||||
|
||||
template <class A0, class A1>
|
||||
|ArgumentPack|_ `operator()`_\(A0 const& a0, A1 const& a1) const; :vellipsis:`\
|
||||
.
|
||||
.
|
||||
.
|
||||
`
|
||||
|ArgumentPack|_ `operator()`_\(A0& a0, A1& a1) const;
|
||||
|
||||
:vellipsis:`⋮`
|
||||
|
||||
template <class A0, class A1, …class A\ β>
|
||||
|ArgumentPack|_ `operator()`_\(A0 const& a0, A1 const& a1, …A\ β const& a\ β) const;
|
||||
|ArgumentPack|_ `operator()`_\(A0& a0, A1& a1, …A\ β& a\ β) const;
|
||||
};
|
||||
|
||||
|
||||
@@ -403,13 +402,22 @@ __ ../../../../boost/parameter/parameters.hpp
|
||||
follows, for any argument type ``A``\ *i*:
|
||||
|
||||
|
||||
| let ``D0`` the set [d0, …, d\ *j*] of all **deduced** *parameter specs* in [``P0``, …, ``P``\ β]
|
||||
| ``R``\ *i* is ``A``\ *i*\ 's |intended argument type|
|
||||
|
|
||||
| if ``A``\ *i* is a result type of ``keyword<T>::``\ |operator=|_
|
||||
| then
|
||||
| ``K``\ *i* is ``T``
|
||||
| else
|
||||
| ``K``\ *i* is ``P``\ *i*\ 's |keyword tag type|.
|
||||
| if ``A``\ *i* is a result type of ``keyword<T>::``\ |operator=|_
|
||||
| then
|
||||
| ``K``\ *i* is ``T``
|
||||
| else
|
||||
| if some ``A``\ *j* where *j*\ ≤\ *i* is a result type of ``keyword<T>::``\ |operator=|_
|
||||
| *or* some ``P``\ *j* in *j*\ ≤\ *i* is **deduced**
|
||||
| then
|
||||
| if some *parameter spec* ``d``\ *j* in ``D``\ *i* matches ``A``\ *i*
|
||||
| then
|
||||
| ``K``\ *i* is ``d``\ *j*\ 's |keyword tag type|.
|
||||
| ``D``\ :sub:`i+1` is ``D``\ *i* - [``d``\ *j*]
|
||||
| else
|
||||
| ``K``\ *i* is ``P``\ *i*\ 's |keyword tag type|.
|
||||
|
||||
|
||||
.. _match:
|
||||
@@ -425,7 +433,7 @@ __ ../../../../boost/parameter/parameters.hpp
|
||||
every *j* in 0…β, either:
|
||||
|
||||
* ``P``\ *j* is the *unspecified* default
|
||||
* **or**, ``P``\ *j* is a specialization of |keyword|_,
|
||||
* **or**, ``P``\ *j* is a *keyword tag type*
|
||||
|
||||
* **or**, ``P``\ *j* is |optional|_ ``<X,F>`` and either
|
||||
|
||||
@@ -443,11 +451,10 @@ __ ../../../../boost/parameter/parameters.hpp
|
||||
``operator()``
|
||||
.. parsed-literal::
|
||||
|
||||
template <class A0> |ArgumentPack|_ operator()(A0 const& a0) const; :vellipsis:`\
|
||||
.
|
||||
.
|
||||
.
|
||||
`
|
||||
template <class A0> |ArgumentPack|_ operator()(A0 const& a0) const;
|
||||
|
||||
:vellipsis:`⋮`
|
||||
|
||||
template <class A0, …class A\ β> |ArgumentPack|_ `operator()`_\(A0 const& a0, …A\ β const& a\ β) const;
|
||||
|
||||
:Returns:
|
||||
@@ -488,6 +495,23 @@ The default value of ``Predicate`` is an unspecified |Metafunction|_ that return
|
||||
.. |Metafunction| replace:: :concept:`Metafunction`
|
||||
.. _Metafunction: ../../../mpl/doc/refmanual/metafunction.html
|
||||
|
||||
|
||||
``deduced``
|
||||
-----------
|
||||
|
||||
This template is used to wrap the *keyword tag* argument to
|
||||
``optional`` or ``required``.
|
||||
|
||||
:Defined in: `boost/parameter/parameters.hpp`__
|
||||
|
||||
__ ../../../../boost/parameter/parameters.hpp
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
template <class Tag>
|
||||
struct deduced;
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Metafunctions
|
||||
@@ -546,6 +570,37 @@ __ ../../../../boost/parameter/binding.hpp
|
||||
reference| exists, returns ``boost::``\ |result_of|_\ ``<F()>::type``. [#no_result_of]_
|
||||
|
||||
|
||||
``value_type``
|
||||
--------------
|
||||
|
||||
Returns the result type of indexing an argument pack with a
|
||||
|keyword tag type| or with a |tagged default|.
|
||||
|
||||
:Defined n: `boost/parameter/value_type.hpp`__
|
||||
|
||||
__ ../../../../boost/parameter/value_type.hpp
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
template <class A, class K, class D = void>
|
||||
struct value_type
|
||||
{
|
||||
typedef … type;
|
||||
};
|
||||
|
||||
:Requires: ``A`` is a model of |ArgumentPack|_.
|
||||
|
||||
:Returns: the type of the |tagged reference| in ``A``
|
||||
having |keyword tag type| ``K``, if any. If no such |tagged
|
||||
reference| exists, returns ``D``. Equivalent to::
|
||||
|
||||
typename remove_reference<
|
||||
typename binding<A, K, D>::type
|
||||
>::type
|
||||
|
||||
… when ``D`` is not a reference type.
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Code Generation Macros
|
||||
@@ -554,6 +609,7 @@ Code Generation Macros
|
||||
Macros in this section can be used to ease the writing of code
|
||||
using the Parameter libray by eliminating repetitive boilerplate.
|
||||
|
||||
|
||||
``BOOST_PARAMETER_FUNCTION(result,name,tag_namespace,arguments)``
|
||||
-----------------------------------------------------------------
|
||||
|
||||
@@ -571,17 +627,20 @@ __ ../../../../boost/parameter/preprocessor.hpp
|
||||
:Argument specifiers syntax:
|
||||
.. parsed-literal::
|
||||
|
||||
argument-specifiers ::= specifier-group {specifier-group}
|
||||
argument-specifiers ::= *specifier-group* {*specifier-group*}
|
||||
|
||||
specifier-group ::= ( '(' 'optional' optional-specifier {optional-specifier} ')' ) |
|
||||
( '(' 'required' required-specifier {required-specifier} ')' )
|
||||
specifier-group0 ::= *specifier-group1* |
|
||||
( '**(**' '**deduced**' *specifier-group1* {*specifier-group1*} '**)**' )
|
||||
|
||||
optional-specifier ::= '(' name ',' restriction ',' default-value ')'
|
||||
required-specifier ::= '(' name ',' restriction ')'
|
||||
specifier-group1 ::= ( '**(**' '**optional**' *optional-specifier* {*optional-specifier*} '**)**' ) |
|
||||
( '**(**' '**required**' *required-specifier* {*required-specifier*} '**)**' )
|
||||
|
||||
restriction ::= ('*' '(' lambda-expression ')' ) |
|
||||
( '(' typename ')' ) |
|
||||
'*'
|
||||
optional-specifier ::= '**(**' *name* '**,**' *restriction* '**,**' *default-value* ')'
|
||||
required-specifier ::= '**(**' *name* '**,**' *restriction* ')'
|
||||
|
||||
restriction ::= ('*****' '**(**' *lambda-expression* '**)**' ) |
|
||||
( '**(**' *typename* '**)**' ) |
|
||||
'*****'
|
||||
|
||||
``name`` is any valid C++ identifier. ``default-value`` is any valid
|
||||
C++ expression. ``typename`` is the name of a type.
|
||||
@@ -631,11 +690,7 @@ Approximate expansion:
|
||||
*… forward to implementation …*
|
||||
}
|
||||
|
||||
:vellipsis:`\
|
||||
.
|
||||
.
|
||||
.
|
||||
`
|
||||
:vellipsis:`⋮`
|
||||
|
||||
template <class A0, …, class A\ **m**>
|
||||
*result type* **name**\ (
|
||||
@@ -661,9 +716,149 @@ Approximate expansion:
|
||||
, *argument name*\ **m** ## _type& *argument name*\ **m**
|
||||
)
|
||||
|
||||
|
||||
|
||||
``BOOST_PARAMETER_MEMBER_FUNCTION(result,name,tag_namespace,arguments)``
|
||||
------------------------------------------------------------------------
|
||||
|
||||
:Defined in: `boost/parameter/preprocessor.hpp`__
|
||||
|
||||
__ ../../../../boost/parameter/preprocessor.hpp
|
||||
|
||||
See ``BOOST_PARAMETER_FUNCTION(result,name,tag_namespace,arguments)``
|
||||
|
||||
|
||||
|
||||
``BOOST_PARAMETER_CONSTRUCTOR(cls, impl, tag_namespace, arguments)``
|
||||
--------------------------------------------------------------------
|
||||
|
||||
:Defined in: `boost/parameter/preprocessor.hpp`__
|
||||
|
||||
__ ../../../../boost/parameter/preprocessor.hpp
|
||||
|
||||
:Requires: ``cls`` is the name of this class. ``impl`` is the
|
||||
parenthesized implementation base class for ``cls``.
|
||||
``tag_namespace`` is the namespace in which the keywords
|
||||
used by the function resides. ``arguments`` is
|
||||
a list of *argument specifiers*, as defined in
|
||||
``BOOST_PARAMETER_FUNCTION(result,name,tag_namespace,arguments)``.
|
||||
|
||||
:Generated names in enclosing scope:
|
||||
* ``boost_param_params_ ## __LINE__ ## ctor``
|
||||
* ``constructor_parameters ## __LINE__``
|
||||
|
||||
Approximate expansion:
|
||||
**Where**:
|
||||
|
||||
* ``n`` denotes the *minimum* arity, as determined from ``arguments``.
|
||||
* ``m`` denotes the *maximum* arity, as determined from ``arguments``.
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
struct boost_param_params\_ ## __LINE__ ## ctor
|
||||
: boost::parameter::parameters<
|
||||
*list of parameter specifications, based on arguments*
|
||||
>
|
||||
{};
|
||||
|
||||
typedef boost_param_params\_ ## __LINE__ ## **name**
|
||||
constructor_parameters ## __LINE__;
|
||||
|
||||
template <class A0, …, class A\ **n**>
|
||||
*cls*\ (A0 const& a0, …, A\ **n** const& a\ **n**)
|
||||
: *impl*\ (constructor_parameters ## __LINE__(a0, …, a\ **n**))
|
||||
{}
|
||||
|
||||
:vellipsis:`⋮`
|
||||
|
||||
template <class A0, …, class A\ **m**>
|
||||
*cls*\ (A0 const& a0, …, A\ **n** const& a\ **m**)
|
||||
: *impl*\ (constructor_parameters ## __LINE__(a0, …, a\ **m**))
|
||||
{}
|
||||
|
||||
|
||||
``BOOST_PARAMETER_NAME(name)``
|
||||
------------------------------
|
||||
|
||||
Declares a tag-type and keyword object.
|
||||
|
||||
Expands to:
|
||||
|
||||
**If** *name* is of the form:
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
(*tag-name*, *namespace-name*) *object-name*
|
||||
|
||||
**then**
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
namespace *namespace-name*
|
||||
{
|
||||
struct *tag-name*
|
||||
{
|
||||
static char const* keyword_name()
|
||||
{
|
||||
return ##\ *tag-name*;
|
||||
}
|
||||
|
||||
typedef *implementation defined* _;
|
||||
typedef *implementation defined* _1;
|
||||
};
|
||||
}
|
||||
|
||||
::boost::parameter::keyword<*tag-namespace*\ ::\ *tag-name*\ > const& *object-name*
|
||||
= ::boost::parameter::keyword<*tag-namespace*\ ::\ *tag-name*\ >::instance;
|
||||
|
||||
**Else**
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
namespace tag
|
||||
{
|
||||
struct *name*
|
||||
{
|
||||
static char const* keyword_name()
|
||||
{
|
||||
return ##\ *name*;
|
||||
}
|
||||
|
||||
typedef *implementation defined* _;
|
||||
typedef *implementation defined* _1;
|
||||
};
|
||||
}
|
||||
|
||||
::boost::parameter::keyword<tag::\ *name*\ > const& _\ *name*
|
||||
= ::boost::parameter::keyword<tag::\ *name*\ >::instance;
|
||||
|
||||
|
||||
``BOOST_PARAMETER_TEMPLATE_KEYWORD(name)``
|
||||
------------------------------------------
|
||||
|
||||
Expands to:
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
namespace tag
|
||||
{
|
||||
struct *name*;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
struct *name*
|
||||
: ::boost::parameter::template_keyword<tag::\ *name*, T>
|
||||
{};
|
||||
|
||||
|
||||
``BOOST_PARAMETER_FUN(r,n,l,h,p)``
|
||||
----------------------------------
|
||||
|
||||
.. admonition:: Deprecated
|
||||
|
||||
This macro has been deprecated in favor of
|
||||
``BOOST_PARAMETER_FUNCTION``.
|
||||
|
||||
Generates a sequence of `forwarding function`_ templates named
|
||||
``n``, with arities ranging from ``l`` to ``h`` , returning ``r``,
|
||||
and using ``p`` to control overload resolution and assign tags to
|
||||
@@ -694,11 +889,10 @@ Generates
|
||||
, typename **p**::match<A1,A2,…A\ **l**,A\ ##\ BOOST_PP_INC_\ (**l**)>::type p = **p**\ ())
|
||||
{
|
||||
return **name**\ _with_named_params(**p**\ (x1,x2,…x\ **l**,x\ ##\ BOOST_PP_INC_\ (**l**)));
|
||||
} :vellipsis:`\
|
||||
.
|
||||
.
|
||||
.
|
||||
`
|
||||
}
|
||||
|
||||
:vellipsis:`⋮`
|
||||
|
||||
template <class A1, class A2, …class A\ **h**>
|
||||
r name(
|
||||
A1 const& a1, A2 const& a2, …A\ **h** const& x\ **h**
|
||||
@@ -713,6 +907,11 @@ Generates
|
||||
``BOOST_PARAMETER_KEYWORD(n,k)``
|
||||
--------------------------------
|
||||
|
||||
.. admonition:: Deprecated
|
||||
|
||||
This macro has been deprecated in favor of
|
||||
``BOOST_PARAMETER_NAME``.
|
||||
|
||||
Generates the declaration of a |keyword tag type| named ``k`` in
|
||||
namespace ``n``, and a corresponding |keyword object| definition in
|
||||
the enclosing namespace.
|
||||
|
||||
@@ -91,14 +91,18 @@ struct keyword
|
||||
// every instantiation of a function template is the same object.
|
||||
// We provide a reference to a common instance of each keyword
|
||||
// object and prevent construction by users.
|
||||
|
||||
static keyword<Tag> const instance;
|
||||
|
||||
// This interface is deprecated
|
||||
static keyword<Tag>& get()
|
||||
{
|
||||
static keyword<Tag> result;
|
||||
return result;
|
||||
return const_cast<keyword<Tag>&>(instance);
|
||||
}
|
||||
};
|
||||
|
||||
template <class Tag>
|
||||
keyword<Tag> const keyword<Tag>::instance = {};
|
||||
|
||||
// Reduces boilerplate required to declare and initialize keywords
|
||||
// without violating ODR. Declares a keyword tag type with the given
|
||||
// name in namespace tag_namespace, and declares and initializes a
|
||||
@@ -107,19 +111,19 @@ struct keyword
|
||||
|
||||
#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>& name \
|
||||
= ::boost::parameter::keyword<tag_namespace::name>::get();
|
||||
# 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
|
||||
|
||||
@@ -136,8 +140,8 @@ struct keyword
|
||||
} \
|
||||
namespace \
|
||||
{ \
|
||||
::boost::parameter::keyword<tag_namespace::name>& name \
|
||||
= ::boost::parameter::keyword<tag_namespace::name>::get(); \
|
||||
::boost::parameter::keyword<tag_namespace::name> const& name \
|
||||
= ::boost::parameter::keyword<tag_namespace::name>::instance;\
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -76,14 +76,14 @@ struct lambda<
|
||||
|
||||
# if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
||||
# define BOOST_PARAMETER_NAME_OBJECT(tag, name) \
|
||||
static ::boost::parameter::keyword<tag>& name \
|
||||
= ::boost::parameter::keyword<tag>::get();
|
||||
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>& name \
|
||||
= ::boost::parameter::keyword<tag>::get(); \
|
||||
::boost::parameter::keyword<tag> const& name \
|
||||
= ::boost::parameter::keyword<tag>::instance; \
|
||||
}
|
||||
# endif
|
||||
|
||||
|
||||
@@ -835,7 +835,7 @@ struct parameters
|
||||
// !!!NOTE!!!
|
||||
//
|
||||
// The make_arg_list<> produces a reversed arg_list, so
|
||||
// we need to pass the arguments to it's constructor
|
||||
// we need to pass the arguments to its constructor
|
||||
// reversed.
|
||||
//
|
||||
aux::empty_arg_list operator()() const
|
||||
|
||||
@@ -685,7 +685,7 @@ struct funptr_predicate<void**>
|
||||
# define BOOST_PARAMETER_FUNCTION_DEFAULT_EVAL_DEFAULT(arg, tag_namespace) \
|
||||
boost::parameter::keyword< \
|
||||
tag_namespace::BOOST_PARAMETER_FN_ARG_KEYWORD(arg) \
|
||||
>::get() | boost::parameter::aux::use_default_tag()
|
||||
>::instance | boost::parameter::aux::use_default_tag()
|
||||
|
||||
# define BOOST_PARAMETER_FUNCTION_DEFAULT_FUNCTION_GET_ARG(arg, tag_ns) \
|
||||
BOOST_PARAMETER_FUNCTION_CAST( \
|
||||
@@ -834,7 +834,7 @@ struct funptr_predicate<void**>
|
||||
# define BOOST_PARAMETER_FUNCTION_DEFAULT_GET_ARG(r, tag_ns, arg) \
|
||||
, BOOST_PARAMETER_FUNCTION_CAST( \
|
||||
args[ \
|
||||
boost::parameter::keyword<tag_ns::BOOST_PARAMETER_FN_ARG_KEYWORD(arg)>::get() \
|
||||
boost::parameter::keyword<tag_ns::BOOST_PARAMETER_FN_ARG_KEYWORD(arg)>::instance \
|
||||
] \
|
||||
, BOOST_PARAMETER_FN_ARG_PRED(arg) \
|
||||
)
|
||||
|
||||
@@ -107,6 +107,6 @@ int main()
|
||||
|
||||
//f(index = 56, name = 55); // won't compile
|
||||
|
||||
return 0;
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/mpl/assert.hpp>
|
||||
#include <cstring>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
|
||||
namespace test {
|
||||
|
||||
@@ -79,9 +80,9 @@ struct values_t
|
||||
BOOST_MPL_ASSERT((boost::is_same<Value,Value_>));
|
||||
BOOST_MPL_ASSERT((boost::is_same<Name,Name_>));
|
||||
#endif
|
||||
BOOST_ASSERT(equal(n, n_));
|
||||
BOOST_ASSERT(equal(v, v_));
|
||||
BOOST_ASSERT(equal(i, i_));
|
||||
BOOST_TEST(equal(n, n_));
|
||||
BOOST_TEST(equal(v, v_));
|
||||
BOOST_TEST(equal(i, i_));
|
||||
}
|
||||
|
||||
Name const& n;
|
||||
|
||||
Reference in New Issue
Block a user