1<?xml version="1.0" encoding="utf-8" ?> 2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 3<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 4<head> 5<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 6<meta name="generator" content="Docutils 0.12: http://docutils.sourceforge.net/" /> 7<title>The Boost Parameter Library Reference Documentation</title> 8<meta name="authors" content="David Abrahams Daniel Wallin" /> 9<meta name="organization" content="BoostPro Computing" /> 10<meta name="date" content="2005-07-17" /> 11<meta name="copyright" content="Copyright David Abrahams, Daniel Wallin 2005-2009. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)" /> 12<link rel="stylesheet" href="rst.css" type="text/css" /> 13</head> 14<body> 15<div class="document" id="the-boost-parameter-library-reference-documentation"> 16<h1 class="title">The Boost Parameter Library Reference Documentation</h1> 17<table class="docinfo" frame="void" rules="none"> 18<col class="docinfo-name" /> 19<col class="docinfo-content" /> 20<tbody valign="top"> 21<tr><th class="docinfo-name">Authors:</th> 22<td>David Abrahams 23<br />Daniel Wallin</td></tr> 24<tr><th class="docinfo-name">Contact:</th> 25<td><a class="first reference external" href="mailto:dave@boost-consulting.com">dave@boost-consulting.com</a>, <a class="last reference external" href="mailto:daniel@boostpro.com">daniel@boostpro.com</a></td></tr> 26<tr><th class="docinfo-name">Organization:</th> 27<td><a class="first last reference external" href="http://www.boostpro.com">BoostPro Computing</a></td></tr> 28<tr><th class="docinfo-name">Date:</th> 29<td>2005-07-17</td></tr> 30<tr><th class="docinfo-name">Copyright:</th> 31<td>Copyright David Abrahams, Daniel Wallin 322005-2009. Distributed under the Boost Software License, 33Version 1.0. (See accompanying file LICENSE_1_0.txt 34or copy at <a class="reference external" href="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</a>)</td></tr> 35</tbody> 36</table> 37<p><a class="reference external" href="../../../../index.htm"><img alt="Boost" src="../../../../boost.png" /></a></p> 38<hr class="docutils" /> 39<div class="contents topic" id="contents"> 40<p class="topic-title first">Contents</p> 41<ul class="auto-toc simple"> 42<li><a class="reference internal" href="#preliminaries" id="id31">1 Preliminaries</a><ul class="auto-toc"> 43<li><a class="reference internal" href="#namespaces" id="id32">1.1 Namespaces</a></li> 44<li><a class="reference internal" href="#exceptions" id="id33">1.2 Exceptions</a></li> 45<li><a class="reference internal" href="#thread-safety" id="id34">1.3 Thread Safety</a></li> 46<li><a class="reference internal" href="#typography" id="id35">1.4 Typography</a></li> 47</ul> 48</li> 49<li><a class="reference internal" href="#terminology" id="id36">2 Terminology</a></li> 50<li><a class="reference internal" href="#concepts" id="id37">3 Concepts</a><ul class="auto-toc"> 51<li><a class="reference internal" href="#argumentpack" id="id38">3.1 <span class="concept">ArgumentPack</span></a></li> 52<li><a class="reference internal" href="#id3" id="id39">3.2 <span class="concept">ParameterSpec</span></a></li> 53</ul> 54</li> 55<li><a class="reference internal" href="#class-templates" id="id40">4 Class Templates</a><ul class="auto-toc"> 56<li><a class="reference internal" href="#id5" id="id41">4.1 <tt class="docutils literal">keyword</tt></a></li> 57<li><a class="reference internal" href="#id7" id="id42">4.2 <tt class="docutils literal">template_keyword</tt></a></li> 58<li><a class="reference internal" href="#id8" id="id43">4.3 <tt class="docutils literal">parameters</tt></a></li> 59<li><a class="reference internal" href="#optional-required" id="id44">4.4 <tt class="docutils literal">optional</tt>, <tt class="docutils literal">required</tt></a></li> 60<li><a class="reference internal" href="#id9" id="id45">4.5 <tt class="docutils literal">deduced</tt></a></li> 61</ul> 62</li> 63<li><a class="reference internal" href="#metafunctions" id="id46">5 Metafunctions</a><ul class="auto-toc"> 64<li><a class="reference internal" href="#id10" id="id47">5.1 <tt class="docutils literal">binding</tt></a></li> 65<li><a class="reference internal" href="#id11" id="id48">5.2 <tt class="docutils literal">lazy_binding</tt></a></li> 66<li><a class="reference internal" href="#id13" id="id49">5.3 <tt class="docutils literal">value_type</tt></a></li> 67<li><a class="reference internal" href="#id14" id="id50">5.4 <tt class="docutils literal">lazy_value_type</tt></a></li> 68<li><a class="reference internal" href="#id16" id="id51">5.5 <tt class="docutils literal">are_tagged_arguments</tt></a></li> 69<li><a class="reference internal" href="#id17" id="id52">5.6 <tt class="docutils literal">is_argument_pack</tt></a></li> 70<li><a class="reference internal" href="#id18" id="id53">5.7 <tt class="docutils literal"><span class="pre">result_of::compose</span></tt></a></li> 71</ul> 72</li> 73<li><a class="reference internal" href="#function-templates" id="id54">6 Function Templates</a><ul class="auto-toc"> 74<li><a class="reference internal" href="#id19" id="id55">6.1 <tt class="docutils literal">compose</tt></a></li> 75</ul> 76</li> 77<li><a class="reference internal" href="#code-generation-macros" id="id56">7 Code Generation Macros</a><ul class="auto-toc"> 78<li><a class="reference internal" href="#boost-parameter-function-result-name-tag-namespace-arguments" id="id57">7.1 <tt class="docutils literal">BOOST_PARAMETER_FUNCTION(result, name, tag_namespace, arguments)</tt></a></li> 79<li><a class="reference internal" href="#boost-parameter-member-function-result-name-tag-namespace-arguments" id="id58">7.2 <tt class="docutils literal">BOOST_PARAMETER_MEMBER_FUNCTION(result, name, tag_namespace, arguments)</tt></a></li> 80<li><a class="reference internal" href="#boost-parameter-const-member-function-result-name-tag-ns-arguments" id="id59">7.3 <tt class="docutils literal">BOOST_PARAMETER_CONST_MEMBER_FUNCTION(result, name, tag_ns, arguments)</tt></a></li> 81<li><a class="reference internal" href="#boost-parameter-function-call-operator-result-tag-namespace-arguments" id="id60">7.4 <tt class="docutils literal">BOOST_PARAMETER_FUNCTION_CALL_OPERATOR(result, tag_namespace, arguments)</tt></a></li> 82<li><a class="reference internal" href="#boost-parameter-const-function-call-operator-result-tag-ns-arguments" id="id61">7.5 <tt class="docutils literal">BOOST_PARAMETER_CONST_FUNCTION_CALL_OPERATOR(result, tag_ns, arguments)</tt></a></li> 83<li><a class="reference internal" href="#boost-parameter-constructor-cls-impl-tag-namespace-arguments" id="id62">7.6 <tt class="docutils literal">BOOST_PARAMETER_CONSTRUCTOR(cls, impl, tag_namespace, arguments)</tt></a></li> 84<li><a class="reference internal" href="#boost-parameter-basic-function-result-name-tag-namespace-arguments" id="id63">7.7 <tt class="docutils literal">BOOST_PARAMETER_BASIC_FUNCTION(result, name, tag_namespace, arguments)</tt></a></li> 85<li><a class="reference internal" href="#boost-parameter-basic-member-function-result-name-tag-ns-arguments" id="id64">7.8 <tt class="docutils literal">BOOST_PARAMETER_BASIC_MEMBER_FUNCTION(result, name, tag_ns, arguments)</tt></a></li> 86<li><a class="reference internal" href="#boost-parameter-basic-const-member-function-result-name-tag-ns-args" id="id65">7.9 <tt class="docutils literal">BOOST_PARAMETER_BASIC_CONST_MEMBER_FUNCTION(result, name, tag_ns, args)</tt></a></li> 87<li><a class="reference internal" href="#boost-parameter-basic-function-call-operator-result-tag-ns-arguments" id="id66">7.10 <tt class="docutils literal">BOOST_PARAMETER_BASIC_FUNCTION_CALL_OPERATOR(result, tag_ns, arguments)</tt></a></li> 88<li><a class="reference internal" href="#boost-parameter-basic-const-function-call-operator-result-tag-ns-args" id="id67">7.11 <tt class="docutils literal">BOOST_PARAMETER_BASIC_CONST_FUNCTION_CALL_OPERATOR(result, tag_ns, args)</tt></a></li> 89<li><a class="reference internal" href="#boost-parameter-no-spec-function-result-name" id="id68">7.12 <tt class="docutils literal">BOOST_PARAMETER_NO_SPEC_FUNCTION(result, name)</tt></a></li> 90<li><a class="reference internal" href="#boost-parameter-no-spec-member-function-result-name" id="id69">7.13 <tt class="docutils literal">BOOST_PARAMETER_NO_SPEC_MEMBER_FUNCTION(result, name)</tt></a></li> 91<li><a class="reference internal" href="#boost-parameter-no-spec-const-member-function-result-name" id="id70">7.14 <tt class="docutils literal">BOOST_PARAMETER_NO_SPEC_CONST_MEMBER_FUNCTION(result, name)</tt></a></li> 92<li><a class="reference internal" href="#boost-parameter-no-spec-function-call-operator-result" id="id71">7.15 <tt class="docutils literal">BOOST_PARAMETER_NO_SPEC_FUNCTION_CALL_OPERATOR(result)</tt></a></li> 93<li><a class="reference internal" href="#boost-parameter-no-spec-const-function-call-operator-result" id="id72">7.16 <tt class="docutils literal">BOOST_PARAMETER_NO_SPEC_CONST_FUNCTION_CALL_OPERATOR(result)</tt></a></li> 94<li><a class="reference internal" href="#boost-parameter-no-spec-constructor-cls-impl" id="id73">7.17 <tt class="docutils literal">BOOST_PARAMETER_NO_SPEC_CONSTRUCTOR(cls, impl)</tt></a></li> 95<li><a class="reference internal" href="#boost-parameter-no-spec-no-base-constructor-cls-impl" id="id74">7.18 <tt class="docutils literal">BOOST_PARAMETER_NO_SPEC_NO_BASE_CONSTRUCTOR(cls, impl)</tt></a></li> 96<li><a class="reference internal" href="#boost-parameter-name-name" id="id75">7.19 <tt class="docutils literal">BOOST_PARAMETER_NAME(name)</tt></a></li> 97<li><a class="reference internal" href="#boost-parameter-nested-keyword-tag-namespace-name-alias" id="id76">7.20 <tt class="docutils literal">BOOST_PARAMETER_NESTED_KEYWORD(tag_namespace, name, alias)</tt></a></li> 98<li><a class="reference internal" href="#boost-parameter-template-keyword-name" id="id77">7.21 <tt class="docutils literal">BOOST_PARAMETER_TEMPLATE_KEYWORD(name)</tt></a></li> 99<li><a class="reference internal" href="#boost-parameter-fun-r-n-l-h-p" id="id78">7.22 <tt class="docutils literal">BOOST_PARAMETER_FUN(r, n, l, h, p)</tt></a></li> 100<li><a class="reference internal" href="#boost-parameter-keyword-n-k" id="id79">7.23 <tt class="docutils literal">BOOST_PARAMETER_KEYWORD(n, k)</tt></a></li> 101<li><a class="reference internal" href="#boost-parameter-match-p-a-x" id="id80">7.24 <tt class="docutils literal">BOOST_PARAMETER_MATCH(p, a, x)</tt></a></li> 102</ul> 103</li> 104<li><a class="reference internal" href="#configuration-macros" id="id81">8 Configuration Macros</a><ul class="auto-toc"> 105<li><a class="reference internal" href="#id21" id="id82">8.1 <tt class="docutils literal">BOOST_PARAMETER_HAS_PERFECT_FORWARDING</tt></a></li> 106<li><a class="reference internal" href="#id22" id="id83">8.2 <tt class="docutils literal">BOOST_PARAMETER_DISABLE_PERFECT_FORWARDING</tt></a></li> 107<li><a class="reference internal" href="#id23" id="id84">8.3 <tt class="docutils literal">BOOST_PARAMETER_CAN_USE_MP11</tt></a></li> 108<li><a class="reference internal" href="#id24" id="id85">8.4 <tt class="docutils literal">BOOST_PARAMETER_DISABLE_MP11_USAGE</tt></a></li> 109<li><a class="reference internal" href="#id25" id="id86">8.5 <tt class="docutils literal">BOOST_PARAMETER_VARIADIC_MPL_SEQUENCE</tt></a></li> 110<li><a class="reference internal" href="#id26" id="id87">8.6 <tt class="docutils literal">BOOST_PARAMETER_MAX_ARITY</tt></a></li> 111<li><a class="reference internal" href="#id27" id="id88">8.7 <tt class="docutils literal">BOOST_PARAMETER_COMPOSE_MAX_ARITY</tt></a></li> 112<li><a class="reference internal" href="#id28" id="id89">8.8 <tt class="docutils literal">BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY</tt></a></li> 113<li><a class="reference internal" href="#outside-of-this-library" id="id90">8.9 ...Outside Of This Library</a></li> 114</ul> 115</li> 116<li><a class="reference internal" href="#tutorial" id="id91">9 Tutorial</a></li> 117</ul> 118</div> 119<hr class="docutils" /> 120<div class="section" id="preliminaries"> 121<h1><a class="toc-backref" href="#id31">1 Preliminaries</a></h1> 122<p>This section covers some basic information you'll need to know in order to 123understand this reference.</p> 124<div class="section" id="namespaces"> 125<h2><a class="toc-backref" href="#id32">1.1 Namespaces</a></h2> 126<p>In this document, all unqualified identifiers should be assumed to be defined 127in namespace <tt class="docutils literal"><span class="pre">boost::parameter</span></tt> unless otherwise specified.</p> 128</div> 129<div class="section" id="exceptions"> 130<h2><a class="toc-backref" href="#id33">1.2 Exceptions</a></h2> 131<p>No operation described in this document throws an exception unless otherwise 132specified.</p> 133</div> 134<div class="section" id="thread-safety"> 135<h2><a class="toc-backref" href="#id34">1.3 Thread Safety</a></h2> 136<p>All components of this library can be used safely from multiple threads 137without synchronization.<a class="footnote-reference" href="#thread" id="id2"><sup>1</sup></a></p> 138</div> 139<div class="section" id="typography"> 140<h2><a class="toc-backref" href="#id35">1.4 Typography</a></h2> 141<p>Names written in <span class="concept">sans serif type</span> represent <a class="reference internal" href="#concepts">concepts</a>.</p> 142<p>In code blocks, <em>italic type</em> represents unspecified text that satisfies the 143requirements given in the detailed description that follows the code block.</p> 144<p>In a specification of the tokens generated by a macro, <strong>bold type</strong> is used 145to highlight the position of the expanded macro argument in the result.</p> 146<p>The special character β represents the value of <a class="reference internal" href="#boost-parameter-max-arity"><tt class="docutils literal">BOOST_PARAMETER_MAX_ARITY</tt></a>.</p> 147</div> 148</div> 149<hr class="docutils" /> 150<div class="section" id="terminology"> 151<h1><a class="toc-backref" href="#id36">2 Terminology</a></h1> 152<dl class="docutils" id="kw"> 153<dt>keyword</dt> 154<dd>The name of a function parameter.</dd> 155</dl> 156<span class="target" id="keyword-tag-type"></span><dl class="docutils"> 157<dt>keyword tag type</dt> 158<dd>A type used to uniquely identify a function parameter. Typically its name 159will be the same as that of the parameter.</dd> 160</dl> 161<span class="target" id="positional"></span><dl class="docutils"> 162<dt>positional argument</dt> 163<dd>An argument passed with no explicit keyword. Its parameter is determined 164in the usual C++ way: by position with respect to a parameter list.</dd> 165</dl> 166<span class="target" id="tag-type"></span><dl class="docutils"> 167<dt>tag type</dt> 168<dd>Shorthand for “<a class="reference internal" href="#keyword-tag-type">keyword tag type</a>.”</dd> 169</dl> 170<span class="target" id="keyword-object"></span><dl class="docutils"> 171<dt>keyword object</dt> 172<dd>An instance of <a class="reference internal" href="#keyword"><tt class="docutils literal">keyword</tt></a><tt class="docutils literal"><T></tt> for some <a class="reference internal" href="#tag-type">tag type</a> <tt class="docutils literal">T</tt>.</dd> 173</dl> 174<span class="target" id="tagged-reference"></span><dl class="docutils"> 175<dt>tagged reference</dt> 176<dd><p class="first">An object whose type is associated with a <a class="reference internal" href="#keyword-tag-type">keyword tag type</a> (the object's 177<em>keyword</em>), and that holds a reference (to the object's <em>value</em>).</p> 178<p class="last">As a shorthand, a “tagged reference to <tt class="docutils literal">x</tt>” means a tagged reference 179whose <em>value</em> is <tt class="docutils literal">x</tt>.</p> 180</dd> 181</dl> 182<span class="target" id="tagged-default"></span><dl class="docutils"> 183<dt>tagged default</dt> 184<dd>A <a class="reference internal" href="#tagged-reference">tagged reference</a> whose <em>value</em> represents the value of a 185default argument.</dd> 186</dl> 187<span class="target" id="tagged-lazy-default"></span><dl class="docutils"> 188<dt>tagged lazy default</dt> 189<dd>A <a class="reference internal" href="#tagged-reference">tagged reference</a> whose <em>value</em>, when invoked with no arguments, 190computes a default argument value.</dd> 191</dl> 192<span class="target" id="intended-argument-type"></span><dl class="docutils"> 193<dt>intended argument type</dt> 194<dd>The <em>intended argument type</em> of a single-element <a class="reference internal" href="#argumentpack"><span class="concept">ArgumentPack</span></a> is the 195type of its element's <em>value</em>. The intended argument type of any other 196type <tt class="docutils literal">X</tt> is <tt class="docutils literal">X</tt> itself.</dd> 197</dl> 198<div class="note"> 199<p class="first admonition-title">Note</p> 200<p class="last">In this reference, we will use concept names (and other names) to describe 201both types and objects, depending on context. So for example, “an 202<a class="reference internal" href="#argumentpack"><span class="concept">ArgumentPack</span></a>” can refer to a type that models <a class="reference internal" href="#argumentpack"><span class="concept">ArgumentPack</span></a> 203<em>or</em> an object of such a type.</p> 204</div> 205</div> 206<hr class="docutils" /> 207<div class="section" id="concepts"> 208<h1><a class="toc-backref" href="#id37">3 Concepts</a></h1> 209<p>This section describes the generic type concepts used by the Parameter 210library.</p> 211<div class="section" id="argumentpack"> 212<h2><a class="toc-backref" href="#id38">3.1 <span class="concept">ArgumentPack</span></a></h2> 213<p>An <span class="concept">ArgumentPack</span> is a collection of <a class="reference internal" href="#tagged-reference">tagged reference</a>s to the actual 214arguments passed to a function. Every <span class="concept">ArgumentPack</span> is also a valid <a class="reference external" href="../../../mpl/doc/refmanual/forward-sequence.html">MPL 215Forward Sequence</a> and <a class="reference external" href="../../../mpl/doc/refmanual/associative-sequence.html">MPL Associative Sequence</a> consisting of the <a class="reference internal" href="#keyword-tag-type">keyword tag type</a>s in its <a class="reference internal" href="#tagged-reference">tagged reference</a>s. If <tt class="docutils literal">BOOST_PARAMETER_CAN_USE_MP11</tt> 216is defined, then every <span class="concept">ArgumentPack</span> is also a valid <a class="reference external" href="../../../mp11/doc/html/mp11.html">Boost.MP11</a> map whose 217keys are <a class="reference internal" href="#keyword-tag-type">keyword tag type</a>s. The <a class="reference external" href="../../test/singular.cpp">singular.cpp</a>, <a class="reference external" href="../../test/compose.cpp">compose.cpp</a>, and 218<a class="reference external" href="../../test/mpl.cpp">mpl.cpp</a> test programs demonstrate this functionality.</p> 219<div class="section" id="requirements"> 220<h3>Requirements</h3> 221<p>In the table below,</p> 222<ul class="simple"> 223<li><tt class="docutils literal">A</tt> is a model of <span class="concept">ArgumentPack</span></li> 224<li><tt class="docutils literal">x</tt> is an instance of <tt class="docutils literal">A</tt></li> 225<li><tt class="docutils literal">u</tt> is a <a class="reference internal" href="#keyword-object">keyword object</a> of type <tt class="docutils literal">K</tt></li> 226<li><tt class="docutils literal">v</tt> is a <a class="reference internal" href="#tagged-default">tagged default</a> with <a class="reference internal" href="#tag-type">tag type</a> <tt class="docutils literal">L</tt> and <em>value</em> of type <tt class="docutils literal">D</tt></li> 227<li><tt class="docutils literal">w</tt> is a <a class="reference internal" href="#tagged-lazy-default">tagged lazy default</a> with <a class="reference internal" href="#tag-type">tag type</a> <tt class="docutils literal">M</tt> and <em>value</em> of type <tt class="docutils literal">E const</tt></li> 228<li><tt class="docutils literal">z</tt> is an <span class="concept">ArgumentPack</span> containing a single element (as created by <a class="reference internal" href="#keyword"><tt class="docutils literal">keyword</tt></a><tt class="docutils literal"><span class="pre"><…>::operator=</span></tt>)</li> 229</ul> 230<p>Any exceptions thrown from the invocation of <tt class="docutils literal">w</tt>'s <em>value</em> 231will be propagated to the caller.</p> 232<table border="1" class="docutils"> 233<caption><span class="concept">ArgumentPack</span> requirements</caption> 234<colgroup> 235<col width="14%" /> 236<col width="40%" /> 237<col width="19%" /> 238<col width="27%" /> 239</colgroup> 240<thead valign="bottom"> 241<tr><th class="head">Expression</th> 242<th class="head">Type</th> 243<th class="head">Requirements</th> 244<th class="head">Semantics/Notes</th> 245</tr> 246</thead> 247<tbody valign="top"> 248<tr><td><tt class="docutils literal">x[u]</tt></td> 249<td><tt class="docutils literal">binding<A, <span class="pre">K>::type</span></tt></td> 250<td><tt class="docutils literal">x</tt> contains 251an element <em>b</em> 252whose <a class="reference internal" href="#kw">keyword</a> is 253<tt class="docutils literal">K</tt></td> 254<td>Returns <em>b</em>'s 255<em>value</em> (by 256reference).</td> 257</tr> 258<tr><td><tt class="docutils literal">x[u]</tt></td> 259<td><tt class="docutils literal">binding<A, L, <span class="pre">D>::type</span></tt></td> 260<td><em>none</em></td> 261<td>If <tt class="docutils literal">x</tt> contains an 262element <em>b</em> whose 263<a class="reference internal" href="#kw">keyword</a> is the same as 264<tt class="docutils literal">u</tt>'s, returns 265<em>b</em>'s <em>value</em> (by 266reference). 267Otherwise, returns 268<tt class="docutils literal">u</tt>'s <em>value</em>.</td> 269</tr> 270<tr><td><tt class="docutils literal">x[w]</tt></td> 271<td><tt class="docutils literal">lazy_binding<A, M, <span class="pre">E>::type</span></tt></td> 272<td><em>none</em></td> 273<td>If <tt class="docutils literal">x</tt> contains an 274element <em>b</em> whose 275<a class="reference internal" href="#kw">keyword</a> is the same as 276<tt class="docutils literal">w</tt>'s, returns 277<em>b</em>'s <em>value</em> (by 278reference). 279Otherwise, invokes 280<tt class="docutils literal">w</tt>'s <em>value</em> 281and returns the 282result.</td> 283</tr> 284<tr><td><tt class="docutils literal">x, z</tt></td> 285<td>Model of <a class="reference internal" href="#argumentpack"><span class="concept">ArgumentPack</span></a></td> 286<td><em>none</em></td> 287<td>Returns an 288<a class="reference internal" href="#argumentpack"><span class="concept">ArgumentPack</span></a> 289containing all the 290elements of both 291<tt class="docutils literal">x</tt> and <tt class="docutils literal">z</tt>.</td> 292</tr> 293</tbody> 294</table> 295</div> 296</div> 297<div class="section" id="id3"> 298<span id="parameterspec"></span><h2><a class="toc-backref" href="#id39">3.2 <span class="concept">ParameterSpec</span></a></h2> 299<p>A <span class="concept">ParameterSpec</span> describes the type requirements for arguments corresponding 300to a given <a class="reference internal" href="#kw">keyword</a> and indicates whether the argument is optional or 301required. The table below details the allowed forms and describes their 302condition for satisfaction by an actual argument type. In each row,</p> 303<ul class="simple" id="conditions"> 304<li><tt class="docutils literal">K</tt> is the <span class="concept">ParameterSpec</span>'s <a class="reference internal" href="#keyword-tag-type">keyword tag type</a></li> 305<li><tt class="docutils literal">A</tt> is an <a class="reference internal" href="#intended-argument-type">intended argument type</a> associated with <tt class="docutils literal">K</tt>, if any</li> 306<li><tt class="docutils literal">P</tt> is a model of <span class="concept">ArgumentPack</span> that contains <tt class="docutils literal">A</tt></li> 307<li><tt class="docutils literal">F</tt> is an <a class="reference external" href="../../../mpl/doc/refmanual/metafunction-class.html">MPL Binary Metafunction Class</a></li> 308</ul> 309<table border="1" class="docutils"> 310<caption><span class="concept">ParameterSpec</span> allowed forms and conditions of satisfaction</caption> 311<colgroup> 312<col width="32%" /> 313<col width="14%" /> 314<col width="54%" /> 315</colgroup> 316<thead valign="bottom"> 317<tr><th class="head">Type</th> 318<th class="head"><tt class="docutils literal">A</tt> 319required</th> 320<th class="head">Condition <tt class="docutils literal">A</tt> must satisfy</th> 321</tr> 322</thead> 323<tbody valign="top"> 324<tr><td><tt class="docutils literal">K</tt></td> 325<td>no</td> 326<td><em>n/a</em></td> 327</tr> 328<tr><td><a class="reference internal" href="#optional"><tt class="docutils literal">optional</tt></a><tt class="docutils literal"><K,F></tt></td> 329<td>no</td> 330<td><tt class="docutils literal"><span class="pre">mpl::apply2<F,A,P>::type::value</span></tt> is 331<tt class="docutils literal">true</tt>.</td> 332</tr> 333<tr><td><a class="reference internal" href="#required"><tt class="docutils literal">required</tt></a><tt class="docutils literal"><K,F></tt></td> 334<td>yes</td> 335<td><tt class="docutils literal"><span class="pre">mpl::apply2<F,A,P>::type::value</span></tt> is 336<tt class="docutils literal">true</tt>.</td> 337</tr> 338</tbody> 339</table> 340<p>The information in a <span class="concept">ParameterSpec</span> is used to <a class="reference external" href="index.html#controlling-overload-resolution">limit</a> the arguments that 341will be matched by <a class="reference external" href="index.html#forwarding-functions">forwarding functions</a>.</p> 342</div> 343</div> 344<hr class="docutils" /> 345<div class="section" id="class-templates"> 346<h1><a class="toc-backref" href="#id40">4 Class Templates</a></h1> 347<div class="section" id="id5"> 348<span id="keyword"></span><h2><a class="toc-backref" href="#id41">4.1 <tt class="docutils literal">keyword</tt></a></h2> 349<p>The type of every <a class="reference internal" href="#keyword-object">keyword object</a> is a specialization of <tt class="docutils literal">keyword</tt>.</p> 350<table class="docutils field-list" frame="void" rules="none"> 351<col class="field-name" /> 352<col class="field-body" /> 353<tbody valign="top"> 354<tr class="field"><th class="field-name">Defined in:</th><td class="field-body"><a class="reference external" href="../../../../boost/parameter/keyword.hpp">boost/parameter/keyword.hpp</a></td> 355</tr> 356</tbody> 357</table> 358<pre class="literal-block"> 359template <typename Tag> 360struct keyword 361{ 362 typedef Tag tag; 363 364 template <typename T> 365 constexpr typename <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::enable_if</a>< 366 typename <a class="reference external" href="../../../mpl/doc/refmanual/eval-if.html">boost::mpl::eval_if</a>< 367 <a class="reference external" href="../../../type_traits/doc/html/boost_typetraits/is_scalar.html">boost::is_scalar</a><T> 368 , <a class="reference external" href="../../../mpl/doc/refmanual/bool.html">mpl::true_</a> // Enable this overload for scalar types. 369 , <a class="reference external" href="../../../mpl/doc/refmanual/eval-if.html">boost::mpl::eval_if</a>< 370 <a class="reference external" href="../../../type_traits/doc/html/boost_typetraits/is_same.html">boost::is_same</a>< 371 typename Tag::qualifier 372 , boost::parameter::in_reference 373 > 374 , <a class="reference external" href="../../../mpl/doc/refmanual/bool.html">mpl::true_</a> // Enable this overload for "in" references. 375 , <a class="reference external" href="../../../mpl/doc/refmanual/if.html">mpl::if_</a>< 376 <a class="reference external" href="../../../type_traits/doc/html/boost_typetraits/is_same.html">boost::is_same</a>< 377 typename Tag::qualifier 378 , boost::parameter::forward_reference 379 > 380 , <a class="reference external" href="../../../mpl/doc/refmanual/bool.html">mpl::true_</a> // Enable this overload for "forward" references. 381 , <a class="reference external" href="../../../mpl/doc/refmanual/bool.html">mpl::false_</a> // Disable this overload for all other reference categories. 382 > 383 > 384 >::type 385 , <a class="reference internal" href="#argumentpack"><span class="concept">ArgumentPack</span></a> 386 >::type 387 <a class="reference internal" href="#assignment-operator"><tt class="docutils literal">operator=</tt></a>(T const& value) const; 388 389 template <typename T> 390 constexpr typename <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::enable_if</a>< 391 typename <a class="reference external" href="../../../mpl/doc/refmanual/eval-if.html">boost::mpl::eval_if</a>< 392 typename <a class="reference external" href="../../../mpl/doc/refmanual/eval-if.html">boost::mpl::eval_if</a>< 393 <a class="reference external" href="../../../type_traits/doc/html/boost_typetraits/is_same.html">boost::is_same</a>< 394 typename Tag::qualifier 395 , boost::parameter::out_reference 396 > 397 , <a class="reference external" href="../../../mpl/doc/refmanual/bool.html">mpl::true_</a> // The reference category is "out". 398 , <a class="reference external" href="../../../mpl/doc/refmanual/if.html">mpl::if_</a>< 399 <a class="reference external" href="../../../type_traits/doc/html/boost_typetraits/is_same.html">boost::is_same</a>< 400 typename Tag::qualifier 401 , boost::parameter::forward_reference 402 > 403 , <a class="reference external" href="../../../mpl/doc/refmanual/bool.html">mpl::true_</a> // The reference category is "forward". 404 , <a class="reference external" href="../../../mpl/doc/refmanual/bool.html">mpl::false_</a> // The reference category is neither "out" nor "forward". 405 > 406 >::type 407 , <a class="reference external" href="../../../mpl/doc/refmanual/if.html">mpl::if_</a>< 408 <a class="reference external" href="../../../type_traits/doc/html/boost_typetraits/is_const.html">boost::is_const</a><T> 409 , <a class="reference external" href="../../../mpl/doc/refmanual/bool.html">mpl::false_</a> // Disable this overload for reference-to-const types. 410 , <a class="reference external" href="../../../mpl/doc/refmanual/bool.html">mpl::true_</a> // Enable this overload for referece-to-mutable types. 411 > 412 , <a class="reference external" href="../../../mpl/doc/refmanual/bool.html">mpl::false_</a> // Disable this overload for references neither "out" nor "forward". 413 >::type 414 , <a class="reference internal" href="#argumentpack"><span class="concept">ArgumentPack</span></a> 415 >::type 416 <a class="reference internal" href="#assignment-operator"><tt class="docutils literal">operator=</tt></a>(T& value) const; 417 418 template <typename T> 419 constexpr typename <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::enable_if</a>< 420 typename <a class="reference external" href="../../../mpl/doc/refmanual/eval-if.html">boost::mpl::eval_if</a>< 421 <a class="reference external" href="../../../type_traits/doc/html/boost_typetraits/is_scalar.html">boost::is_scalar</a><T> 422 , <a class="reference external" href="../../../mpl/doc/refmanual/bool.html">mpl::false_</a> // Disable this overload for scalar types. 423 , <a class="reference external" href="../../../mpl/doc/refmanual/eval-if.html">boost::mpl::eval_if</a>< 424 <a class="reference external" href="../../../type_traits/doc/html/boost_typetraits/is_same.html">boost::is_same</a>< 425 typename Tag::qualifier 426 , boost::parameter::in_reference 427 > 428 , <a class="reference external" href="../../../mpl/doc/refmanual/bool.html">mpl::true_</a> // Enable this overload for "in" references. 429 , <a class="reference external" href="../../../mpl/doc/refmanual/if.html">mpl::if_</a>< 430 <a class="reference external" href="../../../type_traits/doc/html/boost_typetraits/is_same.html">boost::is_same</a>< 431 typename Tag::qualifier 432 , boost::parameter::forward_reference 433 > 434 , <a class="reference external" href="../../../mpl/doc/refmanual/bool.html">mpl::true_</a> // Enable this overload for "forward" references. 435 , <a class="reference external" href="../../../mpl/doc/refmanual/bool.html">mpl::false_</a> // Disable this overload for all other reference categories. 436 > 437 > 438 >::type 439 , <a class="reference internal" href="#argumentpack"><span class="concept">ArgumentPack</span></a> 440 >::type 441 <a class="reference internal" href="#assignment-operator"><tt class="docutils literal">operator=</tt></a>(T const&& value) const; 442 443 template <typename T> 444 constexpr typename <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::enable_if</a>< 445 typename <a class="reference external" href="../../../mpl/doc/refmanual/eval-if.html">boost::mpl::eval_if</a>< 446 <a class="reference external" href="../../../type_traits/doc/html/boost_typetraits/is_scalar.html">boost::is_scalar</a><T> 447 , <a class="reference external" href="../../../mpl/doc/refmanual/bool.html">mpl::false_</a> // Disable this overload for scalar types. 448 , <a class="reference external" href="../../../mpl/doc/refmanual/eval-if.html">boost::mpl::eval_if</a>< 449 <a class="reference external" href="../../../type_traits/doc/html/boost_typetraits/is_same.html">boost::is_same</a>< 450 typename Tag::qualifier 451 , boost::parameter::consume_reference 452 > 453 , <a class="reference external" href="../../../mpl/doc/refmanual/bool.html">mpl::true_</a> // Enable this overload for "consume" references. 454 , <a class="reference external" href="../../../mpl/doc/refmanual/if.html">mpl::if_</a>< 455 <a class="reference external" href="../../../type_traits/doc/html/boost_typetraits/is_same.html">boost::is_same</a>< 456 typename Tag::qualifier 457 , boost::parameter::forward_reference 458 > 459 , <a class="reference external" href="../../../mpl/doc/refmanual/bool.html">mpl::true_</a> // Enable this overload for "forward" references. 460 , <a class="reference external" href="../../../mpl/doc/refmanual/bool.html">mpl::false_</a> // Disable this overload for all other reference categories. 461 > 462 > 463 >::type 464 , <a class="reference internal" href="#argumentpack"><span class="concept">ArgumentPack</span></a> 465 >::type 466 <a class="reference internal" href="#assignment-operator"><tt class="docutils literal">operator=</tt></a>(T&& value) const; 467 468 template <typename T> 469 constexpr typename <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::enable_if</a>< 470 typename <a class="reference external" href="../../../mpl/doc/refmanual/eval-if.html">boost::mpl::eval_if</a>< 471 <a class="reference external" href="../../../type_traits/doc/html/boost_typetraits/is_scalar.html">boost::is_scalar</a><T> 472 , <a class="reference external" href="../../../mpl/doc/refmanual/bool.html">mpl::true_</a> // Enable this overload for scalar types. 473 , <a class="reference external" href="../../../mpl/doc/refmanual/eval-if.html">boost::mpl::eval_if</a>< 474 <a class="reference external" href="../../../type_traits/doc/html/boost_typetraits/is_same.html">boost::is_same</a>< 475 typename Tag::qualifier 476 , boost::parameter::in_reference 477 > 478 , <a class="reference external" href="../../../mpl/doc/refmanual/bool.html">mpl::true_</a> // Enable this overload for "in" references. 479 , <a class="reference external" href="../../../mpl/doc/refmanual/if.html">mpl::if_</a>< 480 <a class="reference external" href="../../../type_traits/doc/html/boost_typetraits/is_same.html">boost::is_same</a>< 481 typename Tag::qualifier 482 , boost::parameter::forward_reference 483 > 484 , <a class="reference external" href="../../../mpl/doc/refmanual/bool.html">mpl::true_</a> // Enable this overload for "forward" references. 485 , <a class="reference external" href="../../../mpl/doc/refmanual/bool.html">mpl::false_</a> // Disable this overload for all other reference categories. 486 > 487 > 488 >::type 489 , <em>tagged default</em> 490 >::type 491 <a class="reference internal" href="#bitwise-or-operator"><tt class="docutils literal">operator|</tt></a>(T const& x) const; 492 493 template <typename T> 494 constexpr typename <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::enable_if</a>< 495 typename <a class="reference external" href="../../../mpl/doc/refmanual/eval-if.html">boost::mpl::eval_if</a>< 496 typename <a class="reference external" href="../../../mpl/doc/refmanual/eval-if.html">boost::mpl::eval_if</a>< 497 <a class="reference external" href="../../../type_traits/doc/html/boost_typetraits/is_same.html">boost::is_same</a>< 498 typename Tag::qualifier 499 , boost::parameter::out_reference 500 > 501 , <a class="reference external" href="../../../mpl/doc/refmanual/bool.html">mpl::true_</a> // The reference category is "out". 502 , <a class="reference external" href="../../../mpl/doc/refmanual/if.html">mpl::if_</a>< 503 <a class="reference external" href="../../../type_traits/doc/html/boost_typetraits/is_same.html">boost::is_same</a>< 504 typename Tag::qualifier 505 , boost::parameter::forward_reference 506 > 507 , <a class="reference external" href="../../../mpl/doc/refmanual/bool.html">mpl::true_</a> // The reference category is "forward". 508 , <a class="reference external" href="../../../mpl/doc/refmanual/bool.html">mpl::false_</a> // The reference category is neither "out" nor "forward". 509 > 510 >::type 511 , <a class="reference external" href="../../../mpl/doc/refmanual/if.html">mpl::if_</a>< 512 <a class="reference external" href="../../../type_traits/doc/html/boost_typetraits/is_const.html">boost::is_const</a><T> 513 , <a class="reference external" href="../../../mpl/doc/refmanual/bool.html">mpl::false_</a> // Disable this overload for reference-to-const types. 514 , <a class="reference external" href="../../../mpl/doc/refmanual/bool.html">mpl::true_</a> // Enable this overload for referece-to-mutable types. 515 > 516 , <a class="reference external" href="../../../mpl/doc/refmanual/bool.html">mpl::false_</a> // Disable this overload for references neither "out" nor "forward". 517 >::type 518 , <em>tagged default</em> 519 >::type 520 <a class="reference internal" href="#bitwise-or-operator"><tt class="docutils literal">operator|</tt></a>(T& x) const; 521 522 template <typename T> 523 constexpr typename <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::enable_if</a>< 524 typename <a class="reference external" href="../../../mpl/doc/refmanual/eval-if.html">boost::mpl::eval_if</a>< 525 <a class="reference external" href="../../../type_traits/doc/html/boost_typetraits/is_scalar.html">boost::is_scalar</a><T> 526 , <a class="reference external" href="../../../mpl/doc/refmanual/bool.html">mpl::false_</a> // Disable this overload for scalar types. 527 , <a class="reference external" href="../../../mpl/doc/refmanual/eval-if.html">boost::mpl::eval_if</a>< 528 <a class="reference external" href="../../../type_traits/doc/html/boost_typetraits/is_same.html">boost::is_same</a>< 529 typename Tag::qualifier 530 , boost::parameter::in_reference 531 > 532 , <a class="reference external" href="../../../mpl/doc/refmanual/bool.html">mpl::true_</a> // Enable this overload for "in" references. 533 , <a class="reference external" href="../../../mpl/doc/refmanual/if.html">mpl::if_</a>< 534 <a class="reference external" href="../../../type_traits/doc/html/boost_typetraits/is_same.html">boost::is_same</a>< 535 typename Tag::qualifier 536 , boost::parameter::forward_reference 537 > 538 , <a class="reference external" href="../../../mpl/doc/refmanual/bool.html">mpl::true_</a> // Enable this overload for "forward" references. 539 , <a class="reference external" href="../../../mpl/doc/refmanual/bool.html">mpl::false_</a> // Disable this overload for all other reference categories. 540 > 541 > 542 >::type 543 , <em>tagged default</em> 544 >::type 545 <a class="reference internal" href="#bitwise-or-operator"><tt class="docutils literal">operator|</tt></a>(T const&& x) const; 546 547 template <typename T> 548 constexpr typename <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::enable_if</a>< 549 typename <a class="reference external" href="../../../mpl/doc/refmanual/eval-if.html">boost::mpl::eval_if</a>< 550 <a class="reference external" href="../../../type_traits/doc/html/boost_typetraits/is_scalar.html">boost::is_scalar</a><T> 551 , <a class="reference external" href="../../../mpl/doc/refmanual/bool.html">mpl::false_</a> // Disable this overload for scalar types. 552 , <a class="reference external" href="../../../mpl/doc/refmanual/eval-if.html">boost::mpl::eval_if</a>< 553 <a class="reference external" href="../../../type_traits/doc/html/boost_typetraits/is_same.html">boost::is_same</a>< 554 typename Tag::qualifier 555 , boost::parameter::consume_reference 556 > 557 , <a class="reference external" href="../../../mpl/doc/refmanual/bool.html">mpl::true_</a> // Enable this overload for "consume" references. 558 , <a class="reference external" href="../../../mpl/doc/refmanual/if.html">mpl::if_</a>< 559 <a class="reference external" href="../../../type_traits/doc/html/boost_typetraits/is_same.html">boost::is_same</a>< 560 typename Tag::qualifier 561 , boost::parameter::forward_reference 562 > 563 , <a class="reference external" href="../../../mpl/doc/refmanual/bool.html">mpl::true_</a> // Enable this overload for "forward" references. 564 , <a class="reference external" href="../../../mpl/doc/refmanual/bool.html">mpl::false_</a> // Disable this overload for all other reference categories. 565 > 566 > 567 >::type 568 , <em>tagged default</em> 569 >::type constexpr 570 <a class="reference internal" href="#bitwise-or-operator"><tt class="docutils literal">operator|</tt></a>(T&& value) const; 571 572 template <typename F> 573 constexpr <em>tagged lazy default</em> <a class="reference internal" href="#logical-or-operator"><tt class="docutils literal">operator||</tt></a>(F const&) const; 574 575 template <typename F> 576 constexpr <em>tagged lazy default</em> <a class="reference internal" href="#logical-or-operator"><tt class="docutils literal">operator||</tt></a>(F&) const; 577 578 static keyword<Tag> const& instance; 579 580 static keyword<Tag>& <a class="reference internal" href="#get">get</a>(); 581}; 582</pre> 583<p id="assignment-operator"><tt class="docutils literal">operator=</tt></p> 584<table class="docutils field-list" frame="void" rules="none"> 585<col class="field-name" /> 586<col class="field-body" /> 587<tbody valign="top"> 588<tr class="field"><th class="field-name">Synopsis:</th><td class="field-body"></td> 589</tr> 590</tbody> 591</table> 592<pre class="literal-block"> 593template <typename T> 594constexpr <a class="reference internal" href="#argumentpack"><span class="concept">ArgumentPack</span></a> operator=(T const& value) const; 595 596template <typename T> 597constexpr <a class="reference internal" href="#argumentpack"><span class="concept">ArgumentPack</span></a> operator=(T& value) const; 598 599template <typename T> 600constexpr <a class="reference internal" href="#argumentpack"><span class="concept">ArgumentPack</span></a> operator=(T const&& value) const; 601 602template <typename T> 603constexpr <a class="reference internal" href="#argumentpack"><span class="concept">ArgumentPack</span></a> operator=(T&& value) const; 604</pre> 605<table class="docutils field-list" frame="void" rules="none"> 606<col class="field-name" /> 607<col class="field-body" /> 608<tbody valign="top"> 609<tr class="field"><th class="field-name">Requires:</th><td class="field-body">one of the following:</td> 610</tr> 611</tbody> 612</table> 613<ul class="simple"> 614<li>The nested <tt class="docutils literal">qualifier</tt> type of <tt class="docutils literal">Tag</tt> must be <tt class="docutils literal">forward_reference</tt>.</li> 615<li>To use the <tt class="docutils literal">const</tt> lvalue reference overload, <tt class="docutils literal">T</tt> must be scalar, or 616the nested <tt class="docutils literal">qualifier</tt> type of <tt class="docutils literal">Tag</tt> must be <tt class="docutils literal">in_reference</tt>.</li> 617<li>To use the mutable lvalue reference overload, the nested <tt class="docutils literal">qualifier</tt> 618type of <tt class="docutils literal">Tag</tt> must be <tt class="docutils literal">out_reference</tt> or <tt class="docutils literal">in_out_reference</tt>, and 619<tt class="docutils literal">T</tt> must not be <tt class="docutils literal">const</tt>-qualified.</li> 620<li>To use the <tt class="docutils literal">const</tt> rvalue reference overload for non-scalar <tt class="docutils literal">T</tt>, the 621nested <tt class="docutils literal">qualifier</tt> type of <tt class="docutils literal">Tag</tt> must be <tt class="docutils literal">in_reference</tt>.</li> 622<li>To use the mutable rvalue reference overload for non-scalar <tt class="docutils literal">T</tt>, the 623nested <tt class="docutils literal">qualifier</tt> type of <tt class="docutils literal">Tag</tt> must be <tt class="docutils literal">consume_reference</tt> or 624<tt class="docutils literal">move_from_reference</tt>.</li> 625</ul> 626<table class="docutils field-list" frame="void" rules="none"> 627<col class="field-name" /> 628<col class="field-body" /> 629<tbody valign="top"> 630<tr class="field"><th class="field-name">Returns:</th><td class="field-body">an <a class="reference internal" href="#argumentpack"><span class="concept">ArgumentPack</span></a> containing a single <a class="reference internal" href="#tagged-reference">tagged reference</a> to 631<tt class="docutils literal">value</tt> with <a class="reference internal" href="#kw">keyword</a> <tt class="docutils literal">Tag</tt></td> 632</tr> 633</tbody> 634</table> 635<p id="bitwise-or-operator"><tt class="docutils literal">operator|</tt></p> 636<table class="docutils field-list" frame="void" rules="none"> 637<col class="field-name" /> 638<col class="field-body" /> 639<tbody valign="top"> 640<tr class="field"><th class="field-name">Synopsis:</th><td class="field-body"></td> 641</tr> 642</tbody> 643</table> 644<pre class="literal-block"> 645template <typename T> 646constexpr <em>tagged default</em> operator|(T const& x) const; 647 648template <typename T> 649constexpr <em>tagged default</em> operator|(T& x) const; 650 651template <typename T> 652constexpr <em>tagged default</em> operator|(T const&& x) const; 653 654template <typename T> 655constexpr <em>tagged default</em> operator|(T&& x) const; 656</pre> 657<table class="docutils field-list" frame="void" rules="none"> 658<col class="field-name" /> 659<col class="field-body" /> 660<tbody valign="top"> 661<tr class="field"><th class="field-name">Requires:</th><td class="field-body">one of the following:</td> 662</tr> 663</tbody> 664</table> 665<ul class="simple"> 666<li>The nested <tt class="docutils literal">qualifier</tt> type of <tt class="docutils literal">Tag</tt> must be <tt class="docutils literal">forward_reference</tt>.</li> 667<li>To use the <tt class="docutils literal">const</tt> lvalue reference overload, <tt class="docutils literal">T</tt> must be scalar, or 668the nested <tt class="docutils literal">qualifier</tt> type of <tt class="docutils literal">Tag</tt> must be <tt class="docutils literal">in_reference</tt>.</li> 669<li>To use the mutable lvalue reference overload, the nested <tt class="docutils literal">qualifier</tt> 670type of <tt class="docutils literal">Tag</tt> must be <tt class="docutils literal">out_reference</tt> or <tt class="docutils literal">in_out_reference</tt>, and 671<tt class="docutils literal">T</tt> must not be <tt class="docutils literal">const</tt>-qualified.</li> 672<li>To use the <tt class="docutils literal">const</tt> rvalue reference overload for non-scalar <tt class="docutils literal">T</tt>, the 673nested <tt class="docutils literal">qualifier</tt> type of <tt class="docutils literal">Tag</tt> must be <tt class="docutils literal">in_reference</tt>.</li> 674<li>To use the mutable rvalue reference overload for non-scalar <tt class="docutils literal">T</tt>, the 675nested <tt class="docutils literal">qualifier</tt> type of <tt class="docutils literal">Tag</tt> must be <tt class="docutils literal">consume_reference</tt> or 676<tt class="docutils literal">move_from_reference</tt>.</li> 677</ul> 678<table class="docutils field-list" frame="void" rules="none"> 679<col class="field-name" /> 680<col class="field-body" /> 681<tbody valign="top"> 682<tr class="field"><th class="field-name">Returns:</th><td class="field-body">a <a class="reference internal" href="#tagged-default">tagged default</a> with <em>value</em> <tt class="docutils literal">x</tt> and <a class="reference internal" href="#kw">keyword</a> <tt class="docutils literal">Tag</tt>.</td> 683</tr> 684</tbody> 685</table> 686<p id="logical-or-operator"><tt class="docutils literal">operator||</tt></p> 687<table class="docutils field-list" frame="void" rules="none"> 688<col class="field-name" /> 689<col class="field-body" /> 690<tbody valign="top"> 691<tr class="field"><th class="field-name">Synopsis:</th><td class="field-body"></td> 692</tr> 693</tbody> 694</table> 695<pre class="literal-block"> 696template <typename F> 697constexpr <em>tagged lazy default</em> operator||(F const& g) const; 698 699template <typename F> 700constexpr <em>tagged lazy default</em> operator||(F& g) const; 701</pre> 702<table class="docutils field-list" frame="void" rules="none"> 703<col class="field-name" /> 704<col class="field-body" /> 705<tbody valign="top"> 706<tr class="field"><th class="field-name">Requires:</th><td class="field-body"><tt class="docutils literal">g()</tt> must be valid, with type 707<a class="reference external" href="../../../utility/utility.htm#result_of"><tt class="docutils literal"><span class="pre">boost::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="id6"><sup>2</sup></a></td> 708</tr> 709<tr class="field"><th class="field-name">Returns:</th><td class="field-body">a <a class="reference internal" href="#tagged-lazy-default">tagged lazy default</a> with <em>value</em> <tt class="docutils literal">g</tt> and <a class="reference internal" href="#kw">keyword</a> <tt class="docutils literal">Tag</tt>.</td> 710</tr> 711</tbody> 712</table> 713<p id="instance"><tt class="docutils literal">instance</tt></p> 714<table class="docutils field-list" frame="void" rules="none"> 715<col class="field-name" /> 716<col class="field-body" /> 717<tbody valign="top"> 718<tr class="field"><th class="field-name">Synopsis:</th><td class="field-body"></td> 719</tr> 720</tbody> 721</table> 722<pre class="literal-block"> 723static keyword<Tag> const& instance; 724</pre> 725<table class="docutils field-list" frame="void" rules="none"> 726<col class="field-name" /> 727<col class="field-body" /> 728<tbody valign="top"> 729<tr class="field"><th class="field-name">Returns:</th><td class="field-body">a “singleton instance”: the same object will be returned on each 730invocation of <tt class="docutils literal">instance</tt>.</td> 731</tr> 732<tr class="field"><th class="field-name">Thread Safety:</th><td class="field-body"><tt class="docutils literal">instance</tt> can be accessed from multiple threads simultaneously.</td> 733</tr> 734</tbody> 735</table> 736<p id="get"><tt class="docutils literal">get</tt></p> 737<table class="docutils field-list" frame="void" rules="none"> 738<col class="field-name" /> 739<col class="field-body" /> 740<tbody valign="top"> 741<tr class="field"><th class="field-name">Synopsis:</th><td class="field-body"></td> 742</tr> 743</tbody> 744</table> 745<pre class="literal-block"> 746static keyword<Tag>& get(); 747</pre> 748<div class="admonition-deprecated admonition"> 749<p class="first admonition-title">Deprecated</p> 750<p class="last">This function has been deprecated in favor of <tt class="docutils literal">instance</tt>.</p> 751</div> 752<table class="docutils field-list" frame="void" rules="none"> 753<col class="field-name" /> 754<col class="field-body" /> 755<tbody valign="top"> 756<tr class="field"><th class="field-name">Returns:</th><td class="field-body">a “singleton instance”: the same object will be returned on each 757invocation of <tt class="docutils literal">get()</tt>.</td> 758</tr> 759<tr class="field"><th class="field-name">Thread Safety:</th><td class="field-body"><tt class="docutils literal">get()</tt> can be called from multiple threads simultaneously.</td> 760</tr> 761</tbody> 762</table> 763</div> 764<div class="section" id="id7"> 765<span id="template-keyword"></span><h2><a class="toc-backref" href="#id42">4.2 <tt class="docutils literal">template_keyword</tt></a></h2> 766<p>This class template encapsulates a named template parameter. Every type 767generated by the <a class="reference internal" href="#boost-parameter-template-keyword"><tt class="docutils literal">BOOST_PARAMETER_TEMPLATE_KEYWORD</tt></a> macro is a specialization 768of <tt class="docutils literal">template_keyword</tt>.</p> 769<table class="docutils field-list" frame="void" rules="none"> 770<col class="field-name" /> 771<col class="field-body" /> 772<tbody valign="top"> 773<tr class="field"><th class="field-name">Defined in:</th><td class="field-body"><a class="reference external" href="../../../../boost/parameter/template_keyword.hpp">boost/parameter/template_keyword.hpp</a></td> 774</tr> 775</tbody> 776</table> 777<pre class="literal-block"> 778template <typename Tag, typename T> 779struct template_keyword 780{ 781 typedef Tag key_type; 782 typedef T value_type; 783 typedef <em>implementation defined</em> reference; 784}; 785</pre> 786<p>The <a class="reference external" href="../../test/ntp.cpp">test/ntp.cpp</a> test program demonstrates proper usage of this class template.</p> 787</div> 788<div class="section" id="id8"> 789<span id="parameters"></span><h2><a class="toc-backref" href="#id43">4.3 <tt class="docutils literal">parameters</tt></a></h2> 790<p>Provides an interface for assembling the actual arguments to a <cite>forwarding 791function</cite> into an <span class="concept">ArgumentPack</span>, in which any <a class="reference internal" href="#positional">positional</a> arguments will be 792tagged according to the corresponding template argument to <tt class="docutils literal">parameters</tt>.</p> 793<table class="docutils field-list" frame="void" rules="none"> 794<col class="field-name" /> 795<col class="field-body" /> 796<tbody valign="top"> 797<tr class="field"><th class="field-name">Defined in:</th><td class="field-body"><a class="reference external" href="../../../../boost/parameter/parameters.hpp">boost/parameter/parameters.hpp</a></td> 798</tr> 799</tbody> 800</table> 801<pre class="literal-block"> 802template <typename ...PSpec> 803struct parameters 804{ 805 template <typename ...Args> 806 struct <a class="reference internal" href="#match"><tt class="docutils literal">match</tt></a> 807 { 808 typedef … type; 809 }; 810 811 template <typename ...Args> 812 <a class="reference internal" href="#argumentpack"><span class="concept">ArgumentPack</span></a> <a class="reference internal" href="#function-call-operator"><tt class="docutils literal">operator()</tt></a>(Args&&... args) const; 813}; 814</pre> 815<table class="docutils field-list" frame="void" rules="none"> 816<col class="field-name" /> 817<col class="field-body" /> 818<tbody valign="top"> 819<tr class="field"><th class="field-name">Requires:</th><td class="field-body">Each element in the <tt class="docutils literal">PSpec</tt> parameter pack must be a model of 820<a class="reference internal" href="#parameterspec"><span class="concept">ParameterSpec</span></a>.</td> 821</tr> 822</tbody> 823</table> 824<div class="note"> 825<p class="first admonition-title">Note</p> 826<p>In this section, <tt class="docutils literal">R</tt> ## <em>i</em> and <tt class="docutils literal">K</tt> ## <em>i</em> are defined as 827follows, for any argument type <tt class="docutils literal">A</tt> ## <em>i</em>:</p> 828<div class="last line-block"> 829<div class="line">let <tt class="docutils literal">D0</tt> the set [d0, …, d ## <em>j</em>] of all <strong>deduced</strong></div> 830<div class="line"><em>parameter specs</em> in the <tt class="docutils literal">PSpec</tt> parameter pack</div> 831<div class="line"><tt class="docutils literal">R</tt> ## <em>i</em> is the <a class="reference internal" href="#intended-argument-type">intended argument type</a> of <tt class="docutils literal">A</tt> ## <em>i</em></div> 832<div class="line"><br /></div> 833<div class="line">if <tt class="docutils literal">A</tt> ## <em>i</em> is a result type of <tt class="docutils literal"><span class="pre">keyword<T>::</span></tt> <a class="reference internal" href="#assignment-operator"><tt class="docutils literal">operator=</tt></a></div> 834<div class="line">then</div> 835<div class="line-block"> 836<div class="line"><tt class="docutils literal">K</tt> ## <em>i</em> is <tt class="docutils literal">T</tt></div> 837</div> 838<div class="line">else</div> 839<div class="line-block"> 840<div class="line">if some <tt class="docutils literal">A</tt> ## <em>j</em> where <em>j</em> ≤ <em>i</em> is a result type of</div> 841<div class="line"><tt class="docutils literal"><span class="pre">keyword<T>::</span></tt> <a class="reference internal" href="#assignment-operator"><tt class="docutils literal">operator=</tt></a></div> 842<div class="line"><em>or</em> some <tt class="docutils literal">P</tt> ## <em>j</em> in <em>j</em> ≤ <em>i</em> is <strong>deduced</strong></div> 843<div class="line">then</div> 844<div class="line-block"> 845<div class="line">if some <em>parameter spec</em> <tt class="docutils literal">d</tt> ## <em>j</em> in <tt class="docutils literal">D</tt> ## <em>i</em></div> 846<div class="line">matches <tt class="docutils literal">A</tt> ## <em>i</em></div> 847<div class="line">then</div> 848<div class="line-block"> 849<div class="line"><tt class="docutils literal">K</tt> ## <em>i</em> is the <a class="reference internal" href="#keyword-tag-type">keyword tag type</a> of <tt class="docutils literal">d</tt> ## <em>j</em>.</div> 850<div class="line"><tt class="docutils literal">D</tt><sub>i+1</sub> is <tt class="docutils literal">D</tt> ## <em>i</em> - [ <tt class="docutils literal">d</tt> ## <em>j</em>]</div> 851</div> 852</div> 853<div class="line">else</div> 854<div class="line-block"> 855<div class="line"><tt class="docutils literal">K</tt> ## <em>i</em> is the <a class="reference internal" href="#keyword-tag-type">keyword tag type</a> of <tt class="docutils literal">P</tt> ## <em>i</em>.</div> 856</div> 857</div> 858</div> 859</div> 860<dl class="docutils" id="match"> 861<dt><tt class="docutils literal">match</tt></dt> 862<dd>A <a class="reference external" href="../../../mpl/doc/refmanual/metafunction.html">Metafunction</a> used to remove a <a class="reference external" href="index.html#forwarding-functions">forwarding function</a> from overload 863resolution.</dd> 864</dl> 865<table class="docutils field-list" frame="void" rules="none"> 866<col class="field-name" /> 867<col class="field-body" /> 868<tbody valign="top"> 869<tr class="field"><th class="field-name">Returns:</th><td class="field-body">if all elements in <tt class="docutils literal"><span class="pre">Params...</span></tt> are <em>satisfied</em> (see below), then 870<tt class="docutils literal"><span class="pre">parameters<Params...></span></tt>. Otherwise, <tt class="docutils literal"><span class="pre">match<Args...>::type</span></tt> is not 871defined.</td> 872</tr> 873</tbody> 874</table> 875<p>Each element <tt class="docutils literal">P</tt> in <tt class="docutils literal"><span class="pre">Params...</span></tt> is <strong>satisfied</strong> if either:</p> 876<ul> 877<li><p class="first"><tt class="docutils literal">P</tt> is the <em>unspecified</em> default</p> 878</li> 879<li><p class="first"><strong>or</strong>, <tt class="docutils literal">P</tt> is a <em>keyword tag type</em></p> 880</li> 881<li><dl class="first docutils"> 882<dt><strong>or</strong>, <tt class="docutils literal">P</tt> is <a class="reference internal" href="#optional"><tt class="docutils literal">optional</tt></a> <tt class="docutils literal"><X,F></tt> and either</dt> 883<dd><ul class="first last"> 884<li><p class="first"><tt class="docutils literal">X</tt> is not <tt class="docutils literal">K</tt> ## <em>i</em> for any <em>i</em>,</p> 885</li> 886<li><dl class="first docutils"> 887<dt><strong>or</strong> <tt class="docutils literal">X</tt> is some <tt class="docutils literal">K</tt> ## <em>i</em> and <tt class="docutils literal"><span class="pre">mpl::apply<F,R</span></tt> ## <em>i</em></dt> 888<dd><p class="first last"><tt class="docutils literal"><span class="pre">>::type::value</span></tt> is <tt class="docutils literal">true</tt></p> 889</dd> 890</dl> 891</li> 892</ul> 893</dd> 894</dl> 895</li> 896<li><dl class="first docutils"> 897<dt><strong>or</strong>, <tt class="docutils literal">P</tt> is <a class="reference internal" href="#required"><tt class="docutils literal">required</tt></a> <tt class="docutils literal"><X,F></tt>, and</dt> 898<dd><ul class="first last simple"> 899<li><tt class="docutils literal">X</tt> is some <tt class="docutils literal">K</tt> ## <em>i</em>, <strong>and</strong></li> 900<li><tt class="docutils literal"><span class="pre">mpl::apply<F,R</span></tt> ## <em>i</em> <tt class="docutils literal"><span class="pre">>::type::value</span></tt> is <tt class="docutils literal">true</tt></li> 901</ul> 902</dd> 903</dl> 904</li> 905</ul> 906<p id="function-call-operator"><tt class="docutils literal">operator()</tt></p> 907<table class="docutils field-list" frame="void" rules="none"> 908<col class="field-name" /> 909<col class="field-body" /> 910<tbody valign="top"> 911<tr class="field"><th class="field-name">Synopsis:</th><td class="field-body"></td> 912</tr> 913</tbody> 914</table> 915<pre class="literal-block"> 916template <typename ...Args> 917<a class="reference internal" href="#argumentpack"><span class="concept">ArgumentPack</span></a> operator()(Args&&... args) const; 918</pre> 919<table class="docutils field-list" frame="void" rules="none"> 920<col class="field-name" /> 921<col class="field-body" /> 922<tbody valign="top"> 923<tr class="field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">An <a class="reference internal" href="#argumentpack"><span class="concept">ArgumentPack</span></a> containing, for each <tt class="docutils literal">a</tt> ## <em>i</em>,</p> 924<ul class="last"> 925<li><p class="first">if <tt class="docutils literal">a</tt> ## <em>i</em> is a single-element <span class="concept">ArgumentPack</span>, its element</p> 926</li> 927<li><dl class="first docutils"> 928<dt>Otherwise, a <a class="reference internal" href="#tagged-reference">tagged reference</a> with <a class="reference internal" href="#kw">keyword</a> <tt class="docutils literal">K</tt> ## <em>i</em> and <em>value</em></dt> 929<dd><p class="first last"><tt class="docutils literal">a</tt> ## <em>i</em></p> 930</dd> 931</dl> 932</li> 933</ul> 934</td> 935</tr> 936</tbody> 937</table> 938</div> 939<div class="section" id="optional-required"> 940<span id="required"></span><span id="optional"></span><h2><a class="toc-backref" href="#id44">4.4 <tt class="docutils literal">optional</tt>, <tt class="docutils literal">required</tt></a></h2> 941<p>These templates describe the requirements on a function parameter.</p> 942<p><tt class="docutils literal">optional</tt> is defined in: <a class="reference external" href="../../../../boost/parameter/optional.hpp">boost/parameter/optional.hpp</a></p> 943<p><tt class="docutils literal">required</tt> is defined in: <a class="reference external" href="../../../../boost/parameter/required.hpp">boost/parameter/required.hpp</a></p> 944<p>Both headers are included by: <a class="reference external" href="../../../../boost/parameter/preprocessor.hpp">boost/parameter/preprocessor.hpp</a></p> 945<table class="docutils field-list" frame="void" rules="none"> 946<col class="field-name" /> 947<col class="field-body" /> 948<tbody valign="top"> 949<tr class="field"><th class="field-name" colspan="2">Specializations model:</th></tr> 950<tr class="field"><td> </td><td class="field-body"><a class="reference internal" href="#parameterspec"><span class="concept">ParameterSpec</span></a></td> 951</tr> 952</tbody> 953</table> 954<pre class="literal-block"> 955template <typename Tag, typename Predicate = <em>unspecified</em>> 956struct optional; 957 958template <typename Tag, typename Predicate = <em>unspecified</em>> 959struct required; 960</pre> 961<p>The default value of <tt class="docutils literal">Predicate</tt> is an unspecified <a class="reference external" href="../../../mpl/doc/refmanual/metafunction-class.html">MPL Binary Metafunction 962Class</a> that returns <tt class="docutils literal"><span class="pre">mpl::true_</span></tt> for any argument. If 963<a class="reference internal" href="#boost-parameter-can-use-mp11"><tt class="docutils literal">BOOST_PARAMETER_CAN_USE_MP11</tt></a> is defined, then the default value of 964<tt class="docutils literal">Predicate</tt> is also a <a class="reference external" href="../../../mp11/doc/html/mp11.html">Boost.MP11</a>-style quoted metafunction that returns 965<tt class="docutils literal"><span class="pre">mp11::mp_true</span></tt> for any argument.</p> 966</div> 967<div class="section" id="id9"> 968<span id="deduced"></span><h2><a class="toc-backref" href="#id45">4.5 <tt class="docutils literal">deduced</tt></a></h2> 969<p>This template is used to wrap the <em>keyword tag</em> argument to 970<tt class="docutils literal">optional</tt> or <tt class="docutils literal">required</tt>.</p> 971<table class="docutils field-list" frame="void" rules="none"> 972<col class="field-name" /> 973<col class="field-body" /> 974<tbody valign="top"> 975<tr class="field"><th class="field-name">Defined in:</th><td class="field-body"><a class="reference external" href="../../../../boost/parameter/deduced.hpp">boost/parameter/deduced.hpp</a></td> 976</tr> 977<tr class="field"><th class="field-name">Included by:</th><td class="field-body"><a class="reference external" href="../../../../boost/parameter/preprocessor.hpp">boost/parameter/preprocessor.hpp</a></td> 978</tr> 979</tbody> 980</table> 981<pre class="literal-block"> 982template <typename Tag> 983struct deduced; 984</pre> 985<table class="docutils field-list" frame="void" rules="none"> 986<col class="field-name" /> 987<col class="field-body" /> 988<tbody valign="top"> 989<tr class="field"><th class="field-name">Requires:</th><td class="field-body">nothing</td> 990</tr> 991</tbody> 992</table> 993</div> 994</div> 995<hr class="docutils" /> 996<div class="section" id="metafunctions"> 997<h1><a class="toc-backref" href="#id46">5 Metafunctions</a></h1> 998<p>A <a class="reference external" href="../../../mpl/doc/refmanual/metafunction.html">Metafunction</a> is conceptually a function that operates on, and returns, 999C++ types.</p> 1000<div class="section" id="id10"> 1001<span id="binding"></span><h2><a class="toc-backref" href="#id47">5.1 <tt class="docutils literal">binding</tt></a></h2> 1002<p>Returns the result type of indexing an argument pack with a 1003<a class="reference internal" href="#keyword-tag-type">keyword tag type</a> or with a <a class="reference internal" href="#tagged-default">tagged default</a>.</p> 1004<table class="docutils field-list" frame="void" rules="none"> 1005<col class="field-name" /> 1006<col class="field-body" /> 1007<tbody valign="top"> 1008<tr class="field"><th class="field-name">Defined in:</th><td class="field-body"><a class="reference external" href="../../../../boost/parameter/binding.hpp">boost/parameter/binding.hpp</a></td> 1009</tr> 1010</tbody> 1011</table> 1012<pre class="literal-block"> 1013template <typename A, typename K, typename D = void_> 1014struct binding 1015{ 1016 typedef … type; 1017}; 1018</pre> 1019<table class="docutils field-list" frame="void" rules="none"> 1020<col class="field-name" /> 1021<col class="field-body" /> 1022<tbody valign="top"> 1023<tr class="field"><th class="field-name">Requires:</th><td class="field-body"><tt class="docutils literal">A</tt> must be a model of <a class="reference internal" href="#argumentpack"><span class="concept">ArgumentPack</span></a>.</td> 1024</tr> 1025<tr class="field"><th class="field-name">Returns:</th><td class="field-body">the reference type of the <a class="reference internal" href="#tagged-reference">tagged reference</a> in <tt class="docutils literal">A</tt> having 1026<a class="reference internal" href="#keyword-tag-type">keyword tag type</a> <tt class="docutils literal">K</tt>, if any. If no such <a class="reference internal" href="#tagged-reference">tagged reference</a> exists, 1027returns <tt class="docutils literal">D</tt>.</td> 1028</tr> 1029</tbody> 1030</table> 1031</div> 1032<div class="section" id="id11"> 1033<span id="lazy-binding"></span><h2><a class="toc-backref" href="#id48">5.2 <tt class="docutils literal">lazy_binding</tt></a></h2> 1034<p>Returns the result type of indexing an argument pack with a 1035<a class="reference internal" href="#tagged-lazy-default">tagged lazy default</a>.</p> 1036<table class="docutils field-list" frame="void" rules="none"> 1037<col class="field-name" /> 1038<col class="field-body" /> 1039<tbody valign="top"> 1040<tr class="field"><th class="field-name">Defined in:</th><td class="field-body"><a class="reference external" href="../../../../boost/parameter/binding.hpp">boost/parameter/binding.hpp</a></td> 1041</tr> 1042</tbody> 1043</table> 1044<pre class="literal-block"> 1045template <typename A, typename K, typename F> 1046struct lazy_binding 1047{ 1048 typedef … type; 1049}; 1050</pre> 1051<table class="docutils field-list" frame="void" rules="none"> 1052<col class="field-name" /> 1053<col class="field-body" /> 1054<tbody valign="top"> 1055<tr class="field"><th class="field-name">Requires:</th><td class="field-body"><tt class="docutils literal">A</tt> must be a model of <a class="reference internal" href="#argumentpack"><span class="concept">ArgumentPack</span></a>.</td> 1056</tr> 1057<tr class="field"><th class="field-name">Returns:</th><td class="field-body">the reference type of the <a class="reference internal" href="#tagged-reference">tagged reference</a> in <tt class="docutils literal">A</tt> having 1058<a class="reference internal" href="#keyword-tag-type">keyword tag type</a> <tt class="docutils literal">K</tt>, if any. If no such <a class="reference internal" href="#tagged-reference">tagged reference</a> exists, 1059returns <a class="reference external" href="../../../utility/utility.htm#result_of"><tt class="docutils literal"><span class="pre">boost::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="id12"><sup>2</sup></a></td> 1060</tr> 1061</tbody> 1062</table> 1063</div> 1064<div class="section" id="id13"> 1065<span id="value-type"></span><h2><a class="toc-backref" href="#id49">5.3 <tt class="docutils literal">value_type</tt></a></h2> 1066<p>Returns the result type of indexing an argument pack with a 1067<a class="reference internal" href="#keyword-tag-type">keyword tag type</a> or with a <a class="reference internal" href="#tagged-default">tagged default</a>.</p> 1068<table class="docutils field-list" frame="void" rules="none"> 1069<col class="field-name" /> 1070<col class="field-body" /> 1071<tbody valign="top"> 1072<tr class="field"><th class="field-name">Defined in:</th><td class="field-body"><a class="reference external" href="../../../../boost/parameter/value_type.hpp">boost/parameter/value_type.hpp</a></td> 1073</tr> 1074</tbody> 1075</table> 1076<pre class="literal-block"> 1077template <typename A, typename K, typename D = void_> 1078struct value_type 1079{ 1080 typedef … type; 1081}; 1082</pre> 1083<table class="docutils field-list" frame="void" rules="none"> 1084<col class="field-name" /> 1085<col class="field-body" /> 1086<tbody valign="top"> 1087<tr class="field"><th class="field-name">Requires:</th><td class="field-body"><p class="first"><tt class="docutils literal">A</tt> must be a model of <a class="reference internal" href="#argumentpack"><span class="concept">ArgumentPack</span></a>.</p> 1088</td> 1089</tr> 1090<tr class="field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">the (possibly const-qualified) type of the <a class="reference internal" href="#tagged-reference">tagged reference</a> in 1091<tt class="docutils literal">A</tt> having <a class="reference internal" href="#keyword-tag-type">keyword tag type</a> <tt class="docutils literal">K</tt>, if any. If no such 1092<a class="reference internal" href="#tagged-reference">tagged reference</a> exists, returns <tt class="docutils literal">D</tt>. Equivalent to:</p> 1093<pre class="literal-block"> 1094typename <a class="reference external" href="../../../type_traits/doc/html/boost_typetraits/remove_reference.html">boost::remove_reference</a>< 1095 typename <a class="reference internal" href="#binding"><tt class="docutils literal">binding</tt></a><A, K, D>::type 1096>::type 1097</pre> 1098<p class="last">… when <tt class="docutils literal">D</tt> is not a reference type.</p> 1099</td> 1100</tr> 1101</tbody> 1102</table> 1103</div> 1104<div class="section" id="id14"> 1105<span id="lazy-value-type"></span><h2><a class="toc-backref" href="#id50">5.4 <tt class="docutils literal">lazy_value_type</tt></a></h2> 1106<p>Returns the result type of indexing an argument pack with a 1107<a class="reference internal" href="#tagged-lazy-default">tagged lazy default</a>.</p> 1108<table class="docutils field-list" frame="void" rules="none"> 1109<col class="field-name" /> 1110<col class="field-body" /> 1111<tbody valign="top"> 1112<tr class="field"><th class="field-name">Defined in:</th><td class="field-body"><a class="reference external" href="../../../../boost/parameter/value_type.hpp">boost/parameter/value_type.hpp</a></td> 1113</tr> 1114</tbody> 1115</table> 1116<pre class="literal-block"> 1117template <typename A, typename K, typename F> 1118struct lazy_value_type 1119{ 1120 typedef … type; 1121}; 1122</pre> 1123<table class="docutils field-list" frame="void" rules="none"> 1124<col class="field-name" /> 1125<col class="field-body" /> 1126<tbody valign="top"> 1127<tr class="field"><th class="field-name">Requires:</th><td class="field-body"><tt class="docutils literal">A</tt> must be a model of <a class="reference internal" href="#argumentpack"><span class="concept">ArgumentPack</span></a>.</td> 1128</tr> 1129<tr class="field"><th class="field-name">Returns:</th><td class="field-body">the (possibly const-qualified) type of the <a class="reference internal" href="#tagged-reference">tagged reference</a> in 1130<tt class="docutils literal">A</tt> having <a class="reference internal" href="#keyword-tag-type">keyword tag type</a> <tt class="docutils literal">K</tt>, if any. If no such 1131<a class="reference internal" href="#tagged-reference">tagged reference</a> exists, returns 1132<a class="reference external" href="../../../utility/utility.htm#result_of"><tt class="docutils literal"><span class="pre">boost::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="id15"><sup>2</sup></a></td> 1133</tr> 1134</tbody> 1135</table> 1136</div> 1137<div class="section" id="id16"> 1138<span id="are-tagged-arguments"></span><h2><a class="toc-backref" href="#id51">5.5 <tt class="docutils literal">are_tagged_arguments</tt></a></h2> 1139<table class="docutils field-list" frame="void" rules="none"> 1140<col class="field-name" /> 1141<col class="field-body" /> 1142<tbody valign="top"> 1143<tr class="field"><th class="field-name">Defined in:</th><td class="field-body"><a class="reference external" href="../../../../boost/parameter/are_tagged_arguments.hpp">boost/parameter/are_tagged_arguments.hpp</a></td> 1144</tr> 1145</tbody> 1146</table> 1147<pre class="literal-block"> 1148template <typename T0, typename ...Pack> 1149struct are_tagged_arguments 1150 // : <a class="reference external" href="../../../mpl/doc/refmanual/bool.html">mpl::true_</a> if T0 and all elements in Pack are 1151 // tagged reference types, <a class="reference external" href="../../../mpl/doc/refmanual/bool.html">mpl::false_</a> otherwise. 1152{ 1153}; 1154</pre> 1155<table class="docutils field-list" frame="void" rules="none"> 1156<col class="field-name" /> 1157<col class="field-body" /> 1158<tbody valign="top"> 1159<tr class="field"><th class="field-name">Returns:</th><td class="field-body"><tt class="docutils literal"><span class="pre">mpl::true_</span></tt> if <tt class="docutils literal">T0</tt> and all elements in parameter pack <tt class="docutils literal">Pack</tt> are 1160<a class="reference internal" href="#tagged-reference">tagged reference</a> types, <tt class="docutils literal"><span class="pre">mpl::false_</span></tt> otherwise.</td> 1161</tr> 1162<tr class="field"><th class="field-name">Example usage:</th><td class="field-body"></td> 1163</tr> 1164</tbody> 1165</table> 1166<p>When implementing a Boost.Parameter-enabled constructor for a container that 1167conforms to the C++ standard, one needs to remember that the standard requires 1168the presence of other constructors that are typically defined as templates, 1169such as range constructors. To avoid overload ambiguities between the two 1170constructors, use this metafunction in conjunction with <tt class="docutils literal">disable_if</tt> to 1171define the range constructor.</p> 1172<pre class="literal-block"> 1173template <typename B> 1174class frontend : public B 1175{ 1176 struct _enabler 1177 { 1178 }; 1179 1180 public: 1181 <a class="reference internal" href="#boost-parameter-no-spec-constructor"><tt class="docutils literal">BOOST_PARAMETER_NO_SPEC_CONSTRUCTOR</tt></a>(frontend, (B)) 1182 1183 template <typename Iterator> 1184 frontend( 1185 Iterator itr 1186 , Iterator itr_end 1187 , typename <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::disable_if</a>< 1188 are_tagged_arguments<Iterator> 1189 , _enabler 1190 >::type = _enabler() 1191 ) : B(itr, itr_end) 1192 { 1193 } 1194}; 1195</pre> 1196</div> 1197<div class="section" id="id17"> 1198<span id="is-argument-pack"></span><h2><a class="toc-backref" href="#id52">5.6 <tt class="docutils literal">is_argument_pack</tt></a></h2> 1199<table class="docutils field-list" frame="void" rules="none"> 1200<col class="field-name" /> 1201<col class="field-body" /> 1202<tbody valign="top"> 1203<tr class="field"><th class="field-name">Defined in:</th><td class="field-body"><a class="reference external" href="../../../../boost/parameter/is_argument_pack.hpp">boost/parameter/is_argument_pack.hpp</a></td> 1204</tr> 1205</tbody> 1206</table> 1207<pre class="literal-block"> 1208template <typename T> 1209struct is_argument_pack 1210 // : <a class="reference external" href="../../../mpl/doc/refmanual/bool.html">mpl::true_</a> if T is a model of <a class="reference internal" href="#argumentpack"><span class="concept">ArgumentPack</span></a>, 1211 // <a class="reference external" href="../../../mpl/doc/refmanual/bool.html">mpl::false_</a> otherwise. 1212{ 1213}; 1214</pre> 1215<table class="docutils field-list" frame="void" rules="none"> 1216<col class="field-name" /> 1217<col class="field-body" /> 1218<tbody valign="top"> 1219<tr class="field"><th class="field-name">Returns:</th><td class="field-body"><tt class="docutils literal"><span class="pre">mpl::true_</span></tt> if <tt class="docutils literal">T</tt> is a model of <a class="reference internal" href="#argumentpack"><span class="concept">ArgumentPack</span></a>, <tt class="docutils literal"><span class="pre">mpl::false_</span></tt> 1220otherwise.</td> 1221</tr> 1222<tr class="field"><th class="field-name">Example usage:</th><td class="field-body"></td> 1223</tr> 1224</tbody> 1225</table> 1226<p>To avoid overload ambiguities between a constructor that takes in an 1227<a class="reference internal" href="#argumentpack"><span class="concept">ArgumentPack</span></a> and a templated conversion constructor, use this 1228metafunction in conjunction with <tt class="docutils literal">enable_if</tt>.</p> 1229<pre class="literal-block"> 1230<a class="reference internal" href="#boost-parameter-name"><tt class="docutils literal">BOOST_PARAMETER_NAME</tt></a>(a0) 1231 1232template <typename T> 1233class backend0 1234{ 1235 struct _enabler 1236 { 1237 }; 1238 1239 T a0; 1240 1241 public: 1242 template <typename ArgPack> 1243 explicit backend0( 1244 ArgPack const& args 1245 , typename <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::enable_if</a>< 1246 is_argument_pack<ArgPack> 1247 , _enabler 1248 >::type = _enabler() 1249 ) : a0(args[_a0]) 1250 { 1251 } 1252 1253 template <typename U> 1254 backend0( 1255 backend0<U> const& copy 1256 , typename <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::enable_if</a>< 1257 <a class="reference external" href="../../../type_traits/doc/html/boost_typetraits/is_convertible.html">boost::is_convertible</a><U,T> 1258 , _enabler 1259 >::type = _enabler() 1260 ) : a0(copy.get_a0()) 1261 { 1262 } 1263 1264 T const& get_a0() const 1265 { 1266 return this->a0; 1267 } 1268}; 1269</pre> 1270</div> 1271<div class="section" id="id18"> 1272<span id="result-of-compose"></span><h2><a class="toc-backref" href="#id53">5.7 <tt class="docutils literal"><span class="pre">result_of::compose</span></tt></a></h2> 1273<p>Returns the result type of the <a class="reference internal" href="#compose"><tt class="docutils literal">compose</tt></a> function.</p> 1274<table class="docutils field-list" frame="void" rules="none"> 1275<col class="field-name" /> 1276<col class="field-body" /> 1277<tbody valign="top"> 1278<tr class="field"><th class="field-name">Defined in:</th><td class="field-body"><a class="reference external" href="../../../../boost/parameter/compose.hpp">boost/parameter/compose.hpp</a></td> 1279</tr> 1280</tbody> 1281</table> 1282<pre class="literal-block"> 1283template <typename ...TaggedArgs> 1284struct compose 1285 : <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::enable_if</a>< 1286 <a class="reference internal" href="#are-tagged-arguments"><tt class="docutils literal">are_tagged_arguments</tt></a><T0,Pack...> 1287 , <a class="reference internal" href="#argumentpack"><span class="concept">ArgumentPack</span></a> 1288 > 1289{ 1290}; 1291 1292template <> 1293struct compose<> 1294{ 1295 typedef <em>empty</em> <a class="reference internal" href="#argumentpack"><span class="concept">ArgumentPack</span></a> type; 1296}; 1297</pre> 1298<table class="docutils field-list" frame="void" rules="none"> 1299<col class="field-name" /> 1300<col class="field-body" /> 1301<tbody valign="top"> 1302<tr class="field"><th class="field-name">Requires:</th><td class="field-body">All elements in <tt class="docutils literal">TaggedArgs</tt> must be <a class="reference internal" href="#tagged-reference">tagged reference</a> types, if 1303specified.</td> 1304</tr> 1305<tr class="field"><th class="field-name">Returns:</th><td class="field-body">the result type of the <a class="reference internal" href="#compose"><tt class="docutils literal">compose</tt></a> function.</td> 1306</tr> 1307</tbody> 1308</table> 1309</div> 1310</div> 1311<hr class="docutils" /> 1312<div class="section" id="function-templates"> 1313<h1><a class="toc-backref" href="#id54">6 Function Templates</a></h1> 1314<div class="section" id="id19"> 1315<span id="compose"></span><h2><a class="toc-backref" href="#id55">6.1 <tt class="docutils literal">compose</tt></a></h2> 1316<table class="docutils field-list" frame="void" rules="none"> 1317<col class="field-name" /> 1318<col class="field-body" /> 1319<tbody valign="top"> 1320<tr class="field"><th class="field-name">Defined in:</th><td class="field-body"><a class="reference external" href="../../../../boost/parameter/compose.hpp">boost/parameter/compose.hpp</a></td> 1321</tr> 1322</tbody> 1323</table> 1324<pre class="literal-block"> 1325template <typename ...Pack> 1326constexpr typename <a class="reference internal" href="#result-of-compose"><tt class="docutils literal"><span class="pre">result_of::compose</span></tt></a><Pack...>::type 1327 compose(Pack const&... args); 1328</pre> 1329<p>This function facilitates easier variadic argument composition. It is used by 1330the <a class="reference internal" href="#boost-parameter-no-spec-function"><tt class="docutils literal">BOOST_PARAMETER_NO_SPEC_FUNCTION</tt></a>, 1331<a class="reference internal" href="#boost-parameter-no-spec-member-function"><tt class="docutils literal">BOOST_PARAMETER_NO_SPEC_MEMBER_FUNCTION</tt></a>, 1332<a class="reference internal" href="#boost-parameter-no-spec-const-member-function"><tt class="docutils literal">BOOST_PARAMETER_NO_SPEC_CONST_MEMBER_FUNCTION</tt></a>, 1333<a class="reference internal" href="#boost-parameter-no-spec-function-call-operator"><tt class="docutils literal">BOOST_PARAMETER_NO_SPEC_FUNCTION_CALL_OPERATOR</tt></a>, 1334<a class="reference internal" href="#boost-parameter-no-spec-const-function-call-operator"><tt class="docutils literal">BOOST_PARAMETER_NO_SPEC_CONST_FUNCTION_CALL_OPERATOR</tt></a>, 1335<a class="reference internal" href="#boost-parameter-no-spec-constructor"><tt class="docutils literal">BOOST_PARAMETER_NO_SPEC_CONSTRUCTOR</tt></a>, and 1336<a class="reference internal" href="#boost-parameter-no-spec-no-base-constructor"><tt class="docutils literal">BOOST_PARAMETER_NO_SPEC_NO_BASE_CONSTRUCTOR</tt></a> code generation macros. You 1337can use it to write your own code generation macros if the ones provided by 1338this library do not suffice.</p> 1339<p>Unlike the <a class="reference internal" href="#tagged-reference">tagged reference</a> comma operator, the <tt class="docutils literal">compose()</tt> function is 1340variadic, as mentioned before. However, the <a class="reference internal" href="#tagged-reference">tagged reference</a> comma operator 1341can be invoked indefinitely and therefore does not limit the size of the 1342resulting <span class="concept">ArgumentPack</span>, while the <tt class="docutils literal">compose()</tt> function cannot take in more 1343than <a class="reference internal" href="#boost-parameter-compose-max-arity"><tt class="docutils literal">BOOST_PARAMETER_COMPOSE_MAX_ARITY</tt></a> arguments for compilers that do not 1344support perfect forwarding.</p> 1345<table class="docutils field-list" frame="void" rules="none"> 1346<col class="field-name" /> 1347<col class="field-body" /> 1348<tbody valign="top"> 1349<tr class="field"><th class="field-name">Requires:</th><td class="field-body">All elements in <tt class="docutils literal">args</tt> must be <a class="reference internal" href="#tagged-reference">tagged reference</a> objects, if 1350specified.</td> 1351</tr> 1352<tr class="field"><th class="field-name">Returns:</th><td class="field-body">an <a class="reference internal" href="#argumentpack"><span class="concept">ArgumentPack</span></a> containing all elements in <tt class="docutils literal">args</tt>, if 1353specified; an empty <a class="reference internal" href="#argumentpack"><span class="concept">ArgumentPack</span></a> otherwise.</td> 1354</tr> 1355<tr class="field"><th class="field-name">Example usage:</th><td class="field-body"></td> 1356</tr> 1357</tbody> 1358</table> 1359<pre class="literal-block"> 1360BOOST_PARAMETER_NAME(index) 1361BOOST_PARAMETER_NAME(name) 1362 1363template <typename ArgumentPack> 1364int print_name_and_index(ArgumentPack const& args) 1365{ 1366 std::cout << "index = " << args[_index]; 1367 std::cout << "name = " << args[_name]; 1368 std::cout << "; " << std::endl; 1369 return 0; 1370} 1371 1372int y = print_name_and_index(compose(_index = 3, _name = "jones")); 1373</pre> 1374<p>The <a class="reference external" href="../../test/compose.cpp">compose.cpp</a> test program shows more examples using this function.</p> 1375</div> 1376</div> 1377<hr class="docutils" /> 1378<div class="section" id="code-generation-macros"> 1379<h1><a class="toc-backref" href="#id56">7 Code Generation Macros</a></h1> 1380<p>Macros in this section can be used to ease the writing of code 1381using the Parameter library by eliminating repetitive boilerplate.</p> 1382<div class="section" id="boost-parameter-function-result-name-tag-namespace-arguments"> 1383<span id="boost-parameter-function"></span><h2><a class="toc-backref" href="#id57">7.1 <tt class="docutils literal">BOOST_PARAMETER_FUNCTION(result, name, tag_namespace, arguments)</tt></a></h2> 1384<table class="docutils field-list" frame="void" rules="none"> 1385<col class="field-name" /> 1386<col class="field-body" /> 1387<tbody valign="top"> 1388<tr class="field"><th class="field-name">Defined in:</th><td class="field-body"><a class="reference external" href="../../../../boost/parameter/preprocessor.hpp">boost/parameter/preprocessor.hpp</a></td> 1389</tr> 1390</tbody> 1391</table> 1392<p>Generates a function that can take in positional arguments, composed 1393arguments, named arguments, and deduced arguments.</p> 1394<table class="docutils field-list" frame="void" rules="none"> 1395<col class="field-name" /> 1396<col class="field-body" /> 1397<tbody valign="top"> 1398<tr class="field"><th class="field-name">Example usage:</th><td class="field-body"></td> 1399</tr> 1400</tbody> 1401</table> 1402<p>The return type of each of the following function templates falls under a 1403different value category.</p> 1404<pre class="literal-block"> 1405template <std::size_t N> 1406<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1> rvalue_bitset() 1407{ 1408 return <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1>(); 1409} 1410 1411template <std::size_t N> 1412<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1> const rvalue_const_bitset() 1413{ 1414 return <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1>(); 1415} 1416 1417template <std::size_t N> 1418<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1>& lvalue_bitset() 1419{ 1420 static <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1> lset = <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1>(); 1421 return lset; 1422} 1423 1424template <std::size_t N> 1425<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1> const& lvalue_const_bitset() 1426{ 1427 static <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1> const clset = <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1>(); 1428 return clset; 1429} 1430</pre> 1431<p>The <tt class="docutils literal"><span class="pre">U::evaluate_category</span></tt> static member function template has a simple job: 1432to return the correct value category when passed in an object returned by one 1433of the functions defined above. Assume that 1434<a class="reference internal" href="#boost-parameter-has-perfect-forwarding"><tt class="docutils literal">BOOST_PARAMETER_HAS_PERFECT_FORWARDING</tt></a> is defined.</p> 1435<pre class="literal-block"> 1436enum invoked 1437{ 1438 passed_by_lvalue_reference_to_const 1439 , passed_by_lvalue_reference 1440 , passed_by_rvalue_reference_to_const 1441 , passed_by_rvalue_reference 1442}; 1443 1444struct U 1445{ 1446 template <std::size_t N> 1447 static invoked evaluate_category(<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1> const&) 1448 { 1449 return passed_by_lvalue_reference_to_const; 1450 } 1451 1452 template <std::size_t N> 1453 static invoked evaluate_category(<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1>&) 1454 { 1455 return passed_by_lvalue_reference; 1456 } 1457 1458 template <std::size_t N> 1459 static invoked evaluate_category(<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1> const&&) 1460 { 1461 return passed_by_rvalue_reference_to_const; 1462 } 1463 1464 template <std::size_t N> 1465 static invoked evaluate_category(<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1>&&) 1466 { 1467 return passed_by_rvalue_reference; 1468 } 1469}; 1470</pre> 1471<p>Define the named parameters that will comprise the argument specification that 1472this macro will use. Ensure that all their tag types are in the same 1473namespace, which is <tt class="docutils literal">kw</tt> in this case. The identifiers with leading 1474underscores can be passed to the bracket operator of <tt class="docutils literal">args</tt> to extract the 1475same argument to which the corresponding named parameter (without underscores) 1476is bound, as will be shown later.</p> 1477<pre class="literal-block"> 1478<a class="reference internal" href="#boost-parameter-name"><tt class="docutils literal">BOOST_PARAMETER_NAME</tt></a>((_lrc, kw) in(lrc)) 1479<a class="reference internal" href="#boost-parameter-name"><tt class="docutils literal">BOOST_PARAMETER_NAME</tt></a>((_lr, kw) in_out(lr)) 1480<a class="reference internal" href="#boost-parameter-name"><tt class="docutils literal">BOOST_PARAMETER_NAME</tt></a>((_rrc, kw) in(rrc)) 1481<a class="reference internal" href="#boost-parameter-name"><tt class="docutils literal">BOOST_PARAMETER_NAME</tt></a>((_rr, kw) consume(rr)) 1482</pre> 1483<p>Use the macro as a substitute for a normal function header. Enclose the 1484return type <tt class="docutils literal">bool</tt> in parentheses. For each parameter, also enclose the 1485expected value type in parentheses. Since the value types are mutually 1486exclusive, you can wrap the parameters in a <tt class="docutils literal">(deduced …)</tt> 1487clause. Otherwise, just as with a normal function, the order in which you 1488specify the parameters determines their position. Also, just as with a normal 1489function, optional parameters have default values, whereas required parameters 1490do not. Within the function body, either simply use the parameter name or 1491pass the matching identifier with the leading underscore to the bracket 1492operator of <tt class="docutils literal">args</tt> to extract the corresponding argument. Note that the 1493second method doesn't require <tt class="docutils literal"><span class="pre">std::forward</span></tt> to preserve value categories.</p> 1494<pre class="literal-block"> 1495BOOST_PARAMETER_FUNCTION((bool), evaluate, kw, 1496 (deduced 1497 (required 1498 (lrc, (<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><1>)) 1499 (lr, (<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><2>)) 1500 ) 1501 (optional 1502 (rrc, (<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><3>), rvalue_const_bitset<2>()) 1503 (rr, (<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><4>), rvalue_bitset<3>()) 1504 ) 1505 ) 1506) 1507{ 1508 BOOST_TEST_EQ( 1509 passed_by_lvalue_reference_to_const 1510 , U::evaluate_category<0>(lrc) 1511 ); 1512 BOOST_TEST_EQ( 1513 passed_by_lvalue_reference 1514 , U::evaluate_category<1>(lr) 1515 ); 1516 BOOST_TEST_EQ( 1517 passed_by_rvalue_reference_to_const 1518 , U::evaluate_category<2>(<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/forward">std::forward</a><rrc0_type>(rrc0)) 1519 ); 1520 BOOST_TEST_EQ( 1521 passed_by_rvalue_reference 1522 , U::evaluate_category<3>(args[_rr0]) 1523 ); 1524 1525 return true; 1526} 1527</pre> 1528<p>The following function calls are legal.</p> 1529<pre class="literal-block"> 1530evaluate( // positional arguments 1531 lvalue_const_bitset<0>() 1532 , lvalue_bitset<1>() 1533 , rvalue_const_bitset<2>() 1534 , rvalue_bitset<3>() 1535); 1536evaluate( // positional arguments 1537 lvalue_const_bitset<0>() 1538 , lvalue_bitset<1>() 1539); 1540evaluate(( // composed arguments 1541 _rr0 = rvalue_bitset<3>() 1542 , _lrc0 = lvalue_const_bitset<0>() 1543 , _lr0 = lvalue_bitset<1>() 1544 , _rrc0 = rvalue_const_bitset<2>() 1545)); 1546evaluate( // named arguments 1547 _rr0 = rvalue_bitset<3>() 1548 , _lrc0 = lvalue_const_bitset<0>() 1549 , _lr0 = lvalue_bitset<1>() 1550 , _rrc0 = rvalue_const_bitset<2>() 1551); 1552evaluate( // named arguments 1553 _lr0 = lvalue_bitset<1>() 1554 , _lrc0 = lvalue_const_bitset<0>() 1555); 1556</pre> 1557<p>Because the parameters were wrapped in a <tt class="docutils literal">(deduced …)</tt> clause, the following 1558function calls are also legal.</p> 1559<pre class="literal-block"> 1560evaluate( // deduced arguments 1561 rvalue_bitset<3>() 1562 , lvalue_const_bitset<0>() 1563 , lvalue_bitset<1>() 1564 , rvalue_const_bitset<2>() 1565); 1566evaluate( // deduced arguments 1567 lvalue_bitset<1>() 1568 , lvalue_const_bitset<0>() 1569); 1570</pre> 1571<p>The <a class="reference external" href="../../test/preprocessor.cpp">preprocessor.cpp</a>, <a class="reference external" href="../../test/preprocessor_deduced.cpp">preprocessor_deduced.cpp</a>, and 1572<a class="reference external" href="../../test/preprocessor_eval_category.cpp">preprocessor_eval_category.cpp</a> test programs demonstrate proper usage of this 1573macro.</p> 1574<p><strong>Macro parameters:</strong></p> 1575<ul class="simple"> 1576<li><tt class="docutils literal">result</tt> is the parenthesized return type of the function.</li> 1577<li><tt class="docutils literal">name</tt> is the base name of the function; it determines the name of the 1578generated forwarding functions.</li> 1579<li><tt class="docutils literal">tag_namespace</tt> is the namespace in which the keywords used by the 1580function resides.</li> 1581<li><tt class="docutils literal">arguments</tt> is a <a class="reference external" href="../../../preprocessor/doc/index.html">Boost.Preprocessor</a> <a class="reference external" href="../../../preprocessor/doc/data/sequences.html">sequence</a> of 1582<em>argument-specifiers</em>, as defined below.</li> 1583</ul> 1584<p><strong>Argument specifiers syntax:</strong></p> 1585<pre class="literal-block"> 1586argument-specifiers ::= <em>specifier-group0</em> {<em>specifier-group0</em>} 1587 1588specifier-group0 ::= <em>specifier-group1</em> | 1589 ( 1590 '<strong>(</strong>' '<strong>deduced</strong>' 1591 <em>specifier-group1</em> {<em>specifier-group1</em>} 1592 '<strong>)</strong>' 1593 ) 1594 1595specifier-group1 ::= 1596 ( 1597 '<strong>(</strong>' '<strong>optional</strong>' 1598 <em>optional-specifier</em> {<em>optional-specifier</em>} 1599 '<strong>)</strong>' 1600 ) | ( 1601 '<strong>(</strong>' '<strong>required</strong>' 1602 <em>required-specifier</em> {<em>required-specifier</em>} 1603 '<strong>)</strong>' 1604 ) 1605 1606optional-specifier ::= 1607 '<strong>(</strong>' 1608 <em>argument-name</em> '<strong>,</strong>' <em>restriction</em> '<strong>,</strong>' <em>default-value</em> 1609 ')' 1610 1611required-specifier ::= 1612 '<strong>(</strong>' <em>argument-name</em> '<strong>,</strong>' <em>restriction</em> ')' 1613 1614restriction ::= 1615 ( '<strong>*</strong>' '<strong>(</strong>' <em>mfc</em> '<strong>)</strong>' ) | 1616 ( '<strong>(</strong>' <em>type-name</em> '<strong>)</strong>' ) | 1617 '<strong>*</strong>' 1618</pre> 1619<ul class="simple"> 1620<li><tt class="docutils literal"><span class="pre">argument-name</span></tt> is any valid C++ identifier.</li> 1621<li><tt class="docutils literal"><span class="pre">default-value</span></tt> is any valid C++ expression; if necessary, user code can 1622compute it in terms of <tt class="docutils literal"><span class="pre">previous-name</span> ## _type</tt>, where <tt class="docutils literal"><span class="pre">previous-name</span></tt> 1623is the <tt class="docutils literal"><span class="pre">argument-name</span></tt> in a previous <tt class="docutils literal"><span class="pre">specifier-group0</span></tt> or 1624<tt class="docutils literal"><span class="pre">specifier-group1</span></tt>. <em>This expression will be invoked exactly once.</em></li> 1625<li><tt class="docutils literal">mfc</tt> is an <a class="reference external" href="../../../mpl/doc/refmanual/metafunction-class.html">MPL Binary Metafunction Class</a> whose first argument will 1626be the type of the corresponding <tt class="docutils literal"><span class="pre">argument-name</span></tt>, whose second argument 1627will be the entire <a class="reference internal" href="#argumentpack"><span class="concept">ArgumentPack</span></a>, and whose return type is a <a class="reference external" href="../../../mpl/doc/refmanual/integral-constant.html">Boolean 1628Integral Constant</a>; however, user code <em>cannot</em> compute <tt class="docutils literal">mfc</tt> in terms 1629of <tt class="docutils literal"><span class="pre">previous-name</span> ## _type</tt>.</li> 1630<li><tt class="docutils literal"><span class="pre">type-name</span></tt> is either the name of a <strong>target type</strong> or an <a class="reference external" href="../../../mpl/doc/refmanual/metafunction-class.html">MPL Binary 1631Metafunction Class</a> whose first argument will be the type of the 1632corresponding <tt class="docutils literal"><span class="pre">argument-name</span></tt>, whose second argument will be the entire 1633<a class="reference internal" href="#argumentpack"><span class="concept">ArgumentPack</span></a>, and whose return type is the <strong>target type</strong>. If 1634<tt class="docutils literal">restriction</tt> uses this form, then the type of the generated name 1635<tt class="docutils literal"><span class="pre">argument-name</span> ## _type</tt> will be computed in terms of the <strong>target 1636type</strong>, and the generated reference <tt class="docutils literal"><span class="pre">argument-name</span></tt> (but not its 1637corresponding entry in <tt class="docutils literal">args</tt>) will be cast to that type.</li> 1638</ul> 1639<p><strong>Approximate expansion:</strong></p> 1640<p>Where:</p> 1641<ul class="simple"> 1642<li><tt class="docutils literal">n</tt> denotes the <em>minimum</em> arity, as determined from <tt class="docutils literal">arguments</tt>.</li> 1643<li><tt class="docutils literal">m</tt> denotes the <em>maximum</em> arity, as determined from <tt class="docutils literal">arguments</tt>.</li> 1644</ul> 1645<pre class="literal-block"> 1646// If <strong>result</strong> is a template instantiation of <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::enable_if</a>, 1647// <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::enable_if_c</a>, <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::lazy_enable_if</a>, 1648// <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::lazy_enable_if_c</a>, <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::disable_if</a>, <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::disable_if_c</a>, 1649// <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::lazy_disable_if</a>, <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::lazy_disable_if_c</a>, or 1650// <a class="reference external" href="http://en.cppreference.com/w/cpp/types/enable_if">std::enable_if</a>: 1651template <typename Args> 1652using boost_param_result_ ## __LINE__ ## <strong>name</strong> = <strong>result</strong>; 1653 1654// If <strong>result</strong> is a simple return type: 1655template <typename Args> 1656struct boost_param_result_ ## __LINE__ ## <strong>name</strong> 1657{ 1658 typedef <strong>result</strong> type; 1659}; 1660 1661struct boost_param_params_ ## __LINE__ ## <strong>name</strong> 1662 : <a class="reference internal" href="#parameters"><tt class="docutils literal">parameters</tt></a>< 1663 <em>list of parameter specifications, based on arguments</em> 1664 > 1665{ 1666}; 1667 1668typedef boost_param_params_ ## __LINE__ ## <strong>name</strong> 1669 boost_param_parameters_ ## __LINE__ ## <strong>name</strong>; 1670 1671template <typename Args> 1672typename boost_param_result_ ## __LINE__ ## <strong>name</strong><Args>::type 1673 boost_param_impl ## __LINE__ ## <strong>name</strong>(Args const&); 1674 1675template <typename A0, …, typename A ## <strong>n</strong>> 1676<strong>result</strong> <strong>name</strong>( 1677 A0&& a0, …, A ## <strong>n</strong>&& a ## <strong>n</strong> 1678 , typename boost_param_parameters_ ## __LINE__ ## <strong>name</strong> 1679 ::match<A0, …, A ## <strong>n</strong>>::type 1680 = boost_param_parameters_ ## __LINE__ ## <strong>name</strong>() 1681) 1682{ 1683 return boost_param_impl ## __LINE__ ## <strong>name</strong>( 1684 boost_param_parameters_ ## __LINE__ ## <strong>name</strong>()( 1685 <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/forward">std::forward</a><A0>(a0) 1686 , … 1687 , <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/forward">std::forward</a><A ## <strong>n</strong>>(a ## <strong>n</strong>) 1688 ) 1689 ); 1690} 1691 1692<span class="vellipsis">⋮</span> 1693 1694template <typename A0, …, typename A ## <strong>m</strong>> 1695<strong>result</strong> <strong>name</strong>( 1696 A0&& a0, …, A ## <strong>m</strong>&& a ## <strong>m</strong> 1697 , typename boost_param_parameters_ ## __LINE__ ## <strong>name</strong> 1698 ::match<A0, …, A ## <strong>m</strong>>::type 1699 = boost_param_parameters_ ## __LINE__ ## <strong>name</strong>() 1700) 1701{ 1702 return boost_param_impl ## __LINE__ ## <strong>name</strong>( 1703 boost_param_parameters_ ## __LINE__ ## <strong>name</strong>()( 1704 <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/forward">std::forward</a><A0>(a0) 1705 , … 1706 , <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/forward">std::forward</a><A ## <strong>m</strong>>(a ## <strong>m</strong>) 1707 ) 1708 ); 1709} 1710 1711template < 1712 typename ResultType 1713 , typename Args 1714 , typename <em>argument name</em> ## <strong>0</strong> ## _type 1715 , … 1716 , typename <em>argument name</em> ## <strong>n</strong> ## _type 1717> 1718ResultType 1719 boost_param_dispatch_0boost_ ## __LINE__ ## <strong>name</strong>( 1720 (ResultType(*)()) 1721 , Args const& args 1722 , <em>argument name</em> ## <strong>0</strong> ## _type&& <em>argument name</em> ## <strong>0</strong> 1723 , … 1724 , <em>argument name</em> ## <strong>n</strong> ## _type&& <em>argument name</em> ## <strong>m</strong> 1725 ); 1726 1727<span class="vellipsis">⋮</span> 1728 1729template < 1730 typename ResultType 1731 , typename Args 1732 , typename <em>argument name</em> ## <strong>0</strong> ## _type 1733 , … 1734 , typename <em>argument name</em> ## <strong>m</strong> ## _type 1735> 1736ResultType 1737 boost_param_dispatch_0boost_ ## __LINE__ ## <strong>name</strong>( 1738 (ResultType(*)()) 1739 , Args const& args 1740 , <em>argument name</em> ## <strong>0</strong> ## _type&& <em>argument name</em> ## <strong>0</strong> 1741 , … 1742 , <em>argument name</em> ## <strong>m</strong> ## _type&& <em>argument name</em> ## <strong>m</strong> 1743 ); 1744 1745template <typename Args> 1746typename boost_param_result_ ## __LINE__ ## <strong>name</strong><Args>::type 1747 boost_param_impl ## __LINE__ ## <strong>name</strong>(Args const& args) 1748{ 1749 return boost_param_dispatch_0boost_ ## __LINE__ ## <strong>name</strong>( 1750 static_cast< 1751 typename boost_param_result_ ## __LINE__ ## <strong>name</strong>< 1752 Args 1753 >::type(*)() 1754 >(<a class="reference external" href="http://en.cppreference.com/w/cpp/language/nullptr">std::nullptr</a>) 1755 , args 1756 , <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/forward">std::forward</a>< 1757 typename <a class="reference internal" href="#value-type"><tt class="docutils literal">value_type</tt></a>< 1758 Args 1759 , <em>keyword tag type of required parameter</em> ## <strong>0</strong> 1760 >::type 1761 >(args[ <em>keyword object of required parameter</em> ## <strong>0</strong>]) 1762 , … 1763 , <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/forward">std::forward</a>< 1764 typename <a class="reference internal" href="#value-type"><tt class="docutils literal">value_type</tt></a>< 1765 Args 1766 , <em>keyword tag type of required parameter</em> ## <strong>n</strong> 1767 >::type 1768 >(args[ <em>keyword object of required parameter</em> ## <strong>n</strong>]) 1769 ); 1770} 1771 1772template < 1773 typename ResultType 1774 , typename Args 1775 , typename <em>argument name</em> ## <strong>0</strong> ## _type 1776 , … 1777 , typename <em>argument name</em> ## <strong>n</strong> ## _type 1778> 1779ResultType 1780 boost_param_dispatch_0boost_ ## __LINE__ ## <strong>name</strong>( 1781 (ResultType(*)()) 1782 , Args const& args 1783 , <em>argument name</em> ## <strong>0</strong> ## _type&& <em>argument name</em> ## <strong>0</strong> 1784 , … 1785 , <em>argument name</em> ## <strong>n</strong> ## _type&& <em>argument name</em> ## <strong>n</strong> 1786 ) 1787{ 1788 return boost_param_dispatch_0boost_ ## __LINE__ ## <strong>name</strong>( 1789 static_cast<ResultType(*)()>(<a class="reference external" href="http://en.cppreference.com/w/cpp/language/nullptr">std::nullptr</a>) 1790 , (args, <em>keyword object of optional parameter</em> ## <strong>n + 1</strong> = 1791 <em>default value of optional parameter</em> ## <strong>n + 1</strong> 1792 ) 1793 , <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/forward">std::forward</a><<em>argument name</em> ## <strong>0</strong> ## _type>( 1794 <em>argument name</em> ## <strong>0</strong> 1795 ) 1796 , … 1797 , <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/forward">std::forward</a><<em>argument name</em> ## <strong>n</strong> ## _type>( 1798 <em>argument name</em> ## <strong>n</strong> 1799 ) 1800 , <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/forward">std::forward</a>< 1801 typename <a class="reference internal" href="#value-type"><tt class="docutils literal">value_type</tt></a>< 1802 Args 1803 , <em>keyword tag type of optional parameter</em> ## <strong>n + 1</strong> 1804 >::type 1805 >(<em>default value of optional parameter</em> ## <strong>n + 1</strong>) 1806 ); 1807} 1808 1809<span class="vellipsis">⋮</span> 1810 1811template < 1812 typename ResultType 1813 , typename Args 1814 , typename <em>argument name</em> ## <strong>0</strong> ## _type 1815 , … 1816 , typename <em>argument name</em> ## <strong>m</strong> ## _type 1817> 1818ResultType 1819 boost_param_dispatch_0boost_ ## __LINE__ ## <strong>name</strong>( 1820 (ResultType(*)()) 1821 , Args const& args 1822 , <em>argument name</em> ## <strong>0</strong> ## _type&& <em>argument name</em> ## <strong>0</strong> 1823 , … 1824 , <em>argument name</em> ## <strong>m</strong> ## _type&& <em>argument name</em> ## <strong>m</strong> 1825 ) 1826</pre> 1827</div> 1828<div class="section" id="boost-parameter-member-function-result-name-tag-namespace-arguments"> 1829<span id="boost-parameter-member-function"></span><h2><a class="toc-backref" href="#id58">7.2 <tt class="docutils literal">BOOST_PARAMETER_MEMBER_FUNCTION(result, name, tag_namespace, arguments)</tt></a></h2> 1830<table class="docutils field-list" frame="void" rules="none"> 1831<col class="field-name" /> 1832<col class="field-body" /> 1833<tbody valign="top"> 1834<tr class="field"><th class="field-name">Defined in:</th><td class="field-body"><a class="reference external" href="../../../../boost/parameter/preprocessor.hpp">boost/parameter/preprocessor.hpp</a></td> 1835</tr> 1836</tbody> 1837</table> 1838<p>Generates a member function that can take in positional arguments, composed 1839arguments, named arguments, and deduced arguments.</p> 1840<table class="docutils field-list" frame="void" rules="none"> 1841<col class="field-name" /> 1842<col class="field-body" /> 1843<tbody valign="top"> 1844<tr class="field"><th class="field-name">Example usage:</th><td class="field-body"></td> 1845</tr> 1846</tbody> 1847</table> 1848<p>The return type of each of the following function templates falls under a 1849different value category.</p> 1850<pre class="literal-block"> 1851template <std::size_t N> 1852<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1> rvalue_bitset() 1853{ 1854 return <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1>(); 1855} 1856 1857template <std::size_t N> 1858<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1> const rvalue_const_bitset() 1859{ 1860 return <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1>(); 1861} 1862 1863template <std::size_t N> 1864<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1>& lvalue_bitset() 1865{ 1866 static <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1> lset = <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1>(); 1867 return lset; 1868} 1869 1870template <std::size_t N> 1871<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1> const& lvalue_const_bitset() 1872{ 1873 static <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1> const clset = <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1>(); 1874 return clset; 1875} 1876</pre> 1877<p>The <tt class="docutils literal"><span class="pre">U::evaluate_category</span></tt> static member function template has a simple job: 1878to return the correct value category when passed in an object returned by one 1879of the functions defined above. Assume that 1880<a class="reference internal" href="#boost-parameter-has-perfect-forwarding"><tt class="docutils literal">BOOST_PARAMETER_HAS_PERFECT_FORWARDING</tt></a> is defined.</p> 1881<pre class="literal-block"> 1882enum invoked 1883{ 1884 passed_by_lvalue_reference_to_const 1885 , passed_by_lvalue_reference 1886 , passed_by_rvalue_reference_to_const 1887 , passed_by_rvalue_reference 1888}; 1889 1890struct U 1891{ 1892 template <std::size_t N> 1893 static invoked evaluate_category(<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1> const&) 1894 { 1895 return passed_by_lvalue_reference_to_const; 1896 } 1897 1898 template <std::size_t N> 1899 static invoked evaluate_category(<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1>&) 1900 { 1901 return passed_by_lvalue_reference; 1902 } 1903 1904 template <std::size_t N> 1905 static invoked evaluate_category(<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1> const&&) 1906 { 1907 return passed_by_rvalue_reference_to_const; 1908 } 1909 1910 template <std::size_t N> 1911 static invoked evaluate_category(<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1>&&) 1912 { 1913 return passed_by_rvalue_reference; 1914 } 1915}; 1916</pre> 1917<p>Define the named parameters that will comprise the argument specification that 1918this macro will use. Ensure that all their tag types are in the same 1919namespace, which is <tt class="docutils literal">kw</tt> in this case. The identifiers with leading 1920underscores can be passed to the bracket operator of <tt class="docutils literal">args</tt> to extract the 1921same argument to which the corresponding named parameter (without underscores) 1922is bound, as will be shown later.</p> 1923<pre class="literal-block"> 1924<a class="reference internal" href="#boost-parameter-name"><tt class="docutils literal">BOOST_PARAMETER_NAME</tt></a>((_lrc, kw) in(lrc)) 1925<a class="reference internal" href="#boost-parameter-name"><tt class="docutils literal">BOOST_PARAMETER_NAME</tt></a>((_lr, kw) in_out(lr)) 1926<a class="reference internal" href="#boost-parameter-name"><tt class="docutils literal">BOOST_PARAMETER_NAME</tt></a>((_rrc, kw) in(rrc)) 1927<a class="reference internal" href="#boost-parameter-name"><tt class="docutils literal">BOOST_PARAMETER_NAME</tt></a>((_rr, kw) consume(rr)) 1928</pre> 1929<p>Use the macro as a substitute for a normal <tt class="docutils literal">static</tt> member function 1930header. Enclose the return type <tt class="docutils literal">bool</tt> in parentheses. For each parameter, 1931also enclose the expected value type in parentheses. Since the value types 1932are mutually exclusive, you can wrap the parameters in a <tt class="docutils literal">(deduced …)</tt> 1933clause. Otherwise, just as with a normal function, the order in which you 1934specify the parameters determines their position. Also, just as with a normal 1935function, optional parameters have default values, whereas required parameters 1936do not. Within the function body, either simply use the parameter name or 1937pass the matching identifier with the leading underscore to the bracket 1938operator of <tt class="docutils literal">args</tt> to extract the corresponding argument. Note that the 1939second method doesn't require <tt class="docutils literal"><span class="pre">std::forward</span></tt> to preserve value categories.</p> 1940<pre class="literal-block"> 1941struct B 1942{ 1943 BOOST_PARAMETER_MEMBER_FUNCTION((bool), static evaluate, kw, 1944 (deduced 1945 (required 1946 (lrc, (<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><1>)) 1947 (lr, (<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><2>)) 1948 ) 1949 (optional 1950 (rrc, (<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><3>), rvalue_const_bitset<2>()) 1951 (rr, (<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><4>), rvalue_bitset<3>()) 1952 ) 1953 ) 1954 ) 1955 { 1956 BOOST_TEST_EQ( 1957 passed_by_lvalue_reference_to_const 1958 , U::evaluate_category<0>(lrc) 1959 ); 1960 BOOST_TEST_EQ( 1961 passed_by_lvalue_reference 1962 , U::evaluate_category<1>(lr) 1963 ); 1964 BOOST_TEST_EQ( 1965 passed_by_rvalue_reference_to_const 1966 , U::evaluate_category<2>(<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/forward">std::forward</a><rrc0_type>(rrc0)) 1967 ); 1968 BOOST_TEST_EQ( 1969 passed_by_rvalue_reference 1970 , U::evaluate_category<3>(args[_rr0]) 1971 ); 1972 1973 return true; 1974 } 1975}; 1976</pre> 1977<p>The following function calls are legal.</p> 1978<pre class="literal-block"> 1979B::evaluate( // positional arguments 1980 lvalue_const_bitset<0>() 1981 , lvalue_bitset<1>() 1982 , rvalue_const_bitset<2>() 1983 , rvalue_bitset<3>() 1984); 1985B::evaluate( // positional arguments 1986 lvalue_const_bitset<0>() 1987 , lvalue_bitset<1>() 1988); 1989B::evaluate(( // composed arguments 1990 _rr0 = rvalue_bitset<3>() 1991 , _lrc0 = lvalue_const_bitset<0>() 1992 , _lr0 = lvalue_bitset<1>() 1993 , _rrc0 = rvalue_const_bitset<2>() 1994)); 1995B::evaluate( // named arguments 1996 _rr0 = rvalue_bitset<3>() 1997 , _lrc0 = lvalue_const_bitset<0>() 1998 , _lr0 = lvalue_bitset<1>() 1999 , _rrc0 = rvalue_const_bitset<2>() 2000); 2001B::evaluate( // named arguments 2002 _lr0 = lvalue_bitset<1>() 2003 , _lrc0 = lvalue_const_bitset<0>() 2004); 2005</pre> 2006<p>Because the parameters were wrapped in a <tt class="docutils literal">(deduced …)</tt> clause, the following 2007function calls are also legal.</p> 2008<pre class="literal-block"> 2009B::evaluate( // deduced arguments 2010 rvalue_bitset<3>() 2011 , lvalue_const_bitset<0>() 2012 , lvalue_bitset<1>() 2013 , rvalue_const_bitset<2>() 2014); 2015B::evaluate( // deduced arguments 2016 lvalue_bitset<1>() 2017 , lvalue_const_bitset<0>() 2018); 2019</pre> 2020<p>The <a class="reference external" href="../../test/preprocessor.cpp">preprocessor.cpp</a> and <a class="reference external" href="../../test/preprocessor_eval_category.cpp">preprocessor_eval_category.cpp</a> test programs 2021demonstrate proper usage of this macro.</p> 2022<p><strong>Macro parameters:</strong></p> 2023<ul class="simple"> 2024<li><tt class="docutils literal">result</tt> is the parenthesized return type of the function.</li> 2025<li><tt class="docutils literal">name</tt> is the base name of the function; it determines the name of the 2026generated forwarding functions. <tt class="docutils literal">name</tt> may be qualified by the 2027<tt class="docutils literal">static</tt> keyword to declare the member function and its helpers as not 2028associated with any object of the enclosing type.</li> 2029<li><tt class="docutils literal">tag_namespace</tt> is the namespace in which the keywords used by the 2030function resides.</li> 2031<li><tt class="docutils literal">arguments</tt> is a <a class="reference external" href="../../../preprocessor/doc/index.html">Boost.Preprocessor</a> <a class="reference external" href="../../../preprocessor/doc/data/sequences.html">sequence</a> of 2032<em>argument-specifiers</em>, as defined below.</li> 2033</ul> 2034<p><strong>Argument specifiers syntax:</strong></p> 2035<pre class="literal-block"> 2036argument-specifiers ::= <em>specifier-group0</em> {<em>specifier-group0</em>} 2037 2038specifier-group0 ::= <em>specifier-group1</em> | 2039 ( 2040 '<strong>(</strong>' '<strong>deduced</strong>' 2041 <em>specifier-group1</em> {<em>specifier-group1</em>} 2042 '<strong>)</strong>' 2043 ) 2044 2045specifier-group1 ::= 2046 ( 2047 '<strong>(</strong>' '<strong>optional</strong>' 2048 <em>optional-specifier</em> {<em>optional-specifier</em>} 2049 '<strong>)</strong>' 2050 ) | ( 2051 '<strong>(</strong>' '<strong>required</strong>' 2052 <em>required-specifier</em> {<em>required-specifier</em>} 2053 '<strong>)</strong>' 2054 ) 2055 2056optional-specifier ::= 2057 '<strong>(</strong>' 2058 <em>argument-name</em> '<strong>,</strong>' <em>restriction</em> '<strong>,</strong>' <em>default-value</em> 2059 ')' 2060 2061required-specifier ::= 2062 '<strong>(</strong>' <em>argument-name</em> '<strong>,</strong>' <em>restriction</em> ')' 2063 2064restriction ::= 2065 ( '<strong>*</strong>' '<strong>(</strong>' <em>mfc</em> '<strong>)</strong>' ) | 2066 ( '<strong>(</strong>' <em>type-name</em> '<strong>)</strong>' ) | 2067 '<strong>*</strong>' 2068</pre> 2069<ul class="simple"> 2070<li><tt class="docutils literal"><span class="pre">argument-name</span></tt> is any valid C++ identifier.</li> 2071<li><tt class="docutils literal"><span class="pre">default-value</span></tt> is any valid C++ expression; if necessary, user code can 2072compute it in terms of <tt class="docutils literal"><span class="pre">previous-name</span> ## _type</tt>, where <tt class="docutils literal"><span class="pre">previous-name</span></tt> 2073is the <tt class="docutils literal"><span class="pre">argument-name</span></tt> in a previous <tt class="docutils literal"><span class="pre">specifier-group0</span></tt> or 2074<tt class="docutils literal"><span class="pre">specifier-group1</span></tt>. <em>This expression will be invoked exactly once.</em></li> 2075<li><tt class="docutils literal">mfc</tt> is an <a class="reference external" href="../../../mpl/doc/refmanual/metafunction-class.html">MPL Binary Metafunction Class</a> whose first argument will 2076be the type of the corresponding <tt class="docutils literal"><span class="pre">argument-name</span></tt>, whose second argument 2077will be the entire <a class="reference internal" href="#argumentpack"><span class="concept">ArgumentPack</span></a>, and whose return type is a <a class="reference external" href="../../../mpl/doc/refmanual/integral-constant.html">Boolean 2078Integral Constant</a>; however, user code <em>cannot</em> compute <tt class="docutils literal">mfc</tt> in terms 2079of <tt class="docutils literal"><span class="pre">previous-name</span> ## _type</tt>.</li> 2080<li><tt class="docutils literal"><span class="pre">type-name</span></tt> is either the name of a <strong>target type</strong> or an <a class="reference external" href="../../../mpl/doc/refmanual/metafunction-class.html">MPL Binary 2081Metafunction Class</a> whose first argument will be the type of the 2082corresponding <tt class="docutils literal"><span class="pre">argument-name</span></tt>, whose second argument will be the entire 2083<a class="reference internal" href="#argumentpack"><span class="concept">ArgumentPack</span></a>, and whose return type is the <strong>target type</strong>. If 2084<tt class="docutils literal">restriction</tt> uses this form, then the type of the generated name 2085<tt class="docutils literal"><span class="pre">argument-name</span> ## _type</tt> will be computed in terms of the <strong>target 2086type</strong>, and the generated reference <tt class="docutils literal"><span class="pre">argument-name</span></tt> (but not its 2087corresponding entry in <tt class="docutils literal">args</tt>) will be cast to that type.</li> 2088</ul> 2089<p><strong>Approximate expansion:</strong></p> 2090<p>Where:</p> 2091<ul class="simple"> 2092<li><tt class="docutils literal">n</tt> denotes the <em>minimum</em> arity, as determined from <tt class="docutils literal">arguments</tt>.</li> 2093<li><tt class="docutils literal">m</tt> denotes the <em>maximum</em> arity, as determined from <tt class="docutils literal">arguments</tt>.</li> 2094</ul> 2095<pre class="literal-block"> 2096// If <strong>result</strong> is a template instantiation of <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::enable_if</a>, 2097// <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::enable_if_c</a>, <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::lazy_enable_if</a>, 2098// <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::lazy_enable_if_c</a>, <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::disable_if</a>, <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::disable_if_c</a>, 2099// <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::lazy_disable_if</a>, <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::lazy_disable_if_c</a>, or 2100// <a class="reference external" href="http://en.cppreference.com/w/cpp/types/enable_if">std::enable_if</a>: 2101template <typename Args> 2102using boost_param_result_ ## __LINE__ ## <strong>name</strong> = <strong>result</strong>; 2103 2104// If <strong>result</strong> is a simple return type: 2105template <typename Args> 2106struct boost_param_result_ ## __LINE__ ## <strong>name</strong> 2107{ 2108 typedef <strong>result</strong> type; 2109}; 2110 2111struct boost_param_params_ ## __LINE__ ## <strong>name</strong> 2112 : <a class="reference internal" href="#parameters"><tt class="docutils literal">parameters</tt></a>< 2113 <em>list of parameter specifications, based on arguments</em> 2114 > 2115{ 2116}; 2117 2118typedef boost_param_params_ ## __LINE__ ## <strong>name</strong> 2119 boost_param_parameters_ ## __LINE__ ## <strong>name</strong>; 2120 2121template <typename A0, …, typename A ## <strong>n</strong>> 2122<strong>result</strong> <strong>name</strong>( 2123 A0&& a0, …, A ## <strong>n</strong>&& a ## <strong>n</strong> 2124 , typename boost_param_parameters_ ## __LINE__ ## <strong>name</strong> 2125 ::match<A0, …, A ## <strong>n</strong>>::type 2126 = boost_param_parameters_ ## __LINE__ ## <strong>name</strong>() 2127) 2128{ 2129 return this->boost_param_impl ## __LINE__ ## <strong>name</strong>( 2130 boost_param_parameters_ ## __LINE__ ## <strong>name</strong>()( 2131 <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/forward">std::forward</a><A0>(a0) 2132 , … 2133 , <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/forward">std::forward</a><A ## <strong>n</strong>>(a ## <strong>n</strong>) 2134 ) 2135 ); 2136} 2137 2138<span class="vellipsis">⋮</span> 2139 2140template <typename A0, …, typename A ## <strong>m</strong>> 2141<strong>result</strong> <strong>name</strong>( 2142 A0&& a0, …, A ## <strong>m</strong>&& a ## <strong>m</strong> 2143 , typename boost_param_parameters_ ## __LINE__ ## <strong>name</strong> 2144 ::match<A0, …, A ## <strong>m</strong>>::type 2145 = boost_param_parameters_ ## __LINE__ ## <strong>name</strong>() 2146) 2147{ 2148 return this->boost_param_impl ## __LINE__ ## <strong>name</strong>( 2149 boost_param_parameters_ ## __LINE__ ## <strong>name</strong>()( 2150 <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/forward">std::forward</a><A0>(a0) 2151 , … 2152 , <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/forward">std::forward</a><A ## <strong>m</strong>>(a ## <strong>m</strong>) 2153 ) 2154 ); 2155} 2156 2157template <typename Args> 2158typename boost_param_result_ ## __LINE__ ## <strong>name</strong><Args>::type 2159 boost_param_impl ## __LINE__ ## <strong>name</strong>(Args const& args) 2160{ 2161 return this->boost_param_dispatch_0boost_ ## __LINE__ ## <strong>name</strong>( 2162 static_cast< 2163 typename boost_param_result_ ## __LINE__ ## <strong>name</strong>< 2164 Args 2165 >::type(*)() 2166 >(<a class="reference external" href="http://en.cppreference.com/w/cpp/language/nullptr">std::nullptr</a>) 2167 , args 2168 , <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/forward">std::forward</a>< 2169 typename <a class="reference internal" href="#value-type"><tt class="docutils literal">value_type</tt></a>< 2170 Args 2171 , <em>keyword tag type of required parameter</em> ## <strong>0</strong> 2172 >::type 2173 >(args[ <em>keyword object of required parameter</em> ## <strong>0</strong>]) 2174 , … 2175 , <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/forward">std::forward</a>< 2176 typename <a class="reference internal" href="#value-type"><tt class="docutils literal">value_type</tt></a>< 2177 Args 2178 , <em>keyword tag type of required parameter</em> ## <strong>n</strong> 2179 >::type 2180 >(args[ <em>keyword object of required parameter</em> ## <strong>n</strong>]) 2181 ); 2182} 2183 2184template < 2185 typename ResultType 2186 , typename Args 2187 , typename <em>argument name</em> ## <strong>0</strong> ## _type 2188 , … 2189 , typename <em>argument name</em> ## <strong>n</strong> ## _type 2190> 2191ResultType 2192 boost_param_dispatch_0boost_ ## __LINE__ ## <strong>name</strong>( 2193 (ResultType(*)()) 2194 , Args const& args 2195 , <em>argument name</em> ## <strong>0</strong> ## _type&& <em>argument name</em> ## <strong>0</strong> 2196 , … 2197 , <em>argument name</em> ## <strong>n</strong> ## _type&& <em>argument name</em> ## <strong>n</strong> 2198 ) 2199{ 2200 return this->boost_param_dispatch_0boost_ ## __LINE__ ## <strong>name</strong>( 2201 static_cast<ResultType(*)()>(<a class="reference external" href="http://en.cppreference.com/w/cpp/language/nullptr">std::nullptr</a>) 2202 , (args, <em>keyword object of optional parameter</em> ## <strong>n + 1</strong> = 2203 <em>default value of optional parameter</em> ## <strong>n + 1</strong> 2204 ) 2205 , <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/forward">std::forward</a><<em>argument name</em> ## <strong>0</strong> ## _type>( 2206 <em>argument name</em> ## <strong>0</strong> 2207 ) 2208 , … 2209 , <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/forward">std::forward</a><<em>argument name</em> ## <strong>n</strong> ## _type>( 2210 <em>argument name</em> ## <strong>n</strong> 2211 ) 2212 , <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/forward">std::forward</a>< 2213 typename <a class="reference internal" href="#value-type"><tt class="docutils literal">value_type</tt></a>< 2214 Args 2215 , <em>keyword tag type of optional parameter</em> ## <strong>n + 1</strong> 2216 >::type 2217 >(<em>default value of optional parameter</em> ## <strong>n + 1</strong>) 2218 ); 2219} 2220 2221<span class="vellipsis">⋮</span> 2222 2223template < 2224 typename ResultType 2225 , typename Args 2226 , typename <em>argument name</em> ## <strong>0</strong> ## _type 2227 , … 2228 , typename <em>argument name</em> ## <strong>m</strong> ## _type 2229> 2230ResultType 2231 boost_param_dispatch_0boost_ ## __LINE__ ## <strong>name</strong>( 2232 (ResultType(*)()) 2233 , Args const& args 2234 , <em>argument name</em> ## <strong>0</strong> ## _type&& <em>argument name</em> ## <strong>0</strong> 2235 , … 2236 , <em>argument name</em> ## <strong>m</strong> ## _type&& <em>argument name</em> ## <strong>m</strong> 2237 ) 2238</pre> 2239</div> 2240<div class="section" id="boost-parameter-const-member-function-result-name-tag-ns-arguments"> 2241<span id="boost-parameter-const-member-function"></span><h2><a class="toc-backref" href="#id59">7.3 <tt class="docutils literal">BOOST_PARAMETER_CONST_MEMBER_FUNCTION(result, name, tag_ns, arguments)</tt></a></h2> 2242<table class="docutils field-list" frame="void" rules="none"> 2243<col class="field-name" /> 2244<col class="field-body" /> 2245<tbody valign="top"> 2246<tr class="field"><th class="field-name">Defined in:</th><td class="field-body"><a class="reference external" href="../../../../boost/parameter/preprocessor.hpp">boost/parameter/preprocessor.hpp</a></td> 2247</tr> 2248</tbody> 2249</table> 2250<p>Generates a member function that can take in positional arguments, composed 2251arguments, named arguments, and deduced arguments.</p> 2252<table class="docutils field-list" frame="void" rules="none"> 2253<col class="field-name" /> 2254<col class="field-body" /> 2255<tbody valign="top"> 2256<tr class="field"><th class="field-name">Example usage:</th><td class="field-body"></td> 2257</tr> 2258</tbody> 2259</table> 2260<p>The return type of each of the following function templates falls under a 2261different value category.</p> 2262<pre class="literal-block"> 2263template <std::size_t N> 2264<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1> rvalue_bitset() 2265{ 2266 return <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1>(); 2267} 2268 2269template <std::size_t N> 2270<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1> const rvalue_const_bitset() 2271{ 2272 return <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1>(); 2273} 2274 2275template <std::size_t N> 2276<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1>& lvalue_bitset() 2277{ 2278 static <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1> lset = <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1>(); 2279 return lset; 2280} 2281 2282template <std::size_t N> 2283<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1> const& lvalue_const_bitset() 2284{ 2285 static <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1> const clset = <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1>(); 2286 return clset; 2287} 2288</pre> 2289<p>The <tt class="docutils literal"><span class="pre">U::evaluate_category</span></tt> static member function template has a simple job: 2290to return the correct value category when passed in an object returned by one 2291of the functions defined above. Assume that 2292<a class="reference internal" href="#boost-parameter-has-perfect-forwarding"><tt class="docutils literal">BOOST_PARAMETER_HAS_PERFECT_FORWARDING</tt></a> is defined.</p> 2293<pre class="literal-block"> 2294enum invoked 2295{ 2296 passed_by_lvalue_reference_to_const 2297 , passed_by_lvalue_reference 2298 , passed_by_rvalue_reference_to_const 2299 , passed_by_rvalue_reference 2300}; 2301 2302struct U 2303{ 2304 template <std::size_t N> 2305 static invoked evaluate_category(<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1> const&) 2306 { 2307 return passed_by_lvalue_reference_to_const; 2308 } 2309 2310 template <std::size_t N> 2311 static invoked evaluate_category(<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1>&) 2312 { 2313 return passed_by_lvalue_reference; 2314 } 2315 2316 template <std::size_t N> 2317 static invoked evaluate_category(<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1> const&&) 2318 { 2319 return passed_by_rvalue_reference_to_const; 2320 } 2321 2322 template <std::size_t N> 2323 static invoked evaluate_category(<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1>&&) 2324 { 2325 return passed_by_rvalue_reference; 2326 } 2327}; 2328</pre> 2329<p>Define the named parameters that will comprise the argument specification that 2330this macro will use. Ensure that all their tag types are in the same 2331namespace, which is <tt class="docutils literal">kw</tt> in this case. The identifiers with leading 2332underscores can be passed to the bracket operator of <tt class="docutils literal">args</tt> to extract the 2333same argument to which the corresponding named parameter (without underscores) 2334is bound, as will be shown later.</p> 2335<pre class="literal-block"> 2336<a class="reference internal" href="#boost-parameter-name"><tt class="docutils literal">BOOST_PARAMETER_NAME</tt></a>((_lrc, kw) in(lrc)) 2337<a class="reference internal" href="#boost-parameter-name"><tt class="docutils literal">BOOST_PARAMETER_NAME</tt></a>((_lr, kw) in_out(lr)) 2338<a class="reference internal" href="#boost-parameter-name"><tt class="docutils literal">BOOST_PARAMETER_NAME</tt></a>((_rrc, kw) in(rrc)) 2339<a class="reference internal" href="#boost-parameter-name"><tt class="docutils literal">BOOST_PARAMETER_NAME</tt></a>((_rr, kw) consume(rr)) 2340</pre> 2341<p>Use the macro as a substitute for a normal <tt class="docutils literal">const</tt> member function 2342header. Enclose the return type <tt class="docutils literal">bool</tt> in parentheses. For each parameter, 2343also enclose the expected value type in parentheses. Since the value types 2344are mutually exclusive, you can wrap the parameters in a <tt class="docutils literal">(deduced …)</tt> 2345clause. Otherwise, just as with a normal function, the order in which you 2346specify the parameters determines their position. Also, just as with a normal 2347function, optional parameters have default values, whereas required parameters 2348do not. Within the function body, either simply use the parameter name or 2349pass the matching identifier with the leading underscore to the bracket 2350operator of <tt class="docutils literal">args</tt> to extract the corresponding argument. Note that the 2351second method doesn't require <tt class="docutils literal"><span class="pre">std::forward</span></tt> to preserve value categories.</p> 2352<pre class="literal-block"> 2353struct B 2354{ 2355 B() 2356 { 2357 } 2358 2359 BOOST_PARAMETER_CONST_MEMBER_FUNCTION((bool), evaluate, kw, 2360 (deduced 2361 (required 2362 (lrc, (<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><1>)) 2363 (lr, (<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><2>)) 2364 ) 2365 (optional 2366 (rrc, (<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><3>), rvalue_const_bitset<2>()) 2367 (rr, (<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><4>), rvalue_bitset<3>()) 2368 ) 2369 ) 2370 ) 2371 { 2372 BOOST_TEST_EQ( 2373 passed_by_lvalue_reference_to_const 2374 , U::evaluate_category<0>(lrc) 2375 ); 2376 BOOST_TEST_EQ( 2377 passed_by_lvalue_reference 2378 , U::evaluate_category<1>(lr) 2379 ); 2380 BOOST_TEST_EQ( 2381 passed_by_rvalue_reference_to_const 2382 , U::evaluate_category<2>(<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/forward">std::forward</a><rrc0_type>(rrc0)) 2383 ); 2384 BOOST_TEST_EQ( 2385 passed_by_rvalue_reference 2386 , U::evaluate_category<3>(args[_rr0]) 2387 ); 2388 2389 return true; 2390 } 2391}; 2392</pre> 2393<p>The following function calls are legal.</p> 2394<pre class="literal-block"> 2395B const b = B(); 2396b.evaluate( // positional arguments 2397 lvalue_const_bitset<0>() 2398 , lvalue_bitset<1>() 2399 , rvalue_const_bitset<2>() 2400 , rvalue_bitset<3>() 2401); 2402b.evaluate( // positional arguments 2403 lvalue_const_bitset<0>() 2404 , lvalue_bitset<1>() 2405); 2406b.evaluate(( // composed arguments 2407 _rr0 = rvalue_bitset<3>() 2408 , _lrc0 = lvalue_const_bitset<0>() 2409 , _lr0 = lvalue_bitset<1>() 2410 , _rrc0 = rvalue_const_bitset<2>() 2411)); 2412b.evaluate( // named arguments 2413 _rr0 = rvalue_bitset<3>() 2414 , _lrc0 = lvalue_const_bitset<0>() 2415 , _lr0 = lvalue_bitset<1>() 2416 , _rrc0 = rvalue_const_bitset<2>() 2417); 2418b.evaluate( // named arguments 2419 _lr0 = lvalue_bitset<1>() 2420 , _lrc0 = lvalue_const_bitset<0>() 2421); 2422</pre> 2423<p>Because the parameters were wrapped in a <tt class="docutils literal">(deduced …)</tt> clause, the following 2424function calls are also legal.</p> 2425<pre class="literal-block"> 2426b.evaluate( // deduced arguments 2427 rvalue_bitset<3>() 2428 , lvalue_const_bitset<0>() 2429 , lvalue_bitset<1>() 2430 , rvalue_const_bitset<2>() 2431); 2432b.evaluate( // deduced arguments 2433 lvalue_bitset<1>() 2434 , lvalue_const_bitset<0>() 2435); 2436</pre> 2437<p>The <a class="reference external" href="../../test/preprocessor.cpp">preprocessor.cpp</a> test program demonstrates proper usage of this macro.</p> 2438<p><strong>Macro parameters:</strong></p> 2439<ul class="simple"> 2440<li><tt class="docutils literal">result</tt> is the parenthesized return type of the function.</li> 2441<li><tt class="docutils literal">name</tt> is the base name of the function; it determines the name of the 2442generated forwarding functions.</li> 2443<li><tt class="docutils literal">tag_namespace</tt> is the namespace in which the keywords used by the 2444function resides.</li> 2445<li><tt class="docutils literal">arguments</tt> is a <a class="reference external" href="../../../preprocessor/doc/index.html">Boost.Preprocessor</a> <a class="reference external" href="../../../preprocessor/doc/data/sequences.html">sequence</a> of 2446<em>argument-specifiers</em>, as defined below.</li> 2447</ul> 2448<p><strong>Argument specifiers syntax:</strong></p> 2449<pre class="literal-block"> 2450argument-specifiers ::= <em>specifier-group0</em> {<em>specifier-group0</em>} 2451 2452specifier-group0 ::= <em>specifier-group1</em> | 2453 ( 2454 '<strong>(</strong>' '<strong>deduced</strong>' 2455 <em>specifier-group1</em> {<em>specifier-group1</em>} 2456 '<strong>)</strong>' 2457 ) 2458 2459specifier-group1 ::= 2460 ( 2461 '<strong>(</strong>' '<strong>optional</strong>' 2462 <em>optional-specifier</em> {<em>optional-specifier</em>} 2463 '<strong>)</strong>' 2464 ) | ( 2465 '<strong>(</strong>' '<strong>required</strong>' 2466 <em>required-specifier</em> {<em>required-specifier</em>} 2467 '<strong>)</strong>' 2468 ) 2469 2470optional-specifier ::= 2471 '<strong>(</strong>' 2472 <em>argument-name</em> '<strong>,</strong>' <em>restriction</em> '<strong>,</strong>' <em>default-value</em> 2473 ')' 2474 2475required-specifier ::= 2476 '<strong>(</strong>' <em>argument-name</em> '<strong>,</strong>' <em>restriction</em> ')' 2477 2478restriction ::= 2479 ( '<strong>*</strong>' '<strong>(</strong>' <em>mfc</em> '<strong>)</strong>' ) | 2480 ( '<strong>(</strong>' <em>type-name</em> '<strong>)</strong>' ) | 2481 '<strong>*</strong>' 2482</pre> 2483<ul class="simple"> 2484<li><tt class="docutils literal"><span class="pre">argument-name</span></tt> is any valid C++ identifier.</li> 2485<li><tt class="docutils literal"><span class="pre">default-value</span></tt> is any valid C++ expression; if necessary, user code can 2486compute it in terms of <tt class="docutils literal"><span class="pre">previous-name</span> ## _type</tt>, where <tt class="docutils literal"><span class="pre">previous-name</span></tt> 2487is the <tt class="docutils literal"><span class="pre">argument-name</span></tt> in a previous <tt class="docutils literal"><span class="pre">specifier-group0</span></tt> or 2488<tt class="docutils literal"><span class="pre">specifier-group1</span></tt>. <em>This expression will be invoked exactly once.</em></li> 2489<li><tt class="docutils literal">mfc</tt> is an <a class="reference external" href="../../../mpl/doc/refmanual/metafunction-class.html">MPL Binary Metafunction Class</a> whose first argument will 2490be the type of the corresponding <tt class="docutils literal"><span class="pre">argument-name</span></tt>, whose second argument 2491will be the entire <a class="reference internal" href="#argumentpack"><span class="concept">ArgumentPack</span></a>, and whose return type is a <a class="reference external" href="../../../mpl/doc/refmanual/integral-constant.html">Boolean 2492Integral Constant</a>; however, user code <em>cannot</em> compute <tt class="docutils literal">mfc</tt> in terms 2493of <tt class="docutils literal"><span class="pre">previous-name</span> ## _type</tt>.</li> 2494<li><tt class="docutils literal"><span class="pre">type-name</span></tt> is either the name of a <strong>target type</strong> or an <a class="reference external" href="../../../mpl/doc/refmanual/metafunction-class.html">MPL Binary 2495Metafunction Class</a> whose first argument will be the type of the 2496corresponding <tt class="docutils literal"><span class="pre">argument-name</span></tt>, whose second argument will be the entire 2497<a class="reference internal" href="#argumentpack"><span class="concept">ArgumentPack</span></a>, and whose return type is the <strong>target type</strong>. If 2498<tt class="docutils literal">restriction</tt> uses this form, then the type of the generated name 2499<tt class="docutils literal"><span class="pre">argument-name</span> ## _type</tt> will be computed in terms of the <strong>target 2500type</strong>, and the generated reference <tt class="docutils literal"><span class="pre">argument-name</span></tt> (but not its 2501corresponding entry in <tt class="docutils literal">args</tt>) will be cast to that type.</li> 2502</ul> 2503<p><strong>Approximate expansion:</strong></p> 2504<p>Where:</p> 2505<ul class="simple"> 2506<li><tt class="docutils literal">n</tt> denotes the <em>minimum</em> arity, as determined from <tt class="docutils literal">arguments</tt>.</li> 2507<li><tt class="docutils literal">m</tt> denotes the <em>maximum</em> arity, as determined from <tt class="docutils literal">arguments</tt>.</li> 2508</ul> 2509<pre class="literal-block"> 2510// If <strong>result</strong> is a template instantiation of <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::enable_if</a>, 2511// <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::enable_if_c</a>, <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::lazy_enable_if</a>, 2512// <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::lazy_enable_if_c</a>, <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::disable_if</a>, <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::disable_if_c</a>, 2513// <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::lazy_disable_if</a>, <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::lazy_disable_if_c</a>, or 2514// <a class="reference external" href="http://en.cppreference.com/w/cpp/types/enable_if">std::enable_if</a>: 2515template <typename Args> 2516using boost_param_result_const_ ## __LINE__ ## <strong>name</strong> = <strong>result</strong>; 2517 2518// If <strong>result</strong> is a simple return type: 2519template <typename Args> 2520struct boost_param_result_const_ ## __LINE__ ## <strong>name</strong> 2521{ 2522 typedef <strong>result</strong> type; 2523}; 2524 2525struct boost_param_params_const_ ## __LINE__ ## <strong>name</strong> 2526 : <a class="reference internal" href="#parameters"><tt class="docutils literal">parameters</tt></a>< 2527 <em>list of parameter specifications, based on arguments</em> 2528 > 2529{ 2530}; 2531 2532typedef boost_param_params_const_ ## __LINE__ ## <strong>name</strong> 2533 boost_param_parameters_const_ ## __LINE__ ## <strong>name</strong>; 2534 2535template <typename A0, …, typename A ## <strong>n</strong>> 2536<strong>result</strong> <strong>name</strong>( 2537 A0&& a0, …, A ## <strong>n</strong>&& a ## <strong>n</strong> 2538 , typename boost_param_parameters_const_ ## __LINE__ ## <strong>name</strong> 2539 ::match<A0, …, A ## <strong>n</strong>>::type 2540 = boost_param_parameters_const_ ## __LINE__ ## <strong>name</strong>() 2541) const 2542{ 2543 return this->boost_param_impl_const ## __LINE__ ## <strong>name</strong>( 2544 boost_param_parameters_const_ ## __LINE__ ## <strong>name</strong>( 2545 <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/forward">std::forward</a><A0>(a0) 2546 , … 2547 , <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/forward">std::forward</a><A ## <strong>n</strong>>(a ## <strong>n</strong>) 2548 ) 2549 ); 2550} 2551 2552<span class="vellipsis">⋮</span> 2553 2554template <typename A0, …, typename A ## <strong>m</strong>> 2555<strong>result</strong> <strong>name</strong>( 2556 A0&& a0, …, A ## <strong>m</strong>&& a ## <strong>m</strong> 2557 , typename boost_param_parameters_const_ ## __LINE__ ## <strong>name</strong> 2558 ::match<A0, …, A ## <strong>m</strong>>::type 2559 = boost_param_parameters_const_ ## __LINE__ ## <strong>name</strong>() 2560) const 2561{ 2562 return this->boost_param_impl_const ## __LINE__ ## <strong>name</strong>( 2563 boost_param_parameters_const_ ## __LINE__ ## <strong>name</strong>()( 2564 <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/forward">std::forward</a><A0>(a0) 2565 , … 2566 , <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/forward">std::forward</a><A ## <strong>m</strong>>(a ## <strong>m</strong>) 2567 ) 2568 ); 2569} 2570 2571template <typename Args> 2572typename boost_param_result_const_ ## __LINE__ ## <strong>name</strong><Args>::type 2573 boost_param_impl_const ## __LINE__ ## <strong>name</strong>(Args const& args) const 2574{ 2575 return this-> 2576 boost_param_dispatch_const_0boost_ ## __LINE__ ## <strong>name</strong>( 2577 static_cast< 2578 typename boost_param_result_const_ ## __LINE__ ## <strong>name</strong>< 2579 Args 2580 >::type(*)() 2581 >(<a class="reference external" href="http://en.cppreference.com/w/cpp/language/nullptr">std::nullptr</a>) 2582 , args 2583 , <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/forward">std::forward</a>< 2584 typename <a class="reference internal" href="#value-type"><tt class="docutils literal">value_type</tt></a>< 2585 Args 2586 , <em>keyword tag type of required parameter</em> ## <strong>0</strong> 2587 >::type 2588 >(args[ <em>keyword object of required parameter</em> ## <strong>0</strong>]) 2589 , … 2590 , <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/forward">std::forward</a>< 2591 typename <a class="reference internal" href="#value-type"><tt class="docutils literal">value_type</tt></a>< 2592 Args 2593 , <em>keyword tag type of required parameter</em> ## <strong>n</strong> 2594 >::type 2595 >(args[ <em>keyword object of required parameter</em> ## <strong>n</strong>]) 2596 ); 2597} 2598 2599template < 2600 typename ResultType 2601 , typename Args 2602 , typename <em>argument name</em> ## <strong>0</strong> ## _type 2603 , … 2604 , typename <em>argument name</em> ## <strong>n</strong> ## _type 2605> 2606ResultType 2607 boost_param_dispatch_const_0boost_ ## __LINE__ ## <strong>name</strong>( 2608 (ResultType(*)()) 2609 , Args const& args 2610 , <em>argument name</em> ## <strong>0</strong> ## _type&& <em>argument name</em> ## <strong>0</strong> 2611 , … 2612 , <em>argument name</em> ## <strong>n</strong> ## _type&& <em>argument name</em> ## <strong>n</strong> 2613 ) const 2614{ 2615 return this-> 2616 boost_param_dispatch_const_0boost_ ## __LINE__ ## <strong>name</strong>( 2617 static_cast<ResultType(*)()>(<a class="reference external" href="http://en.cppreference.com/w/cpp/language/nullptr">std::nullptr</a>) 2618 , (args, <em>keyword object of optional parameter</em> ## <strong>n + 1</strong> = 2619 <em>default value of optional parameter</em> ## <strong>n + 1</strong> 2620 ) 2621 , <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/forward">std::forward</a><<em>argument name</em> ## <strong>0</strong> ## _type>( 2622 <em>argument name</em> ## <strong>0</strong> 2623 ) 2624 , … 2625 , <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/forward">std::forward</a><<em>argument name</em> ## <strong>n</strong> ## _type>( 2626 <em>argument name</em> ## <strong>n</strong> 2627 ) 2628 , <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/forward">std::forward</a>< 2629 typename <a class="reference internal" href="#value-type"><tt class="docutils literal">value_type</tt></a>< 2630 Args 2631 , <em>keyword tag type of optional parameter</em> ## <strong>n + 1</strong> 2632 >::type 2633 >(<em>default value of optional parameter</em> ## <strong>n + 1</strong>) 2634 ); 2635} 2636 2637<span class="vellipsis">⋮</span> 2638 2639template < 2640 typename ResultType 2641 , typename Args 2642 , typename <em>argument name</em> ## <strong>0</strong> ## _type 2643 , … 2644 , typename <em>argument name</em> ## <strong>m</strong> ## _type 2645> 2646ResultType 2647 boost_param_dispatch_const_0boost_ ## __LINE__ ## <strong>name</strong>( 2648 (ResultType(*)()) 2649 , Args const& args 2650 , <em>argument name</em> ## <strong>0</strong> ## _type&& <em>argument name</em> ## <strong>0</strong> 2651 , … 2652 , <em>argument name</em> ## <strong>m</strong> ## _type&& <em>argument name</em> ## <strong>m</strong> 2653 ) const 2654</pre> 2655</div> 2656<div class="section" id="boost-parameter-function-call-operator-result-tag-namespace-arguments"> 2657<span id="boost-parameter-function-call-operator"></span><h2><a class="toc-backref" href="#id60">7.4 <tt class="docutils literal">BOOST_PARAMETER_FUNCTION_CALL_OPERATOR(result, tag_namespace, arguments)</tt></a></h2> 2658<table class="docutils field-list" frame="void" rules="none"> 2659<col class="field-name" /> 2660<col class="field-body" /> 2661<tbody valign="top"> 2662<tr class="field"><th class="field-name">Defined in:</th><td class="field-body"><a class="reference external" href="../../../../boost/parameter/preprocessor.hpp">boost/parameter/preprocessor.hpp</a></td> 2663</tr> 2664</tbody> 2665</table> 2666<p>Generates a function call operator that can take in positional arguments, 2667composed arguments, named arguments, and deduced arguments.</p> 2668<table class="docutils field-list" frame="void" rules="none"> 2669<col class="field-name" /> 2670<col class="field-body" /> 2671<tbody valign="top"> 2672<tr class="field"><th class="field-name">Example usage:</th><td class="field-body"></td> 2673</tr> 2674</tbody> 2675</table> 2676<p>Define the named parameters that will comprise the argument specification that 2677this macro will use. Ensure that all their tag types are in the same 2678namespace, which is <tt class="docutils literal">tag</tt> by default.</p> 2679<pre class="literal-block"> 2680<a class="reference internal" href="#boost-parameter-name"><tt class="docutils literal">BOOST_PARAMETER_NAME</tt></a>(y) 2681<a class="reference internal" href="#boost-parameter-name"><tt class="docutils literal">BOOST_PARAMETER_NAME</tt></a>(z) 2682</pre> 2683<p>Use the macro as a substitute for a normal function call operator 2684header. Enclose the return type in parentheses. For each parameter, also 2685enclose the expected value type in parentheses. Since the value types are 2686mutually exclusive, you can wrap the parameters in a <tt class="docutils literal">(deduced …)</tt> 2687clause. This is especially useful when implementing multiple 2688Boost.Parameter-enabled function call operator overloads.</p> 2689<pre class="literal-block"> 2690class char_reader 2691{ 2692 int index; 2693 char const* key; 2694 2695 public: 2696 explicit char_reader(char const* k) : index(0), key(k) 2697 { 2698 } 2699 2700 BOOST_PARAMETER_FUNCTION_CALL_OPERATOR((void), tag, 2701 (deduced 2702 (required 2703 (y, (int)) 2704 (z, (char const*)) 2705 ) 2706 ) 2707 ) 2708 { 2709 this->index = y; 2710 this->key = z; 2711 } 2712 2713 <a class="reference internal" href="#boost-parameter-const-function-call-operator"><tt class="docutils literal">BOOST_PARAMETER_CONST_FUNCTION_CALL_OPERATOR</tt></a>((char), tag, 2714 (deduced 2715 (required 2716 (y, (bool)) 2717 (z, (<a class="reference external" href="http://en.cppreference.com/w/cpp/container/map">std::map</a><char const*, <a class="reference external" href="http://en.cppreference.com/w/cpp/string/basic_string">std::string</a>>)) 2718 ) 2719 ) 2720 ) 2721 { 2722 return y ? ( 2723 (z.find(this->key)->second)[this->index] 2724 ) : this->key[this->index]; 2725 } 2726}; 2727</pre> 2728<p>As with regular argument-dependent lookup, the value types of the arguments 2729passed in determine which function call operator overload gets invoked.</p> 2730<pre class="literal-block"> 2731char const* keys[] = {"foo", "bar", "baz"}; 2732<a class="reference external" href="http://en.cppreference.com/w/cpp/container/map">std::map</a><char const*, <a class="reference external" href="http://en.cppreference.com/w/cpp/string/basic_string">std::string</a>> k2s; 2733k2s[keys[0]] = <a class="reference external" href="http://en.cppreference.com/w/cpp/string/basic_string">std::string</a>("qux"); 2734k2s[keys[1]] = <a class="reference external" href="http://en.cppreference.com/w/cpp/string/basic_string">std::string</a>("wmb"); 2735k2s[keys[2]] = <a class="reference external" href="http://en.cppreference.com/w/cpp/string/basic_string">std::string</a>("zxc"); 2736char_reader r(keys[0]); 2737 2738// positional arguments 2739BOOST_TEST_EQ('q', (r(true, k2s))); 2740BOOST_TEST_EQ('f', (r(false, k2s))); 2741 2742// named arguments 2743r(_z = keys[1], _y = 1); 2744BOOST_TEST_EQ('m', (r(_z = k2s, _y = true))); 2745BOOST_TEST_EQ('a', (r(_z = k2s, _y = false))); 2746 2747// deduced arguments 2748r(keys[2], 2); 2749BOOST_TEST_EQ('c', (r(k2s, true))); 2750BOOST_TEST_EQ('z', (r(k2s, false))); 2751</pre> 2752<p>The <a class="reference external" href="../../test/preprocessor.cpp">preprocessor.cpp</a> and <a class="reference external" href="../../test/preprocessor_deduced.cpp">preprocessor_deduced.cpp</a> test programs 2753demonstrate proper usage of this macro.</p> 2754<p><strong>Macro parameters:</strong></p> 2755<ul class="simple"> 2756<li><tt class="docutils literal">result</tt> is the parenthesized return type of the function call operator.</li> 2757<li><tt class="docutils literal">tag_namespace</tt> is the namespace in which the keywords used by the 2758function call operator resides.</li> 2759<li><tt class="docutils literal">arguments</tt> is a <a class="reference external" href="../../../preprocessor/doc/index.html">Boost.Preprocessor</a> <a class="reference external" href="../../../preprocessor/doc/data/sequences.html">sequence</a> of 2760<em>argument-specifiers</em>, as defined below.</li> 2761</ul> 2762<p><strong>Argument specifiers syntax:</strong></p> 2763<pre class="literal-block"> 2764argument-specifiers ::= <em>specifier-group0</em> {<em>specifier-group0</em>} 2765 2766specifier-group0 ::= <em>specifier-group1</em> | 2767 ( 2768 '<strong>(</strong>' '<strong>deduced</strong>' 2769 <em>specifier-group1</em> {<em>specifier-group1</em>} 2770 '<strong>)</strong>' 2771 ) 2772 2773specifier-group1 ::= 2774 ( 2775 '<strong>(</strong>' '<strong>optional</strong>' 2776 <em>optional-specifier</em> {<em>optional-specifier</em>} 2777 '<strong>)</strong>' 2778 ) | ( 2779 '<strong>(</strong>' '<strong>required</strong>' 2780 <em>required-specifier</em> {<em>required-specifier</em>} 2781 '<strong>)</strong>' 2782 ) 2783 2784optional-specifier ::= 2785 '<strong>(</strong>' 2786 <em>argument-name</em> '<strong>,</strong>' <em>restriction</em> '<strong>,</strong>' <em>default-value</em> 2787 ')' 2788 2789required-specifier ::= 2790 '<strong>(</strong>' <em>argument-name</em> '<strong>,</strong>' <em>restriction</em> ')' 2791 2792restriction ::= 2793 ( '<strong>*</strong>' '<strong>(</strong>' <em>mfc</em> '<strong>)</strong>' ) | 2794 ( '<strong>(</strong>' <em>type-name</em> '<strong>)</strong>' ) | 2795 '<strong>*</strong>' 2796</pre> 2797<ul class="simple"> 2798<li><tt class="docutils literal"><span class="pre">argument-name</span></tt> is any valid C++ identifier.</li> 2799<li><tt class="docutils literal"><span class="pre">default-value</span></tt> is any valid C++ expression; if necessary, user code can 2800compute it in terms of <tt class="docutils literal"><span class="pre">previous-name</span> ## _type</tt>, where <tt class="docutils literal"><span class="pre">previous-name</span></tt> 2801is the <tt class="docutils literal"><span class="pre">argument-name</span></tt> in a previous <tt class="docutils literal"><span class="pre">specifier-group0</span></tt> or 2802<tt class="docutils literal"><span class="pre">specifier-group1</span></tt>. <em>This expression will be invoked exactly once.</em></li> 2803<li><tt class="docutils literal">mfc</tt> is an <a class="reference external" href="../../../mpl/doc/refmanual/metafunction-class.html">MPL Binary Metafunction Class</a> whose first argument will 2804be the type of the corresponding <tt class="docutils literal"><span class="pre">argument-name</span></tt>, whose second argument 2805will be the entire <a class="reference internal" href="#argumentpack"><span class="concept">ArgumentPack</span></a>, and whose return type is a <a class="reference external" href="../../../mpl/doc/refmanual/integral-constant.html">Boolean 2806Integral Constant</a>; however, user code <em>cannot</em> compute <tt class="docutils literal">mfc</tt> in terms 2807of <tt class="docutils literal"><span class="pre">previous-name</span> ## _type</tt>.</li> 2808<li><tt class="docutils literal"><span class="pre">type-name</span></tt> is either the name of a <strong>target type</strong> or an <a class="reference external" href="../../../mpl/doc/refmanual/metafunction-class.html">MPL Binary 2809Metafunction Class</a> whose first argument will be the type of the 2810corresponding <tt class="docutils literal"><span class="pre">argument-name</span></tt>, whose second argument will be the entire 2811<a class="reference internal" href="#argumentpack"><span class="concept">ArgumentPack</span></a>, and whose return type is the <strong>target type</strong>. If 2812<tt class="docutils literal">restriction</tt> uses this form, then the type of the generated name 2813<tt class="docutils literal"><span class="pre">argument-name</span> ## _type</tt> will be computed in terms of the <strong>target 2814type</strong>, and the generated reference <tt class="docutils literal"><span class="pre">argument-name</span></tt> (but not its 2815corresponding entry in <tt class="docutils literal">args</tt>) will be cast to that type.</li> 2816</ul> 2817<p><strong>Approximate expansion:</strong></p> 2818<p>Where:</p> 2819<ul class="simple"> 2820<li><tt class="docutils literal">n</tt> denotes the <em>minimum</em> arity, as determined from <tt class="docutils literal">arguments</tt>.</li> 2821<li><tt class="docutils literal">m</tt> denotes the <em>maximum</em> arity, as determined from <tt class="docutils literal">arguments</tt>.</li> 2822</ul> 2823<pre class="literal-block"> 2824// If <strong>result</strong> is a template instantiation of <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::enable_if</a>, 2825// <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::enable_if_c</a>, <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::lazy_enable_if</a>, 2826// <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::lazy_enable_if_c</a>, <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::disable_if</a>, <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::disable_if_c</a>, 2827// <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::lazy_disable_if</a>, <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::lazy_disable_if_c</a>, or 2828// <a class="reference external" href="http://en.cppreference.com/w/cpp/types/enable_if">std::enable_if</a>: 2829template <typename Args> 2830using boost_param_result_ ## __LINE__ ## operator = <strong>result</strong>; 2831 2832// If <strong>result</strong> is a simple return type: 2833template <typename Args> 2834struct boost_param_result_ ## __LINE__ ## operator 2835{ 2836 typedef <strong>result</strong> type; 2837}; 2838 2839struct boost_param_params_ ## __LINE__ ## operator 2840 : <a class="reference internal" href="#parameters"><tt class="docutils literal">parameters</tt></a>< 2841 <em>list of parameter specifications, based on arguments</em> 2842 > 2843{ 2844}; 2845 2846typedef boost_param_params_ ## __LINE__ ## operator 2847 boost_param_parameters_ ## __LINE__ ## operator; 2848 2849template <typename A0, …, typename A ## <strong>n</strong>> 2850<strong>result</strong> operator()( 2851 A0&& a0, …, A ## <strong>n</strong>&& a ## <strong>n</strong> 2852 , typename boost_param_parameters_ ## __LINE__ ## operator::match< 2853 A0, …, A ## <strong>n</strong> 2854 >::type = boost_param_parameters_ ## __LINE__ ## operator() 2855) 2856{ 2857 return this->boost_param_impl ## __LINE__ ## operator( 2858 boost_param_parameters_ ## __LINE__ ## operator()( 2859 <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/forward">std::forward</a><A0>(a0) 2860 , … 2861 , <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/forward">std::forward</a><A ## <strong>n</strong>>(a ## <strong>n</strong>) 2862 ) 2863 ); 2864} 2865 2866<span class="vellipsis">⋮</span> 2867 2868template <typename A0, …, typename A ## <strong>m</strong>> 2869<strong>result</strong> operator()( 2870 A0&& a0, …, A ## <strong>m</strong>&& a ## <strong>m</strong> 2871 , typename boost_param_parameters_ ## __LINE__ ## operator::match< 2872 A0, …, A ## <strong>m</strong> 2873 >::type = boost_param_parameters_ ## __LINE__ ## operator() 2874) 2875{ 2876 return this->boost_param_impl ## __LINE__ ## operator( 2877 boost_param_parameters_ ## __LINE__ ## operator()( 2878 <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/forward">std::forward</a><A0>(a0) 2879 , … 2880 , <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/forward">std::forward</a><A ## <strong>m</strong>>(a ## <strong>m</strong>) 2881 ) 2882 ); 2883} 2884 2885template <typename Args> 2886typename boost_param_result_ ## __LINE__ ## operator<Args>::type 2887 boost_param_impl ## __LINE__ ## operator(Args const& args) 2888{ 2889 return this->boost_param_dispatch_0boost_ ## __LINE__ ## operator( 2890 static_cast< 2891 typename boost_param_result_ ## __LINE__ ## operator< 2892 Args 2893 >::type(*)() 2894 >(<a class="reference external" href="http://en.cppreference.com/w/cpp/language/nullptr">std::nullptr</a>) 2895 , args 2896 , <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/forward">std::forward</a>< 2897 typename <a class="reference internal" href="#value-type"><tt class="docutils literal">value_type</tt></a>< 2898 Args 2899 , <em>keyword tag type of required parameter</em> ## <strong>0</strong> 2900 >::type 2901 >(args[ <em>keyword object of required parameter</em> ## <strong>0</strong>]) 2902 , … 2903 , <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/forward">std::forward</a>< 2904 typename <a class="reference internal" href="#value-type"><tt class="docutils literal">value_type</tt></a>< 2905 Args 2906 , <em>keyword tag type of required parameter</em> ## <strong>n</strong> 2907 >::type 2908 >(args[ <em>keyword object of required parameter</em> ## <strong>n</strong>]) 2909 ); 2910} 2911 2912template < 2913 typename ResultType 2914 , typename Args 2915 , typename <em>argument name</em> ## <strong>0</strong> ## _type 2916 , … 2917 , typename <em>argument name</em> ## <strong>n</strong> ## _type 2918> 2919ResultType 2920 boost_param_dispatch_0boost_ ## __LINE__ ## operator( 2921 (ResultType(*)()) 2922 , Args const& args 2923 , <em>argument name</em> ## <strong>0</strong> ## _type&& <em>argument name</em> ## <strong>0</strong> 2924 , … 2925 , <em>argument name</em> ## <strong>n</strong> ## _type&& <em>argument name</em> ## <strong>n</strong> 2926 ) 2927{ 2928 return this->boost_param_dispatch_0boost_ ## __LINE__ ## operator( 2929 static_cast<ResultType(*)()>(<a class="reference external" href="http://en.cppreference.com/w/cpp/language/nullptr">std::nullptr</a>) 2930 , (args, <em>keyword object of optional parameter</em> ## <strong>n + 1</strong> = 2931 <em>default value of optional parameter</em> ## <strong>n + 1</strong> 2932 ) 2933 , <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/forward">std::forward</a><<em>argument name</em> ## <strong>0</strong> ## _type>( 2934 <em>argument name</em> ## <strong>0</strong> 2935 ) 2936 , … 2937 , <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/forward">std::forward</a><<em>argument name</em> ## <strong>n</strong> ## _type>( 2938 <em>argument name</em> ## <strong>n</strong> 2939 ) 2940 , <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/forward">std::forward</a>< 2941 typename <a class="reference internal" href="#value-type"><tt class="docutils literal">value_type</tt></a>< 2942 Args 2943 , <em>keyword tag type of optional parameter</em> ## <strong>n + 1</strong> 2944 >::type 2945 >(<em>default value of optional parameter</em> ## <strong>n + 1</strong>) 2946 ); 2947} 2948 2949<span class="vellipsis">⋮</span> 2950 2951template < 2952 typename ResultType 2953 , typename Args 2954 , typename <em>argument name</em> ## <strong>0</strong> ## _type 2955 , … 2956 , typename <em>argument name</em> ## <strong>m</strong> ## _type 2957> 2958ResultType 2959 boost_param_dispatch_0boost_ ## __LINE__ ## operator( 2960 (ResultType(*)()) 2961 , Args const& args 2962 , <em>argument name</em> ## <strong>0</strong> ## _type&& <em>argument name</em> ## <strong>0</strong> 2963 , … 2964 , <em>argument name</em> ## <strong>m</strong> ## _type&& <em>argument name</em> ## <strong>m</strong> 2965 ) 2966</pre> 2967</div> 2968<div class="section" id="boost-parameter-const-function-call-operator-result-tag-ns-arguments"> 2969<span id="boost-parameter-const-function-call-operator"></span><h2><a class="toc-backref" href="#id61">7.5 <tt class="docutils literal">BOOST_PARAMETER_CONST_FUNCTION_CALL_OPERATOR(result, tag_ns, arguments)</tt></a></h2> 2970<table class="docutils field-list" frame="void" rules="none"> 2971<col class="field-name" /> 2972<col class="field-body" /> 2973<tbody valign="top"> 2974<tr class="field"><th class="field-name">Defined in:</th><td class="field-body"><a class="reference external" href="../../../../boost/parameter/preprocessor.hpp">boost/parameter/preprocessor.hpp</a></td> 2975</tr> 2976</tbody> 2977</table> 2978<p>Generates a function call operator that can take in positional arguments, 2979composed arguments, named arguments, and deduced arguments.</p> 2980<table class="docutils field-list" frame="void" rules="none"> 2981<col class="field-name" /> 2982<col class="field-body" /> 2983<tbody valign="top"> 2984<tr class="field"><th class="field-name">Example usage:</th><td class="field-body"></td> 2985</tr> 2986</tbody> 2987</table> 2988<p>The return type of each of the following function templates falls under a 2989different value category.</p> 2990<pre class="literal-block"> 2991template <std::size_t N> 2992<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1> rvalue_bitset() 2993{ 2994 return <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1>(); 2995} 2996 2997template <std::size_t N> 2998<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1> const rvalue_const_bitset() 2999{ 3000 return <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1>(); 3001} 3002 3003template <std::size_t N> 3004<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1>& lvalue_bitset() 3005{ 3006 static <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1> lset = <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1>(); 3007 return lset; 3008} 3009 3010template <std::size_t N> 3011<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1> const& lvalue_const_bitset() 3012{ 3013 static <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1> const clset = <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1>(); 3014 return clset; 3015} 3016</pre> 3017<p>The <tt class="docutils literal"><span class="pre">U::evaluate_category</span></tt> static member function template has a simple job: 3018to return the correct value category when passed in an object returned by one 3019of the functions defined above. Assume that 3020<a class="reference internal" href="#boost-parameter-has-perfect-forwarding"><tt class="docutils literal">BOOST_PARAMETER_HAS_PERFECT_FORWARDING</tt></a> is defined.</p> 3021<pre class="literal-block"> 3022enum invoked 3023{ 3024 passed_by_lvalue_reference_to_const 3025 , passed_by_lvalue_reference 3026 , passed_by_rvalue_reference_to_const 3027 , passed_by_rvalue_reference 3028}; 3029 3030struct U 3031{ 3032 template <std::size_t N> 3033 static invoked evaluate_category(<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1> const&) 3034 { 3035 return passed_by_lvalue_reference_to_const; 3036 } 3037 3038 template <std::size_t N> 3039 static invoked evaluate_category(<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1>&) 3040 { 3041 return passed_by_lvalue_reference; 3042 } 3043 3044 template <std::size_t N> 3045 static invoked evaluate_category(<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1> const&&) 3046 { 3047 return passed_by_rvalue_reference_to_const; 3048 } 3049 3050 template <std::size_t N> 3051 static invoked evaluate_category(<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1>&&) 3052 { 3053 return passed_by_rvalue_reference; 3054 } 3055}; 3056</pre> 3057<p>Define the named parameters that will comprise the argument specification that 3058this macro will use. Ensure that all their tag types are in the same 3059namespace, which is <tt class="docutils literal">kw</tt> in this case. The identifiers with leading 3060underscores can be passed to the bracket operator of <tt class="docutils literal">args</tt> to extract the 3061same argument to which the corresponding named parameter (without underscores) 3062is bound, as will be shown later.</p> 3063<pre class="literal-block"> 3064<a class="reference internal" href="#boost-parameter-name"><tt class="docutils literal">BOOST_PARAMETER_NAME</tt></a>((_lrc, kw) in(lrc)) 3065<a class="reference internal" href="#boost-parameter-name"><tt class="docutils literal">BOOST_PARAMETER_NAME</tt></a>((_lr, kw) in_out(lr)) 3066<a class="reference internal" href="#boost-parameter-name"><tt class="docutils literal">BOOST_PARAMETER_NAME</tt></a>((_rrc, kw) in(rrc)) 3067<a class="reference internal" href="#boost-parameter-name"><tt class="docutils literal">BOOST_PARAMETER_NAME</tt></a>((_rr, kw) consume(rr)) 3068</pre> 3069<p>Use the macro as a substitute for a normal <tt class="docutils literal">const</tt> function call operator 3070header. Enclose the return type <tt class="docutils literal">bool</tt> in parentheses. For each parameter, 3071also enclose the expected value type in parentheses. Since the value types 3072are mutually exclusive, you can wrap the parameters in a <tt class="docutils literal">(deduced …)</tt> 3073clause. Otherwise, just as with a normal function, the order in which you 3074specify the parameters determines their position. Also, just as with a normal 3075function, optional parameters have default values, whereas required parameters 3076do not. Within the function body, either simply use the parameter name or 3077pass the matching identifier with the leading underscore to the bracket 3078operator of <tt class="docutils literal">args</tt> to extract the corresponding argument. Note that the 3079second method doesn't require <tt class="docutils literal"><span class="pre">std::forward</span></tt> to preserve value categories.</p> 3080<pre class="literal-block"> 3081struct B 3082{ 3083 B() 3084 { 3085 } 3086 3087 BOOST_PARAMETER_CONST_FUNCTION_CALL_OPERATOR((bool), kw, 3088 (deduced 3089 (required 3090 (lrc, (<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><1>)) 3091 (lr, (<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><2>)) 3092 ) 3093 (optional 3094 (rrc, (<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><3>), rvalue_const_bitset<2>()) 3095 (rr, (<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><4>), rvalue_bitset<3>()) 3096 ) 3097 ) 3098 ) 3099 { 3100 BOOST_TEST_EQ( 3101 passed_by_lvalue_reference_to_const 3102 , U::evaluate_category<0>(lrc) 3103 ); 3104 BOOST_TEST_EQ( 3105 passed_by_lvalue_reference 3106 , U::evaluate_category<1>(lr) 3107 ); 3108 BOOST_TEST_EQ( 3109 passed_by_rvalue_reference_to_const 3110 , U::evaluate_category<2>(<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/forward">std::forward</a><rrc0_type>(rrc0)) 3111 ); 3112 BOOST_TEST_EQ( 3113 passed_by_rvalue_reference 3114 , U::evaluate_category<3>(args[_rr0]) 3115 ); 3116 3117 return true; 3118 } 3119}; 3120</pre> 3121<p>The following function calls are legal.</p> 3122<pre class="literal-block"> 3123B const b = B(); 3124b( // positional arguments 3125 lvalue_const_bitset<0>() 3126 , lvalue_bitset<1>() 3127 , rvalue_const_bitset<2>() 3128 , rvalue_bitset<3>() 3129); 3130b( // positional arguments 3131 lvalue_const_bitset<0>() 3132 , lvalue_bitset<1>() 3133); 3134b(( // composed arguments 3135 _rr0 = rvalue_bitset<3>() 3136 , _lrc0 = lvalue_const_bitset<0>() 3137 , _lr0 = lvalue_bitset<1>() 3138 , _rrc0 = rvalue_const_bitset<2>() 3139)); 3140b( // named arguments 3141 _rr0 = rvalue_bitset<3>() 3142 , _lrc0 = lvalue_const_bitset<0>() 3143 , _lr0 = lvalue_bitset<1>() 3144 , _rrc0 = rvalue_const_bitset<2>() 3145); 3146b( // named arguments 3147 _lr0 = lvalue_bitset<1>() 3148 , _lrc0 = lvalue_const_bitset<0>() 3149); 3150</pre> 3151<p>Because the parameters were wrapped in a <tt class="docutils literal">(deduced …)</tt> clause, the following 3152function calls are also legal.</p> 3153<pre class="literal-block"> 3154b( // deduced arguments 3155 rvalue_bitset<3>() 3156 , lvalue_const_bitset<0>() 3157 , lvalue_bitset<1>() 3158 , rvalue_const_bitset<2>() 3159); 3160b( // deduced arguments 3161 lvalue_bitset<1>() 3162 , lvalue_const_bitset<0>() 3163); 3164</pre> 3165<p>The <a class="reference external" href="../../test/preprocessor.cpp">preprocessor.cpp</a>, <a class="reference external" href="../../test/preprocessor_deduced.cpp">preprocessor_deduced.cpp</a>, and 3166<a class="reference external" href="../../test/preprocessor_eval_cat_8.cpp">preprocessor_eval_cat_8.cpp</a> test programs demonstrate proper usage of this 3167macro.</p> 3168<p><strong>Macro parameters:</strong></p> 3169<ul class="simple"> 3170<li><tt class="docutils literal">result</tt> is the parenthesized return type of the function call operator.</li> 3171<li><tt class="docutils literal">tag_namespace</tt> is the namespace in which the keywords used by the 3172function call operator resides.</li> 3173<li><tt class="docutils literal">arguments</tt> is a <a class="reference external" href="../../../preprocessor/doc/index.html">Boost.Preprocessor</a> <a class="reference external" href="../../../preprocessor/doc/data/sequences.html">sequence</a> of 3174<em>argument-specifiers</em>, as defined below.</li> 3175</ul> 3176<p><strong>Argument specifiers syntax:</strong></p> 3177<pre class="literal-block"> 3178argument-specifiers ::= <em>specifier-group0</em> {<em>specifier-group0</em>} 3179 3180specifier-group0 ::= <em>specifier-group1</em> | 3181 ( 3182 '<strong>(</strong>' '<strong>deduced</strong>' 3183 <em>specifier-group1</em> {<em>specifier-group1</em>} 3184 '<strong>)</strong>' 3185 ) 3186 3187specifier-group1 ::= 3188 ( 3189 '<strong>(</strong>' '<strong>optional</strong>' 3190 <em>optional-specifier</em> {<em>optional-specifier</em>} 3191 '<strong>)</strong>' 3192 ) | ( 3193 '<strong>(</strong>' '<strong>required</strong>' 3194 <em>required-specifier</em> {<em>required-specifier</em>} 3195 '<strong>)</strong>' 3196 ) 3197 3198optional-specifier ::= 3199 '<strong>(</strong>' 3200 <em>argument-name</em> '<strong>,</strong>' <em>restriction</em> '<strong>,</strong>' <em>default-value</em> 3201 ')' 3202 3203required-specifier ::= 3204 '<strong>(</strong>' <em>argument-name</em> '<strong>,</strong>' <em>restriction</em> ')' 3205 3206restriction ::= 3207 ( '<strong>*</strong>' '<strong>(</strong>' <em>mfc</em> '<strong>)</strong>' ) | 3208 ( '<strong>(</strong>' <em>type-name</em> '<strong>)</strong>' ) | 3209 '<strong>*</strong>' 3210</pre> 3211<ul class="simple"> 3212<li><tt class="docutils literal"><span class="pre">argument-name</span></tt> is any valid C++ identifier.</li> 3213<li><tt class="docutils literal"><span class="pre">default-value</span></tt> is any valid C++ expression; if necessary, user code can 3214compute it in terms of <tt class="docutils literal"><span class="pre">previous-name</span> ## _type</tt>, where <tt class="docutils literal"><span class="pre">previous-name</span></tt> 3215is the <tt class="docutils literal"><span class="pre">argument-name</span></tt> in a previous <tt class="docutils literal"><span class="pre">specifier-group0</span></tt> or 3216<tt class="docutils literal"><span class="pre">specifier-group1</span></tt>. <em>This expression will be invoked exactly once.</em></li> 3217<li><tt class="docutils literal">mfc</tt> is an <a class="reference external" href="../../../mpl/doc/refmanual/metafunction-class.html">MPL Binary Metafunction Class</a> whose first argument will 3218be the type of the corresponding <tt class="docutils literal"><span class="pre">argument-name</span></tt>, whose second argument 3219will be the entire <a class="reference internal" href="#argumentpack"><span class="concept">ArgumentPack</span></a>, and whose return type is a <a class="reference external" href="../../../mpl/doc/refmanual/integral-constant.html">Boolean 3220Integral Constant</a>; however, user code <em>cannot</em> compute <tt class="docutils literal">mfc</tt> in terms 3221of <tt class="docutils literal"><span class="pre">previous-name</span> ## _type</tt>.</li> 3222<li><tt class="docutils literal"><span class="pre">type-name</span></tt> is either the name of a <strong>target type</strong> or an <a class="reference external" href="../../../mpl/doc/refmanual/metafunction-class.html">MPL Binary 3223Metafunction Class</a> whose first argument will be the type of the 3224corresponding <tt class="docutils literal"><span class="pre">argument-name</span></tt>, whose second argument will be the entire 3225<a class="reference internal" href="#argumentpack"><span class="concept">ArgumentPack</span></a>, and whose return type is the <strong>target type</strong>. If 3226<tt class="docutils literal">restriction</tt> uses this form, then the type of the generated name 3227<tt class="docutils literal"><span class="pre">argument-name</span> ## _type</tt> will be computed in terms of the <strong>target 3228type</strong>, and the generated reference <tt class="docutils literal"><span class="pre">argument-name</span></tt> (but not its 3229corresponding entry in <tt class="docutils literal">args</tt>) will be cast to that type.</li> 3230</ul> 3231<p><strong>Approximate expansion:</strong></p> 3232<p>Where:</p> 3233<ul class="simple"> 3234<li><tt class="docutils literal">n</tt> denotes the <em>minimum</em> arity, as determined from <tt class="docutils literal">arguments</tt>.</li> 3235<li><tt class="docutils literal">m</tt> denotes the <em>maximum</em> arity, as determined from <tt class="docutils literal">arguments</tt>.</li> 3236</ul> 3237<pre class="literal-block"> 3238// If <strong>result</strong> is a template instantiation of <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::enable_if</a>, 3239// <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::enable_if_c</a>, <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::lazy_enable_if</a>, 3240// <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::lazy_enable_if_c</a>, <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::disable_if</a>, <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::disable_if_c</a>, 3241// <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::lazy_disable_if</a>, <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::lazy_disable_if_c</a>, or 3242// <a class="reference external" href="http://en.cppreference.com/w/cpp/types/enable_if">std::enable_if</a>: 3243template <typename Args> 3244using boost_param_result_const_ ## __LINE__ ## operator = <strong>result</strong>; 3245 3246// If <strong>result</strong> is a simple return type: 3247template <typename Args> 3248struct boost_param_result_const_ ## __LINE__ ## operator 3249{ 3250 typedef <strong>result</strong> type; 3251}; 3252 3253struct boost_param_params_const_ ## __LINE__ ## operator 3254 : <a class="reference internal" href="#parameters"><tt class="docutils literal">parameters</tt></a>< 3255 <em>list of parameter specifications, based on arguments</em> 3256 > 3257{ 3258}; 3259 3260typedef boost_param_params_const_ ## __LINE__ ## operator 3261 boost_param_parameters_const_ ## __LINE__ ## operator; 3262 3263template <typename A0, …, typename A ## <strong>n</strong>> 3264<strong>result</strong> operator()( 3265 A0&& a0, …, A ## <strong>n</strong>&& a ## <strong>n</strong> 3266 , typename boost_param_parameters_const_ ## __LINE__ ## operator 3267 ::match<A0, …, A ## <strong>n</strong>>::type 3268 = boost_param_parameters_const_ ## __LINE__ ## operator() 3269) const 3270{ 3271 return this->boost_param_impl_const ## __LINE__ ## operator( 3272 boost_param_parameters_const_ ## __LINE__ ## operator()( 3273 <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/forward">std::forward</a><A0>(a0) 3274 , … 3275 , <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/forward">std::forward</a><A ## <strong>n</strong>>(a ## <strong>n</strong>) 3276 ) 3277 ); 3278} 3279 3280<span class="vellipsis">⋮</span> 3281 3282template <typename A0, …, typename A ## <strong>m</strong>> 3283<strong>result</strong> operator()( 3284 A0&& a0, …, A ## <strong>m</strong>&& a ## <strong>m</strong> 3285 , typename boost_param_parameters_const_ ## __LINE__ ## operator 3286 ::match<A0, …, A ## <strong>m</strong>>::type 3287 = boost_param_parameters_const_ ## __LINE__ ## operator() 3288) const 3289{ 3290 return this->boost_param_impl_const ## __LINE__ ## operator( 3291 boost_param_parameters_const_ ## __LINE__ ## operator()( 3292 <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/forward">std::forward</a><A0>(a0) 3293 , … 3294 , <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/forward">std::forward</a><A ## <strong>m</strong>>(a ## <strong>m</strong>) 3295 ) 3296 ); 3297} 3298 3299template <typename Args> 3300typename boost_param_result_const_ ## __LINE__ ## operator<Args>::type 3301 boost_param_impl_const ## __LINE__ ## operator(Args const& args) const 3302{ 3303 return this-> 3304 boost_param_dispatch_const_0boost_ ## __LINE__ ## operator( 3305 static_cast< 3306 typename boost_param_result_const_ ## __LINE__ ## operator< 3307 Args 3308 >::type(*)() 3309 >(<a class="reference external" href="http://en.cppreference.com/w/cpp/language/nullptr">std::nullptr</a>) 3310 , args 3311 , <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/forward">std::forward</a>< 3312 typename <a class="reference internal" href="#value-type"><tt class="docutils literal">value_type</tt></a>< 3313 Args 3314 , <em>keyword tag type of required parameter</em> ## <strong>0</strong> 3315 >::type 3316 >(args[ <em>keyword object of required parameter</em> ## <strong>0</strong>]) 3317 , … 3318 , <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/forward">std::forward</a>< 3319 typename <a class="reference internal" href="#value-type"><tt class="docutils literal">value_type</tt></a>< 3320 Args 3321 , <em>keyword tag type of required parameter</em> ## <strong>n</strong> 3322 >::type 3323 >(args[ <em>keyword object of required parameter</em> ## <strong>n</strong>]) 3324 ); 3325} 3326 3327template < 3328 typename ResultType 3329 , typename Args 3330 , typename <em>argument name</em> ## <strong>0</strong> ## _type 3331 , … 3332 , typename <em>argument name</em> ## <strong>n</strong> ## _type 3333> 3334ResultType 3335 boost_param_dispatch_const_0boost_ ## __LINE__ ## operator( 3336 (ResultType(*)()) 3337 , Args const& args 3338 , <em>argument name</em> ## <strong>0</strong> ## _type&& <em>argument name</em> ## <strong>0</strong> 3339 , … 3340 , <em>argument name</em> ## <strong>n</strong> ## _type&& <em>argument name</em> ## <strong>n</strong> 3341 ) const 3342{ 3343 return this-> 3344 boost_param_dispatch_const_0boost_ ## __LINE__ ## operator( 3345 static_cast<ResultType(*)()>(<a class="reference external" href="http://en.cppreference.com/w/cpp/language/nullptr">std::nullptr</a>) 3346 , (args, <em>keyword object of optional parameter</em> ## <strong>n + 1</strong> = 3347 <em>default value of optional parameter</em> ## <strong>n + 1</strong> 3348 ) 3349 , <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/forward">std::forward</a><<em>argument name</em> ## <strong>0</strong> ## _type>( 3350 <em>argument name</em> ## <strong>0</strong> 3351 ) 3352 , … 3353 , <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/forward">std::forward</a><<em>argument name</em> ## <strong>n</strong> ## _type>( 3354 <em>argument name</em> ## <strong>n</strong> 3355 ) 3356 , <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/forward">std::forward</a>< 3357 typename <a class="reference internal" href="#value-type"><tt class="docutils literal">value_type</tt></a>< 3358 Args 3359 , <em>keyword tag type of optional parameter</em> ## <strong>n + 1</strong> 3360 >::type 3361 >(<em>default value of optional parameter</em> ## <strong>n + 1</strong>) 3362 ); 3363} 3364 3365<span class="vellipsis">⋮</span> 3366 3367template < 3368 typename ResultType 3369 , typename Args 3370 , typename <em>argument name</em> ## <strong>0</strong> ## _type 3371 , … 3372 , typename <em>argument name</em> ## <strong>m</strong> ## _type 3373> 3374ResultType 3375 boost_param_dispatch_const_0boost_ ## __LINE__ ## operator( 3376 (ResultType(*)()) 3377 , Args const& args 3378 , <em>argument name</em> ## <strong>0</strong> ## _type&& <em>argument name</em> ## <strong>0</strong> 3379 , … 3380 , <em>argument name</em> ## <strong>m</strong> ## _type&& <em>argument name</em> ## <strong>m</strong> 3381 ) const 3382</pre> 3383</div> 3384<div class="section" id="boost-parameter-constructor-cls-impl-tag-namespace-arguments"> 3385<span id="boost-parameter-constructor"></span><h2><a class="toc-backref" href="#id62">7.6 <tt class="docutils literal">BOOST_PARAMETER_CONSTRUCTOR(cls, impl, tag_namespace, arguments)</tt></a></h2> 3386<table class="docutils field-list" frame="void" rules="none"> 3387<col class="field-name" /> 3388<col class="field-body" /> 3389<tbody valign="top"> 3390<tr class="field"><th class="field-name">Defined in:</th><td class="field-body"><a class="reference external" href="../../../../boost/parameter/preprocessor.hpp">boost/parameter/preprocessor.hpp</a></td> 3391</tr> 3392</tbody> 3393</table> 3394<p>Generates a constructor that can take in positional arguments, composed 3395arguments, named arguments, and deduced arguments.</p> 3396<table class="docutils field-list" frame="void" rules="none"> 3397<col class="field-name" /> 3398<col class="field-body" /> 3399<tbody valign="top"> 3400<tr class="field"><th class="field-name">Example usage:</th><td class="field-body"></td> 3401</tr> 3402</tbody> 3403</table> 3404<p>Define the named parameters that will comprise the argument specification that 3405this macro will use. Ensure that all their tag types are in the same 3406namespace, which is <tt class="docutils literal">tag</tt> by default.</p> 3407<pre class="literal-block"> 3408<a class="reference internal" href="#boost-parameter-name"><tt class="docutils literal">BOOST_PARAMETER_NAME</tt></a>(y) 3409<a class="reference internal" href="#boost-parameter-name"><tt class="docutils literal">BOOST_PARAMETER_NAME</tt></a>(z) 3410</pre> 3411<p>In the base class, implement a delegate constructor template that takes in an 3412<a class="reference internal" href="#argumentpack"><span class="concept">ArgumentPack</span></a>. You must pass the identifiers with leading underscores to 3413<tt class="docutils literal">args</tt> in order to extract the corresponding arguments.</p> 3414<pre class="literal-block"> 3415class char_read_base 3416{ 3417 int index; 3418 char const* key; 3419 3420 public: 3421 template <typename Args> 3422 explicit char_read_base(Args const& args) 3423 : index(args[_y]), key(args[_z]) 3424 { 3425 } 3426 3427 <a class="reference internal" href="#boost-parameter-const-function-call-operator"><tt class="docutils literal">BOOST_PARAMETER_CONST_FUNCTION_CALL_OPERATOR</tt></a>((char), tag, 3428 (deduced 3429 (required 3430 (y, (bool)) 3431 (z, (<a class="reference external" href="http://en.cppreference.com/w/cpp/container/map">std::map</a><char const*, <a class="reference external" href="http://en.cppreference.com/w/cpp/string/basic_string">std::string</a>>)) 3432 ) 3433 ) 3434 ) 3435 { 3436 return y ? ( 3437 (z.find(this->key)->second)[this->index] 3438 ) : this->key[this->index]; 3439 } 3440}; 3441</pre> 3442<p>Use the macro as a substitute for a normal constructor definition. Note the 3443lack of an explicit body. Enclose the base type in parentheses. For each 3444parameter, also enclose the expected value type in parentheses. Since the 3445value types are mutually exclusive, you can wrap the parameters in a 3446<tt class="docutils literal">(deduced …)</tt> clause.</p> 3447<pre class="literal-block"> 3448struct char_reader : public char_read_base 3449{ 3450 BOOST_PARAMETER_CONSTRUCTOR(char_reader, (char_read_base), tag, 3451 (deduced 3452 (required 3453 (y, (int)) 3454 (z, (char const*)) 3455 ) 3456 ) 3457 ) 3458}; 3459</pre> 3460<p>The following <tt class="docutils literal">char_reader</tt> constructor calls are legal.</p> 3461<pre class="literal-block"> 3462char const* keys[] = {"foo", "bar", "baz"}; 3463<a class="reference external" href="http://en.cppreference.com/w/cpp/container/map">std::map</a><char const*, <a class="reference external" href="http://en.cppreference.com/w/cpp/string/basic_string">std::string</a>> k2s; 3464k2s[keys[0]] = <a class="reference external" href="http://en.cppreference.com/w/cpp/string/basic_string">std::string</a>("qux"); 3465k2s[keys[1]] = <a class="reference external" href="http://en.cppreference.com/w/cpp/string/basic_string">std::string</a>("wmb"); 3466k2s[keys[2]] = <a class="reference external" href="http://en.cppreference.com/w/cpp/string/basic_string">std::string</a>("zxc"); 3467 3468// positional arguments 3469char_reader r0(0, keys[0]); 3470BOOST_TEST_EQ('q', (r0(true, k2s))); 3471BOOST_TEST_EQ('f', (r0(false, k2s))); 3472 3473// named arguments 3474char_reader r1(_z = keys[1], _y = 1); 3475BOOST_TEST_EQ('m', (r1(_z = k2s, _y = true))); 3476BOOST_TEST_EQ('a', (r1(_z = k2s, _y = false))); 3477 3478// deduced arguments 3479char_reader r2(keys[2], 2); 3480BOOST_TEST_EQ('c', (r2(k2s, true))); 3481BOOST_TEST_EQ('z', (r2(k2s, false))); 3482</pre> 3483<p>The <a class="reference external" href="../../test/preprocessor.cpp">preprocessor.cpp</a> and <a class="reference external" href="../../test/preprocessor_deduced.cpp">preprocessor_deduced.cpp</a> test programs 3484demonstrate proper usage of this macro.</p> 3485<p><strong>Macro parameters:</strong></p> 3486<ul class="simple"> 3487<li><tt class="docutils literal">cls</tt> is the name of the enclosing class.</li> 3488<li><tt class="docutils literal">impl</tt> is the parenthesized implementation base class for <tt class="docutils literal">cls</tt>.</li> 3489<li><tt class="docutils literal">tag_namespace</tt> is the namespace in which the keywords used by the 3490constructor resides.</li> 3491<li><tt class="docutils literal">arguments</tt> is a list of <em>argument-specifiers</em>, as defined below.</li> 3492</ul> 3493<p><strong>Argument specifiers syntax:</strong></p> 3494<pre class="literal-block"> 3495argument-specifiers ::= <em>specifier-group0</em> {<em>specifier-group0</em>} 3496 3497specifier-group0 ::= <em>specifier-group1</em> | 3498 ( 3499 '<strong>(</strong>' '<strong>deduced</strong>' 3500 <em>specifier-group1</em> {<em>specifier-group1</em>} 3501 '<strong>)</strong>' 3502 ) 3503 3504specifier-group1 ::= 3505 ( 3506 '<strong>(</strong>' '<strong>optional</strong>' 3507 <em>specifier</em> {<em>specifier</em>} 3508 '<strong>)</strong>' 3509 ) | ( 3510 '<strong>(</strong>' '<strong>required</strong>' 3511 <em>specifier</em> {<em>specifier</em>} 3512 '<strong>)</strong>' 3513 ) 3514 3515specifier ::= 3516 '<strong>(</strong>' <em>argument-name</em> '<strong>,</strong>' <em>restriction</em> ')' 3517 3518restriction ::= 3519 ( '<strong>*</strong>' '<strong>(</strong>' <em>mfc</em> '<strong>)</strong>' ) | 3520 ( '<strong>(</strong>' <em>type-name</em> '<strong>)</strong>' ) | 3521 '<strong>*</strong>' 3522</pre> 3523<ul class="simple"> 3524<li><tt class="docutils literal"><span class="pre">argument-name</span></tt> is any valid C++ identifier.</li> 3525<li><tt class="docutils literal">mfc</tt> is an <a class="reference external" href="../../../mpl/doc/refmanual/metafunction-class.html">MPL Binary Metafunction Class</a> whose first argument will 3526be the type of the corresponding <tt class="docutils literal"><span class="pre">argument-name</span></tt>, whose second argument 3527will be the entire <a class="reference internal" href="#argumentpack"><span class="concept">ArgumentPack</span></a>, and whose return type is a <a class="reference external" href="../../../mpl/doc/refmanual/integral-constant.html">Boolean 3528Integral Constant</a>; however, user code <em>cannot</em> compute <tt class="docutils literal">mfc</tt> in terms 3529of <tt class="docutils literal"><span class="pre">previous-name</span> ## _type</tt>.</li> 3530<li><tt class="docutils literal"><span class="pre">type-name</span></tt> is either the name of a <strong>target type</strong> or an <a class="reference external" href="../../../mpl/doc/refmanual/metafunction-class.html">MPL Binary 3531Metafunction Class</a> whose first argument will be the type of the 3532corresponding <tt class="docutils literal"><span class="pre">argument-name</span></tt>, whose second argument will be the entire 3533<a class="reference internal" href="#argumentpack"><span class="concept">ArgumentPack</span></a>, and whose return type is the <strong>target type</strong>.</li> 3534</ul> 3535<p>Note that <em>specifier</em> does not include <em>default-value</em>. It is up to the 3536delegate constructor in <tt class="docutils literal">impl</tt> to determine the default value of all 3537optional arguments.</p> 3538<p><strong>Approximate expansion:</strong></p> 3539<p>Where:</p> 3540<ul class="simple"> 3541<li><tt class="docutils literal">n</tt> denotes the <em>minimum</em> arity, as determined from <tt class="docutils literal">arguments</tt>.</li> 3542<li><tt class="docutils literal">m</tt> denotes the <em>maximum</em> arity, as determined from <tt class="docutils literal">arguments</tt>.</li> 3543</ul> 3544<pre class="literal-block"> 3545struct boost_param_params_ ## __LINE__ ## ctor 3546 : <a class="reference internal" href="#parameters"><tt class="docutils literal">parameters</tt></a>< 3547 <em>list of parameter specifications, based on arguments</em> 3548 > 3549{ 3550}; 3551 3552typedef boost_param_params_ ## __LINE__ ## ctor 3553 constructor_parameters ## __LINE__; 3554 3555template <typename A0, …, typename A ## <strong>n</strong>> 3556<strong>cls</strong>(A0&& a0, …, A ## <strong>n</strong> && a ## <strong>n</strong>) 3557 : <strong>impl</strong>( 3558 constructor_parameters ## __LINE__( 3559 <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/forward">std::forward</a><A0>(a0) 3560 , … 3561 , <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/forward">std::forward</a><A ## <strong>n</strong>>(a ## <strong>n</strong>) 3562 ) 3563 ) 3564{ 3565} 3566 3567<span class="vellipsis">⋮</span> 3568 3569template <typename A0, …, typename A ## <strong>m</strong>> 3570<strong>cls</strong>(A0&& a0, …, A ## <strong>m</strong> && a ## <strong>m</strong>) 3571 : <strong>impl</strong>( 3572 constructor_parameters ## __LINE__( 3573 <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/forward">std::forward</a><A0>(a0) 3574 , … 3575 , <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/forward">std::forward</a><A ## <strong>m</strong>>(a ## <strong>m</strong>) 3576 ) 3577 ) 3578{ 3579} 3580</pre> 3581</div> 3582<div class="section" id="boost-parameter-basic-function-result-name-tag-namespace-arguments"> 3583<span id="boost-parameter-basic-function"></span><h2><a class="toc-backref" href="#id63">7.7 <tt class="docutils literal">BOOST_PARAMETER_BASIC_FUNCTION(result, name, tag_namespace, arguments)</tt></a></h2> 3584<table class="docutils field-list" frame="void" rules="none"> 3585<col class="field-name" /> 3586<col class="field-body" /> 3587<tbody valign="top"> 3588<tr class="field"><th class="field-name">Defined in:</th><td class="field-body"><a class="reference external" href="../../../../boost/parameter/preprocessor.hpp">boost/parameter/preprocessor.hpp</a></td> 3589</tr> 3590</tbody> 3591</table> 3592<p>Generates a function that can take in positional arguments, composed 3593arguments, named arguments, and deduced arguments.</p> 3594<table class="docutils field-list" frame="void" rules="none"> 3595<col class="field-name" /> 3596<col class="field-body" /> 3597<tbody valign="top"> 3598<tr class="field"><th class="field-name">Example usage:</th><td class="field-body"></td> 3599</tr> 3600</tbody> 3601</table> 3602<p>The return type of each of the following function templates falls under a 3603different value category.</p> 3604<pre class="literal-block"> 3605template <std::size_t N> 3606<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1> rvalue_bitset() 3607{ 3608 return <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1>(); 3609} 3610 3611template <std::size_t N> 3612<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1> const rvalue_const_bitset() 3613{ 3614 return <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1>(); 3615} 3616 3617template <std::size_t N> 3618<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1>& lvalue_bitset() 3619{ 3620 static <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1> lset = <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1>(); 3621 return lset; 3622} 3623 3624template <std::size_t N> 3625<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1> const& lvalue_const_bitset() 3626{ 3627 static <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1> const clset = <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1>(); 3628 return clset; 3629} 3630</pre> 3631<p>The <tt class="docutils literal"><span class="pre">U::evaluate_category</span></tt> static member function template has a simple job: 3632to return the correct value category when passed in an object returned by one 3633of the functions defined above. Assume that 3634<a class="reference internal" href="#boost-parameter-has-perfect-forwarding"><tt class="docutils literal">BOOST_PARAMETER_HAS_PERFECT_FORWARDING</tt></a> is defined.</p> 3635<pre class="literal-block"> 3636enum invoked 3637{ 3638 passed_by_lvalue_reference_to_const 3639 , passed_by_lvalue_reference 3640 , passed_by_rvalue_reference_to_const 3641 , passed_by_rvalue_reference 3642}; 3643 3644struct U 3645{ 3646 template <std::size_t N> 3647 static invoked evaluate_category(<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1> const&) 3648 { 3649 return passed_by_lvalue_reference_to_const; 3650 } 3651 3652 template <std::size_t N> 3653 static invoked evaluate_category(<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1>&) 3654 { 3655 return passed_by_lvalue_reference; 3656 } 3657 3658 template <std::size_t N> 3659 static invoked evaluate_category(<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1> const&&) 3660 { 3661 return passed_by_rvalue_reference_to_const; 3662 } 3663 3664 template <std::size_t N> 3665 static invoked evaluate_category(<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1>&&) 3666 { 3667 return passed_by_rvalue_reference; 3668 } 3669}; 3670</pre> 3671<p>Define the named parameters that will comprise the argument specification that 3672this macro will use. Ensure that all their tag types are in the same 3673namespace, which is <tt class="docutils literal">kw</tt> in this case. The identifiers with leading 3674underscores can be passed to the bracket operator of <tt class="docutils literal">args</tt> to extract the 3675same argument to which the corresponding named parameter (without underscores) 3676is bound, as will be shown later.</p> 3677<pre class="literal-block"> 3678<a class="reference internal" href="#boost-parameter-name"><tt class="docutils literal">BOOST_PARAMETER_NAME</tt></a>((_lrc, kw) in(lrc)) 3679<a class="reference internal" href="#boost-parameter-name"><tt class="docutils literal">BOOST_PARAMETER_NAME</tt></a>((_lr, kw) in_out(lr)) 3680<a class="reference internal" href="#boost-parameter-name"><tt class="docutils literal">BOOST_PARAMETER_NAME</tt></a>((_rrc, kw) in(rrc)) 3681<a class="reference internal" href="#boost-parameter-name"><tt class="docutils literal">BOOST_PARAMETER_NAME</tt></a>((_rr, kw) consume(rr)) 3682</pre> 3683<p>Use the macro as a substitute for a normal function header. Enclose the 3684return type <tt class="docutils literal">bool</tt> in parentheses. For each parameter, also enclose the 3685expected value type in parentheses. Since the value types are mutually 3686exclusive, you can wrap the parameters in a <tt class="docutils literal">(deduced …)</tt> 3687clause. Otherwise, just as with a normal function, the order in which you 3688specify the parameters determines their position. However, unlike a normal 3689function, default values must be specified within the function body. Also 3690within the function body, you must pass the matching identifier with the 3691leading underscore to the bracket operator of <tt class="docutils literal">args</tt> to extract the 3692corresponding argument, but at least this doesn't require <tt class="docutils literal"><span class="pre">std::forward</span></tt> to 3693preserve value categories.</p> 3694<pre class="literal-block"> 3695BOOST_PARAMETER_BASIC_FUNCTION((bool), evaluate, kw, 3696 (deduced 3697 (required 3698 (lrc, (<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><1>)) 3699 (lr, (<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><2>)) 3700 ) 3701 (optional 3702 (rrc, (<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><3>)) 3703 (rr, (<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><4>)) 3704 ) 3705 ) 3706) 3707{ 3708 BOOST_TEST_EQ( 3709 passed_by_lvalue_reference_to_const 3710 , U::evaluate_category<0>(args[_lrc]) 3711 ); 3712 BOOST_TEST_EQ( 3713 passed_by_lvalue_reference 3714 , U::evaluate_category<1>(args[_lr]) 3715 ); 3716 BOOST_TEST_EQ( 3717 passed_by_rvalue_reference_to_const 3718 , U::evaluate_category<2>( 3719 args[_rrc0 | rvalue_const_bitset<2>()] 3720 ) 3721 ); 3722 BOOST_TEST_EQ( 3723 passed_by_rvalue_reference 3724 , U::evaluate_category<3>(args[_rr0 | rvalue_bitset<3>()]) 3725 ); 3726 3727 return true; 3728} 3729</pre> 3730<p>The following function calls are legal.</p> 3731<pre class="literal-block"> 3732evaluate( // positional arguments 3733 lvalue_const_bitset<0>() 3734 , lvalue_bitset<1>() 3735 , rvalue_const_bitset<2>() 3736 , rvalue_bitset<3>() 3737); 3738evaluate( // positional arguments 3739 lvalue_const_bitset<0>() 3740 , lvalue_bitset<1>() 3741); 3742evaluate(( // composed arguments 3743 _rr0 = rvalue_bitset<3>() 3744 , _lrc0 = lvalue_const_bitset<0>() 3745 , _lr0 = lvalue_bitset<1>() 3746 , _rrc0 = rvalue_const_bitset<2>() 3747)); 3748evaluate( // named arguments 3749 _rr0 = rvalue_bitset<3>() 3750 , _lrc0 = lvalue_const_bitset<0>() 3751 , _lr0 = lvalue_bitset<1>() 3752 , _rrc0 = rvalue_const_bitset<2>() 3753); 3754evaluate( // named arguments 3755 _lr0 = lvalue_bitset<1>() 3756 , _lrc0 = lvalue_const_bitset<0>() 3757); 3758</pre> 3759<p>Because the parameters were wrapped in a <tt class="docutils literal">(deduced …)</tt> clause, the following 3760function calls are also legal.</p> 3761<pre class="literal-block"> 3762evaluate( // deduced arguments 3763 rvalue_bitset<3>() 3764 , lvalue_const_bitset<0>() 3765 , lvalue_bitset<1>() 3766 , rvalue_const_bitset<2>() 3767); 3768evaluate( // deduced arguments 3769 lvalue_bitset<1>() 3770 , lvalue_const_bitset<0>() 3771); 3772</pre> 3773<p>The <a class="reference external" href="../../test/preprocessor.cpp">preprocessor.cpp</a> test program demonstrates proper usage of this macro.</p> 3774<p><strong>Macro parameters:</strong></p> 3775<ul class="simple"> 3776<li><tt class="docutils literal">result</tt> is the parenthesized return type of the function.</li> 3777<li><tt class="docutils literal">name</tt> is the base name of the function; it determines the name of the 3778generated forwarding functions.</li> 3779<li><tt class="docutils literal">tag_namespace</tt> is the namespace in which the keywords used by the 3780function resides.</li> 3781<li><tt class="docutils literal">arguments</tt> is a <a class="reference external" href="../../../preprocessor/doc/index.html">Boost.Preprocessor</a> <a class="reference external" href="../../../preprocessor/doc/data/sequences.html">sequence</a> of 3782<em>argument-specifiers</em>, as defined below.</li> 3783</ul> 3784<p><strong>Argument specifiers syntax:</strong></p> 3785<pre class="literal-block"> 3786argument-specifiers ::= <em>specifier-group0</em> {<em>specifier-group0</em>} 3787 3788specifier-group0 ::= <em>specifier-group1</em> | 3789 ( 3790 '<strong>(</strong>' '<strong>deduced</strong>' 3791 <em>specifier-group1</em> {<em>specifier-group1</em>} 3792 '<strong>)</strong>' 3793 ) 3794 3795specifier-group1 ::= 3796 ( 3797 '<strong>(</strong>' '<strong>optional</strong>' 3798 <em>specifier</em> {<em>specifier</em>} 3799 '<strong>)</strong>' 3800 ) | ( 3801 '<strong>(</strong>' '<strong>required</strong>' 3802 <em>specifier</em> {<em>specifier</em>} 3803 '<strong>)</strong>' 3804 ) 3805 3806specifier ::= 3807 '<strong>(</strong>' <em>argument-name</em> '<strong>,</strong>' <em>restriction</em> ')' 3808 3809restriction ::= 3810 ( '<strong>*</strong>' '<strong>(</strong>' <em>mfc</em> '<strong>)</strong>' ) | 3811 ( '<strong>(</strong>' <em>type-name</em> '<strong>)</strong>' ) | 3812 '<strong>*</strong>' 3813</pre> 3814<ul class="simple"> 3815<li><tt class="docutils literal"><span class="pre">argument-name</span></tt> is any valid C++ identifier.</li> 3816<li><tt class="docutils literal">mfc</tt> is an <a class="reference external" href="../../../mpl/doc/refmanual/metafunction-class.html">MPL Binary Metafunction Class</a> whose first argument will 3817be the type of the corresponding <tt class="docutils literal"><span class="pre">argument-name</span></tt>, whose second argument 3818will be the entire <a class="reference internal" href="#argumentpack"><span class="concept">ArgumentPack</span></a>, and whose return type is a <a class="reference external" href="../../../mpl/doc/refmanual/integral-constant.html">Boolean 3819Integral Constant</a>; however, user code <em>cannot</em> compute <tt class="docutils literal">mfc</tt> in terms 3820of <tt class="docutils literal"><span class="pre">previous-name</span> ## _type</tt>.</li> 3821<li><tt class="docutils literal"><span class="pre">type-name</span></tt> is either the name of a <strong>target type</strong> or an <a class="reference external" href="../../../mpl/doc/refmanual/metafunction-class.html">MPL Binary 3822Metafunction Class</a> whose first argument will be the type of the 3823corresponding <tt class="docutils literal"><span class="pre">argument-name</span></tt>, whose second argument will be the entire 3824<a class="reference internal" href="#argumentpack"><span class="concept">ArgumentPack</span></a>, and whose return type is the <strong>target type</strong>.</li> 3825</ul> 3826<p>Note that <em>specifier</em> does not include <em>default-value</em>. It is up to the 3827function body to determine the default value of all optional arguments.</p> 3828<p><strong>Approximate expansion:</strong></p> 3829<p>Where:</p> 3830<ul class="simple"> 3831<li><tt class="docutils literal">n</tt> denotes the <em>minimum</em> arity, as determined from <tt class="docutils literal">arguments</tt>.</li> 3832<li><tt class="docutils literal">m</tt> denotes the <em>maximum</em> arity, as determined from <tt class="docutils literal">arguments</tt>.</li> 3833</ul> 3834<pre class="literal-block"> 3835// If <strong>result</strong> is a template instantiation of <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::enable_if</a>, 3836// <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::enable_if_c</a>, <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::lazy_enable_if</a>, 3837// <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::lazy_enable_if_c</a>, <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::disable_if</a>, <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::disable_if_c</a>, 3838// <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::lazy_disable_if</a>, <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::lazy_disable_if_c</a>, or 3839// <a class="reference external" href="http://en.cppreference.com/w/cpp/types/enable_if">std::enable_if</a>: 3840template <typename Args> 3841using boost_param_result_ ## __LINE__ ## <strong>name</strong> = <strong>result</strong>; 3842 3843// If <strong>result</strong> is a simple return type: 3844template <typename Args> 3845struct boost_param_result_ ## __LINE__ ## <strong>name</strong> 3846{ 3847 typedef <strong>result</strong> type; 3848}; 3849 3850struct boost_param_params_ ## __LINE__ ## <strong>name</strong> 3851 : <a class="reference internal" href="#parameters"><tt class="docutils literal">parameters</tt></a>< 3852 <em>list of parameter specifications, based on arguments</em> 3853 > 3854{ 3855}; 3856 3857typedef boost_param_params_ ## __LINE__ ## <strong>name</strong> 3858 boost_param_parameters_ ## __LINE__ ## <strong>name</strong>; 3859 3860template <typename Args> 3861typename boost_param_result_ ## __LINE__ ## <strong>name</strong><Args>::type 3862 boost_param_impl ## <strong>name</strong>(Args const&); 3863 3864template <typename A0, …, typename A ## <strong>n</strong>> 3865<strong>result</strong> <strong>name</strong>( 3866 A0&& a0, …, A ## <strong>n</strong>&& a ## <strong>n</strong> 3867 , typename boost_param_parameters_ ## __LINE__ ## <strong>name</strong> 3868 ::match<A0, …, A ## <strong>n</strong>>::type 3869 = boost_param_parameters_ ## __LINE__ ## <strong>name</strong>() 3870) 3871{ 3872 return boost_param_impl ## __LINE__ ## <strong>name</strong>( 3873 boost_param_parameters_ ## __LINE__ ## <strong>name</strong>()( 3874 <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/forward">std::forward</a><A0>(a0) 3875 , … 3876 , <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/forward">std::forward</a><A ## <strong>n</strong>>(a ## <strong>n</strong>) 3877 ) 3878 ); 3879} 3880 3881<span class="vellipsis">⋮</span> 3882 3883template <typename A0, …, typename A ## <strong>m</strong>> 3884<strong>result</strong> <strong>name</strong>( 3885 A0&& a0, …, A ## <strong>m</strong>&& a ## <strong>m</strong> 3886 , typename boost_param_parameters_ ## __LINE__ ## <strong>name</strong> 3887 ::match<A0, …, A ## <strong>m</strong>>::type 3888 = boost_param_parameters_ ## __LINE__ ## <strong>name</strong>() 3889) 3890{ 3891 return boost_param_impl ## __LINE__ ## <strong>name</strong>( 3892 boost_param_parameters_ ## __LINE__ ## <strong>name</strong>()( 3893 <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/forward">std::forward</a><A0>(a0) 3894 , … 3895 , <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/forward">std::forward</a><A ## <strong>m</strong>>(a ## <strong>m</strong>) 3896 ) 3897 ); 3898} 3899 3900template <typename Args> 3901typename boost_param_result_ ## __LINE__ ## <strong>name</strong><Args>::type 3902 boost_param_impl ## __LINE__ ## <strong>name</strong>(Args const& args) 3903</pre> 3904<p>Only the <a class="reference internal" href="#argumentpack"><span class="concept">ArgumentPack</span></a> type <tt class="docutils literal">Args</tt> and its object instance <tt class="docutils literal">args</tt> are 3905available for use within the function body.</p> 3906</div> 3907<div class="section" id="boost-parameter-basic-member-function-result-name-tag-ns-arguments"> 3908<span id="boost-parameter-basic-member-function"></span><h2><a class="toc-backref" href="#id64">7.8 <tt class="docutils literal">BOOST_PARAMETER_BASIC_MEMBER_FUNCTION(result, name, tag_ns, arguments)</tt></a></h2> 3909<table class="docutils field-list" frame="void" rules="none"> 3910<col class="field-name" /> 3911<col class="field-body" /> 3912<tbody valign="top"> 3913<tr class="field"><th class="field-name">Defined in:</th><td class="field-body"><a class="reference external" href="../../../../boost/parameter/preprocessor.hpp">boost/parameter/preprocessor.hpp</a></td> 3914</tr> 3915</tbody> 3916</table> 3917<p>Generates a member function that can take in positional arguments, composed 3918arguments, named arguments, and deduced arguments.</p> 3919<table class="docutils field-list" frame="void" rules="none"> 3920<col class="field-name" /> 3921<col class="field-body" /> 3922<tbody valign="top"> 3923<tr class="field"><th class="field-name">Example usage:</th><td class="field-body"></td> 3924</tr> 3925</tbody> 3926</table> 3927<p>The return type of each of the following function templates falls under a 3928different value category.</p> 3929<pre class="literal-block"> 3930template <std::size_t N> 3931<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1> rvalue_bitset() 3932{ 3933 return <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1>(); 3934} 3935 3936template <std::size_t N> 3937<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1> const rvalue_const_bitset() 3938{ 3939 return <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1>(); 3940} 3941 3942template <std::size_t N> 3943<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1>& lvalue_bitset() 3944{ 3945 static <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1> lset = <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1>(); 3946 return lset; 3947} 3948 3949template <std::size_t N> 3950<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1> const& lvalue_const_bitset() 3951{ 3952 static <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1> const clset = <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1>(); 3953 return clset; 3954} 3955</pre> 3956<p>The <tt class="docutils literal"><span class="pre">U::evaluate_category</span></tt> static member function template has a simple job: 3957to return the correct value category when passed in an object returned by one 3958of the functions defined above. Assume that 3959<a class="reference internal" href="#boost-parameter-has-perfect-forwarding"><tt class="docutils literal">BOOST_PARAMETER_HAS_PERFECT_FORWARDING</tt></a> is defined.</p> 3960<pre class="literal-block"> 3961enum invoked 3962{ 3963 passed_by_lvalue_reference_to_const 3964 , passed_by_lvalue_reference 3965 , passed_by_rvalue_reference_to_const 3966 , passed_by_rvalue_reference 3967}; 3968 3969struct U 3970{ 3971 template <std::size_t N> 3972 static invoked evaluate_category(<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1> const&) 3973 { 3974 return passed_by_lvalue_reference_to_const; 3975 } 3976 3977 template <std::size_t N> 3978 static invoked evaluate_category(<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1>&) 3979 { 3980 return passed_by_lvalue_reference; 3981 } 3982 3983 template <std::size_t N> 3984 static invoked evaluate_category(<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1> const&&) 3985 { 3986 return passed_by_rvalue_reference_to_const; 3987 } 3988 3989 template <std::size_t N> 3990 static invoked evaluate_category(<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1>&&) 3991 { 3992 return passed_by_rvalue_reference; 3993 } 3994}; 3995</pre> 3996<p>Define the named parameters that will comprise the argument specification that 3997this macro will use. Ensure that all their tag types are in the same 3998namespace, which is <tt class="docutils literal">kw</tt> in this case. The identifiers with leading 3999underscores can be passed to the bracket operator of <tt class="docutils literal">args</tt> to extract the 4000same argument to which the corresponding named parameter (without underscores) 4001is bound, as will be shown later.</p> 4002<pre class="literal-block"> 4003<a class="reference internal" href="#boost-parameter-name"><tt class="docutils literal">BOOST_PARAMETER_NAME</tt></a>((_lrc, kw) in(lrc)) 4004<a class="reference internal" href="#boost-parameter-name"><tt class="docutils literal">BOOST_PARAMETER_NAME</tt></a>((_lr, kw) in_out(lr)) 4005<a class="reference internal" href="#boost-parameter-name"><tt class="docutils literal">BOOST_PARAMETER_NAME</tt></a>((_rrc, kw) in(rrc)) 4006<a class="reference internal" href="#boost-parameter-name"><tt class="docutils literal">BOOST_PARAMETER_NAME</tt></a>((_rr, kw) consume(rr)) 4007</pre> 4008<p>Use the macro as a substitute for a normal <tt class="docutils literal">static</tt> member function 4009header. Enclose the return type <tt class="docutils literal">bool</tt> in parentheses. For each parameter, 4010also enclose the expected value type in parentheses. Since the value types 4011are mutually exclusive, you can wrap the parameters in a <tt class="docutils literal">(deduced …)</tt> 4012clause. Otherwise, just as with a normal function, the order in which you 4013specify the parameters determines their position. However, unlike a normal 4014function, default values must be specified within the function body. Also 4015within the function body, you must pass the matching identifier with the 4016leading underscore to the bracket operator of <tt class="docutils literal">args</tt> to extract the 4017corresponding argument, but at least this doesn't require <tt class="docutils literal"><span class="pre">std::forward</span></tt> to 4018preserve value categories.</p> 4019<pre class="literal-block"> 4020struct B 4021{ 4022 BOOST_PARAMETER_BASIC_MEMBER_FUNCTION((bool), static evaluate, kw, 4023 (deduced 4024 (required 4025 (lrc, (<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><1>)) 4026 (lr, (<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><2>)) 4027 ) 4028 (optional 4029 (rrc, (<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><3>)) 4030 (rr, (<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><4>)) 4031 ) 4032 ) 4033 ) 4034 { 4035 BOOST_TEST_EQ( 4036 passed_by_lvalue_reference_to_const 4037 , U::evaluate_category<0>(args[_lrc]) 4038 ); 4039 BOOST_TEST_EQ( 4040 passed_by_lvalue_reference 4041 , U::evaluate_category<1>(args[_lr]) 4042 ); 4043 BOOST_TEST_EQ( 4044 passed_by_rvalue_reference_to_const 4045 , U::evaluate_category<2>( 4046 args[_rrc0 | rvalue_const_bitset<2>()] 4047 ) 4048 ); 4049 BOOST_TEST_EQ( 4050 passed_by_rvalue_reference 4051 , U::evaluate_category<3>( 4052 args[_rr0 | rvalue_bitset<3>()] 4053 ) 4054 ); 4055 4056 return true; 4057 } 4058}; 4059</pre> 4060<p>The following function calls are legal.</p> 4061<pre class="literal-block"> 4062B::evaluate( // positional arguments 4063 lvalue_const_bitset<0>() 4064 , lvalue_bitset<1>() 4065 , rvalue_const_bitset<2>() 4066 , rvalue_bitset<3>() 4067); 4068B::evaluate( // positional arguments 4069 lvalue_const_bitset<0>() 4070 , lvalue_bitset<1>() 4071); 4072B::evaluate(( // composed arguments 4073 _rr0 = rvalue_bitset<3>() 4074 , _lrc0 = lvalue_const_bitset<0>() 4075 , _lr0 = lvalue_bitset<1>() 4076 , _rrc0 = rvalue_const_bitset<2>() 4077)); 4078B::evaluate( // named arguments 4079 _rr0 = rvalue_bitset<3>() 4080 , _lrc0 = lvalue_const_bitset<0>() 4081 , _lr0 = lvalue_bitset<1>() 4082 , _rrc0 = rvalue_const_bitset<2>() 4083); 4084B::evaluate( // named arguments 4085 _lr0 = lvalue_bitset<1>() 4086 , _lrc0 = lvalue_const_bitset<0>() 4087); 4088</pre> 4089<p>Because the parameters were wrapped in a <tt class="docutils literal">(deduced …)</tt> clause, the following 4090function calls are also legal.</p> 4091<pre class="literal-block"> 4092B::evaluate( // deduced arguments 4093 rvalue_bitset<3>() 4094 , lvalue_const_bitset<0>() 4095 , lvalue_bitset<1>() 4096 , rvalue_const_bitset<2>() 4097); 4098B::evaluate( // deduced arguments 4099 lvalue_bitset<1>() 4100 , lvalue_const_bitset<0>() 4101); 4102</pre> 4103<p>The <a class="reference external" href="../../test/preprocessor.cpp">preprocessor.cpp</a> test program demonstrates proper usage of this macro.</p> 4104<p><strong>Macro parameters:</strong></p> 4105<ul class="simple"> 4106<li><tt class="docutils literal">result</tt> is the parenthesized return type of the function.</li> 4107<li><tt class="docutils literal">name</tt> is the base name of the function; it determines the name of the 4108generated forwarding functions. <tt class="docutils literal">name</tt> may be qualified by the 4109<tt class="docutils literal">static</tt> keyword to declare the member function and its helpers as not 4110associated with any object of the enclosing type.</li> 4111<li><tt class="docutils literal">tag_namespace</tt> is the namespace in which the keywords used by the 4112function resides.</li> 4113<li><tt class="docutils literal">arguments</tt> is a <a class="reference external" href="../../../preprocessor/doc/index.html">Boost.Preprocessor</a> <a class="reference external" href="../../../preprocessor/doc/data/sequences.html">sequence</a> of 4114<em>argument-specifiers</em>, as defined below.</li> 4115</ul> 4116<p><strong>Argument specifiers syntax:</strong></p> 4117<pre class="literal-block"> 4118argument-specifiers ::= <em>specifier-group0</em> {<em>specifier-group0</em>} 4119 4120specifier-group0 ::= <em>specifier-group1</em> | 4121 ( 4122 '<strong>(</strong>' '<strong>deduced</strong>' 4123 <em>specifier-group1</em> {<em>specifier-group1</em>} 4124 '<strong>)</strong>' 4125 ) 4126 4127specifier-group1 ::= 4128 ( 4129 '<strong>(</strong>' '<strong>optional</strong>' 4130 <em>specifier</em> {<em>specifier</em>} 4131 '<strong>)</strong>' 4132 ) | ( 4133 '<strong>(</strong>' '<strong>required</strong>' 4134 <em>specifier</em> {<em>specifier</em>} 4135 '<strong>)</strong>' 4136 ) 4137 4138specifier ::= 4139 '<strong>(</strong>' <em>argument-name</em> '<strong>,</strong>' <em>restriction</em> ')' 4140 4141restriction ::= 4142 ( '<strong>*</strong>' '<strong>(</strong>' <em>mfc</em> '<strong>)</strong>' ) | 4143 ( '<strong>(</strong>' <em>type-name</em> '<strong>)</strong>' ) | 4144 '<strong>*</strong>' 4145</pre> 4146<ul class="simple"> 4147<li><tt class="docutils literal"><span class="pre">argument-name</span></tt> is any valid C++ identifier.</li> 4148<li><tt class="docutils literal">mfc</tt> is an <a class="reference external" href="../../../mpl/doc/refmanual/metafunction-class.html">MPL Binary Metafunction Class</a> whose first argument will 4149be the type of the corresponding <tt class="docutils literal"><span class="pre">argument-name</span></tt>, whose second argument 4150will be the entire <a class="reference internal" href="#argumentpack"><span class="concept">ArgumentPack</span></a>, and whose return type is a <a class="reference external" href="../../../mpl/doc/refmanual/integral-constant.html">Boolean 4151Integral Constant</a>; however, user code <em>cannot</em> compute <tt class="docutils literal">mfc</tt> in terms 4152of <tt class="docutils literal"><span class="pre">previous-name</span> ## _type</tt>.</li> 4153<li><tt class="docutils literal"><span class="pre">type-name</span></tt> is either the name of a <strong>target type</strong> or an <a class="reference external" href="../../../mpl/doc/refmanual/metafunction-class.html">MPL Binary 4154Metafunction Class</a> whose first argument will be the type of the 4155corresponding <tt class="docutils literal"><span class="pre">argument-name</span></tt>, whose second argument will be the entire 4156<a class="reference internal" href="#argumentpack"><span class="concept">ArgumentPack</span></a>, and whose return type is the <strong>target type</strong>.</li> 4157</ul> 4158<p>Note that <em>specifier</em> does not include <em>default-value</em>. It is up to the 4159function body to determine the default value of all optional arguments.</p> 4160<p><strong>Approximate expansion:</strong></p> 4161<p>Where:</p> 4162<ul class="simple"> 4163<li><tt class="docutils literal">n</tt> denotes the <em>minimum</em> arity, as determined from <tt class="docutils literal">arguments</tt>.</li> 4164<li><tt class="docutils literal">m</tt> denotes the <em>maximum</em> arity, as determined from <tt class="docutils literal">arguments</tt>.</li> 4165</ul> 4166<pre class="literal-block"> 4167// If <strong>result</strong> is a template instantiation of <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::enable_if</a>, 4168// <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::enable_if_c</a>, <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::lazy_enable_if</a>, 4169// <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::lazy_enable_if_c</a>, <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::disable_if</a>, <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::disable_if_c</a>, 4170// <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::lazy_disable_if</a>, <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::lazy_disable_if_c</a>, or 4171// <a class="reference external" href="http://en.cppreference.com/w/cpp/types/enable_if">std::enable_if</a>: 4172template <typename Args> 4173using boost_param_result_ ## __LINE__ ## <strong>name</strong> = <strong>result</strong>; 4174 4175// If <strong>result</strong> is a simple return type: 4176template <typename Args> 4177struct boost_param_result_ ## __LINE__ ## <strong>name</strong> 4178{ 4179 typedef <strong>result</strong> type; 4180}; 4181 4182struct boost_param_params_ ## __LINE__ ## <strong>name</strong> 4183 : <a class="reference internal" href="#parameters"><tt class="docutils literal">parameters</tt></a>< 4184 <em>list of parameter specifications, based on arguments</em> 4185 > 4186{ 4187}; 4188 4189typedef boost_param_params_ ## __LINE__ ## <strong>name</strong> 4190 boost_param_parameters_ ## __LINE__ ## <strong>name</strong>; 4191 4192template <typename A0, …, typename A ## <strong>n</strong>> 4193<strong>result</strong> <strong>name</strong>( 4194 A0&& a0, …, A ## <strong>n</strong>&& a ## <strong>n</strong> 4195 , typename boost_param_parameters_ ## __LINE__ ## <strong>name</strong> 4196 ::match<A0, …, A ## <strong>n</strong>>::type 4197 = boost_param_parameters_ ## __LINE__ ## <strong>name</strong>() 4198) 4199{ 4200 return this->boost_param_impl ## <strong>name</strong>( 4201 boost_param_parameters_ ## __LINE__ ## <strong>name</strong>()( 4202 <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/forward">std::forward</a><A0>(a0) 4203 , … 4204 , <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/forward">std::forward</a><A ## <strong>n</strong>>(a ## <strong>n</strong>) 4205 ) 4206 ); 4207} 4208 4209<span class="vellipsis">⋮</span> 4210 4211template <typename A0, …, typename A ## <strong>m</strong>> 4212<strong>result</strong> <strong>name</strong>( 4213 A0&& a0, …, A ## <strong>m</strong>&& a ## <strong>m</strong> 4214 , typename boost_param_parameters_ ## __LINE__ ## <strong>name</strong> 4215 ::match<A0, …, A ## <strong>m</strong>>::type 4216 = boost_param_parameters_ ## __LINE__ ## <strong>name</strong>() 4217) 4218{ 4219 return this->boost_param_impl ## <strong>name</strong>( 4220 boost_param_parameters_ ## __LINE__ ## <strong>name</strong>()( 4221 <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/forward">std::forward</a><A0>(a0) 4222 , … 4223 , <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/forward">std::forward</a><A ## <strong>m</strong>>(a ## <strong>m</strong>) 4224 ) 4225 ); 4226} 4227 4228template <typename Args> 4229typename boost_param_result_ ## __LINE__ ## <strong>name</strong><Args>::type 4230 boost_param_impl ## <strong>name</strong>(Args const& args) 4231</pre> 4232<p>Only the <a class="reference internal" href="#argumentpack"><span class="concept">ArgumentPack</span></a> type <tt class="docutils literal">Args</tt> and its object instance <tt class="docutils literal">args</tt> are 4233available for use within the function body.</p> 4234</div> 4235<div class="section" id="boost-parameter-basic-const-member-function-result-name-tag-ns-args"> 4236<span id="boost-parameter-basic-const-member-function"></span><h2><a class="toc-backref" href="#id65">7.9 <tt class="docutils literal">BOOST_PARAMETER_BASIC_CONST_MEMBER_FUNCTION(result, name, tag_ns, args)</tt></a></h2> 4237<table class="docutils field-list" frame="void" rules="none"> 4238<col class="field-name" /> 4239<col class="field-body" /> 4240<tbody valign="top"> 4241<tr class="field"><th class="field-name">Defined in:</th><td class="field-body"><a class="reference external" href="../../../../boost/parameter/preprocessor.hpp">boost/parameter/preprocessor.hpp</a></td> 4242</tr> 4243</tbody> 4244</table> 4245<p>Generates a member function that can take in positional arguments, composed 4246arguments, named arguments, and deduced arguments.</p> 4247<table class="docutils field-list" frame="void" rules="none"> 4248<col class="field-name" /> 4249<col class="field-body" /> 4250<tbody valign="top"> 4251<tr class="field"><th class="field-name">Example usage:</th><td class="field-body"></td> 4252</tr> 4253</tbody> 4254</table> 4255<p>The return type of each of the following function templates falls under a 4256different value category.</p> 4257<pre class="literal-block"> 4258template <std::size_t N> 4259<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1> rvalue_bitset() 4260{ 4261 return <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1>(); 4262} 4263 4264template <std::size_t N> 4265<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1> const rvalue_const_bitset() 4266{ 4267 return <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1>(); 4268} 4269 4270template <std::size_t N> 4271<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1>& lvalue_bitset() 4272{ 4273 static <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1> lset = <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1>(); 4274 return lset; 4275} 4276 4277template <std::size_t N> 4278<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1> const& lvalue_const_bitset() 4279{ 4280 static <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1> const clset = <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1>(); 4281 return clset; 4282} 4283</pre> 4284<p>The <tt class="docutils literal"><span class="pre">U::evaluate_category</span></tt> static member function template has a simple job: 4285to return the correct value category when passed in an object returned by one 4286of the functions defined above. Assume that 4287<a class="reference internal" href="#boost-parameter-has-perfect-forwarding"><tt class="docutils literal">BOOST_PARAMETER_HAS_PERFECT_FORWARDING</tt></a> is defined.</p> 4288<pre class="literal-block"> 4289enum invoked 4290{ 4291 passed_by_lvalue_reference_to_const 4292 , passed_by_lvalue_reference 4293 , passed_by_rvalue_reference_to_const 4294 , passed_by_rvalue_reference 4295}; 4296 4297struct U 4298{ 4299 template <std::size_t N> 4300 static invoked evaluate_category(<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1> const&) 4301 { 4302 return passed_by_lvalue_reference_to_const; 4303 } 4304 4305 template <std::size_t N> 4306 static invoked evaluate_category(<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1>&) 4307 { 4308 return passed_by_lvalue_reference; 4309 } 4310 4311 template <std::size_t N> 4312 static invoked evaluate_category(<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1> const&&) 4313 { 4314 return passed_by_rvalue_reference_to_const; 4315 } 4316 4317 template <std::size_t N> 4318 static invoked evaluate_category(<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1>&&) 4319 { 4320 return passed_by_rvalue_reference; 4321 } 4322}; 4323</pre> 4324<p>Define the named parameters that will comprise the argument specification that 4325this macro will use. Ensure that all their tag types are in the same 4326namespace, which is <tt class="docutils literal">kw</tt> in this case. The identifiers with leading 4327underscores can be passed to the bracket operator of <tt class="docutils literal">args</tt> to extract the 4328same argument to which the corresponding named parameter (without underscores) 4329is bound, as will be shown later.</p> 4330<pre class="literal-block"> 4331<a class="reference internal" href="#boost-parameter-name"><tt class="docutils literal">BOOST_PARAMETER_NAME</tt></a>((_lrc, kw) in(lrc)) 4332<a class="reference internal" href="#boost-parameter-name"><tt class="docutils literal">BOOST_PARAMETER_NAME</tt></a>((_lr, kw) in_out(lr)) 4333<a class="reference internal" href="#boost-parameter-name"><tt class="docutils literal">BOOST_PARAMETER_NAME</tt></a>((_rrc, kw) in(rrc)) 4334<a class="reference internal" href="#boost-parameter-name"><tt class="docutils literal">BOOST_PARAMETER_NAME</tt></a>((_rr, kw) consume(rr)) 4335</pre> 4336<p>Use the macro as a substitute for a normal <tt class="docutils literal">const</tt> member function 4337header. Enclose the return type <tt class="docutils literal">bool</tt> in parentheses. For each parameter, 4338also enclose the expected value type in parentheses. Since the value types 4339are mutually exclusive, you can wrap the parameters in a <tt class="docutils literal">(deduced …)</tt> 4340clause. Otherwise, just as with a normal function, the order in which you 4341specify the parameters determines their position. However, unlike a normal 4342function, default values must be specified within the function body. Also 4343within the function body, you must pass the matching identifier with the 4344leading underscore to the bracket operator of <tt class="docutils literal">args</tt> to extract the 4345corresponding argument, but at least this doesn't require <tt class="docutils literal"><span class="pre">std::forward</span></tt> to 4346preserve value categories.</p> 4347<pre class="literal-block"> 4348struct B 4349{ 4350 B() 4351 { 4352 } 4353 4354 BOOST_PARAMETER_BASIC_CONST_MEMBER_FUNCTION((bool), evaluate, kw, 4355 (deduced 4356 (required 4357 (lrc, (<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><1>)) 4358 (lr, (<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><2>)) 4359 ) 4360 (optional 4361 (rrc, (<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><3>)) 4362 (rr, (<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><4>)) 4363 ) 4364 ) 4365 ) 4366 { 4367 BOOST_TEST_EQ( 4368 passed_by_lvalue_reference_to_const 4369 , U::evaluate_category<0>(args[_lrc]) 4370 ); 4371 BOOST_TEST_EQ( 4372 passed_by_lvalue_reference 4373 , U::evaluate_category<1>(args[_lr]) 4374 ); 4375 BOOST_TEST_EQ( 4376 passed_by_rvalue_reference_to_const 4377 , U::evaluate_category<2>( 4378 args[_rrc0 | rvalue_const_bitset<2>()] 4379 ) 4380 ); 4381 BOOST_TEST_EQ( 4382 passed_by_rvalue_reference 4383 , U::evaluate_category<3>( 4384 args[_rr0 | rvalue_bitset<3>()] 4385 ) 4386 ); 4387 4388 return true; 4389 } 4390}; 4391</pre> 4392<p>The following function calls are legal.</p> 4393<pre class="literal-block"> 4394B const b = B(); 4395b.evaluate( // positional arguments 4396 lvalue_const_bitset<0>() 4397 , lvalue_bitset<1>() 4398 , rvalue_const_bitset<2>() 4399 , rvalue_bitset<3>() 4400); 4401b.evaluate( // positional arguments 4402 lvalue_const_bitset<0>() 4403 , lvalue_bitset<1>() 4404); 4405b.evaluate(( // composed arguments 4406 _rr0 = rvalue_bitset<3>() 4407 , _lrc0 = lvalue_const_bitset<0>() 4408 , _lr0 = lvalue_bitset<1>() 4409 , _rrc0 = rvalue_const_bitset<2>() 4410)); 4411b.evaluate( // named arguments 4412 _rr0 = rvalue_bitset<3>() 4413 , _lrc0 = lvalue_const_bitset<0>() 4414 , _lr0 = lvalue_bitset<1>() 4415 , _rrc0 = rvalue_const_bitset<2>() 4416); 4417b.evaluate( // named arguments 4418 _lr0 = lvalue_bitset<1>() 4419 , _lrc0 = lvalue_const_bitset<0>() 4420); 4421</pre> 4422<p>Because the parameters were wrapped in a <tt class="docutils literal">(deduced …)</tt> clause, the following 4423function calls are also legal.</p> 4424<pre class="literal-block"> 4425b.evaluate( // deduced arguments 4426 rvalue_bitset<3>() 4427 , lvalue_const_bitset<0>() 4428 , lvalue_bitset<1>() 4429 , rvalue_const_bitset<2>() 4430); 4431b.evaluate( // deduced arguments 4432 lvalue_bitset<1>() 4433 , lvalue_const_bitset<0>() 4434); 4435</pre> 4436<p>The <a class="reference external" href="../../test/preprocessor.cpp">preprocessor.cpp</a> test program demonstrates proper usage of this macro.</p> 4437<p><strong>Macro parameters:</strong></p> 4438<ul class="simple"> 4439<li><tt class="docutils literal">result</tt> is the parenthesized return type of the function.</li> 4440<li><tt class="docutils literal">name</tt> is the base name of the function; it determines the name of the 4441generated forwarding functions.</li> 4442<li><tt class="docutils literal">tag_namespace</tt> is the namespace in which the keywords used by the 4443function resides.</li> 4444<li><tt class="docutils literal">arguments</tt> is a <a class="reference external" href="../../../preprocessor/doc/index.html">Boost.Preprocessor</a> <a class="reference external" href="../../../preprocessor/doc/data/sequences.html">sequence</a> of 4445<em>argument-specifiers</em>, as defined below.</li> 4446</ul> 4447<p><strong>Argument specifiers syntax:</strong></p> 4448<pre class="literal-block"> 4449argument-specifiers ::= <em>specifier-group0</em> {<em>specifier-group0</em>} 4450 4451specifier-group0 ::= <em>specifier-group1</em> | 4452 ( 4453 '<strong>(</strong>' '<strong>deduced</strong>' 4454 <em>specifier-group1</em> {<em>specifier-group1</em>} 4455 '<strong>)</strong>' 4456 ) 4457 4458specifier-group1 ::= 4459 ( 4460 '<strong>(</strong>' '<strong>optional</strong>' 4461 <em>specifier</em> {<em>specifier</em>} 4462 '<strong>)</strong>' 4463 ) | ( 4464 '<strong>(</strong>' '<strong>required</strong>' 4465 <em>specifier</em> {<em>specifier</em>} 4466 '<strong>)</strong>' 4467 ) 4468 4469specifier ::= 4470 '<strong>(</strong>' <em>argument-name</em> '<strong>,</strong>' <em>restriction</em> ')' 4471 4472restriction ::= 4473 ( '<strong>*</strong>' '<strong>(</strong>' <em>mfc</em> '<strong>)</strong>' ) | 4474 ( '<strong>(</strong>' <em>type-name</em> '<strong>)</strong>' ) | 4475 '<strong>*</strong>' 4476</pre> 4477<ul class="simple"> 4478<li><tt class="docutils literal"><span class="pre">argument-name</span></tt> is any valid C++ identifier.</li> 4479<li><tt class="docutils literal">mfc</tt> is an <a class="reference external" href="../../../mpl/doc/refmanual/metafunction-class.html">MPL Binary Metafunction Class</a> whose first argument will 4480be the type of the corresponding <tt class="docutils literal"><span class="pre">argument-name</span></tt>, whose second argument 4481will be the entire <a class="reference internal" href="#argumentpack"><span class="concept">ArgumentPack</span></a>, and whose return type is a <a class="reference external" href="../../../mpl/doc/refmanual/integral-constant.html">Boolean 4482Integral Constant</a>; however, user code <em>cannot</em> compute <tt class="docutils literal">mfc</tt> in terms 4483of <tt class="docutils literal"><span class="pre">previous-name</span> ## _type</tt>.</li> 4484<li><tt class="docutils literal"><span class="pre">type-name</span></tt> is either the name of a <strong>target type</strong> or an <a class="reference external" href="../../../mpl/doc/refmanual/metafunction-class.html">MPL Binary 4485Metafunction Class</a> whose first argument will be the type of the 4486corresponding <tt class="docutils literal"><span class="pre">argument-name</span></tt>, whose second argument will be the entire 4487<a class="reference internal" href="#argumentpack"><span class="concept">ArgumentPack</span></a>, and whose return type is the <strong>target type</strong>.</li> 4488</ul> 4489<p>Note that <em>specifier</em> does not include <em>default-value</em>. It is up to the 4490function body to determine the default value of all optional arguments.</p> 4491<p><strong>Approximate expansion:</strong></p> 4492<p>Where:</p> 4493<ul class="simple"> 4494<li><tt class="docutils literal">n</tt> denotes the <em>minimum</em> arity, as determined from <tt class="docutils literal">arguments</tt>.</li> 4495<li><tt class="docutils literal">m</tt> denotes the <em>maximum</em> arity, as determined from <tt class="docutils literal">arguments</tt>.</li> 4496</ul> 4497<pre class="literal-block"> 4498// If <strong>result</strong> is a template instantiation of <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::enable_if</a>, 4499// <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::enable_if_c</a>, <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::lazy_enable_if</a>, 4500// <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::lazy_enable_if_c</a>, <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::disable_if</a>, <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::disable_if_c</a>, 4501// <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::lazy_disable_if</a>, <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::lazy_disable_if_c</a>, or 4502// <a class="reference external" href="http://en.cppreference.com/w/cpp/types/enable_if">std::enable_if</a>: 4503template <typename Args> 4504using boost_param_result_const_ ## __LINE__ ## <strong>name</strong> = <strong>result</strong>; 4505 4506// If <strong>result</strong> is a simple return type: 4507template <typename Args> 4508struct boost_param_result_const_ ## __LINE__ ## <strong>name</strong> 4509{ 4510 typedef <strong>result</strong> type; 4511}; 4512 4513struct boost_param_params_const_ ## __LINE__ ## <strong>name</strong> 4514 : <a class="reference internal" href="#parameters"><tt class="docutils literal">parameters</tt></a>< 4515 <em>list of parameter specifications, based on arguments</em> 4516 > 4517{ 4518}; 4519 4520typedef boost_param_params_const_ ## __LINE__ ## <strong>name</strong> 4521 boost_param_parameters_const_ ## __LINE__ ## <strong>name</strong>; 4522 4523template <typename A0, …, typename A ## <strong>n</strong>> 4524<strong>result</strong> <strong>name</strong>( 4525 A0&& a0, …, A ## <strong>n</strong>&& a ## <strong>n</strong> 4526 , typename boost_param_parameters_const_ ## __LINE__ ## <strong>name</strong> 4527 ::match<A0, …, A ## <strong>n</strong>>::type 4528 = boost_param_parameters_const_ ## __LINE__ ## <strong>name</strong>() 4529) const 4530{ 4531 return this->boost_param_impl_const ## __LINE__ ## <strong>name</strong>( 4532 boost_param_parameters_const_ ## __LINE__ ## <strong>name</strong>()( 4533 <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/forward">std::forward</a><A0>(a0) 4534 , … 4535 , <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/forward">std::forward</a><A ## <strong>n</strong>>(a ## <strong>n</strong>) 4536 ) 4537 ); 4538} 4539 4540<span class="vellipsis">⋮</span> 4541 4542template <typename A0, …, typename A ## <strong>m</strong>> 4543<strong>result</strong> <strong>name</strong>( 4544 A0&& a0, …, A ## <strong>m</strong>&& a ## <strong>m</strong> 4545 , typename boost_param_parameters_const_ ## __LINE__ ## <strong>name</strong> 4546 ::match<A0, …, A ## <strong>m</strong>>::type 4547 = boost_param_parameters_const_ ## __LINE__ ## <strong>name</strong>() 4548) const 4549{ 4550 return this->boost_param_impl_const ## __LINE__ ## <strong>name</strong>( 4551 boost_param_parameters_const_ ## __LINE__ ## <strong>name</strong>()( 4552 <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/forward">std::forward</a><A0>(a0) 4553 , … 4554 , <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/forward">std::forward</a><A ## <strong>m</strong>>(a ## <strong>m</strong>) 4555 ) 4556 ); 4557} 4558 4559template <typename Args> 4560typename boost_param_result_const_ ## __LINE__ ## <strong>name</strong><Args>::type 4561 boost_param_impl_const ## __LINE__ ## <strong>name</strong>(Args const& args) const 4562</pre> 4563<p>Only the <a class="reference internal" href="#argumentpack"><span class="concept">ArgumentPack</span></a> type <tt class="docutils literal">Args</tt> and its object instance <tt class="docutils literal">args</tt> are 4564available for use within the function body.</p> 4565</div> 4566<div class="section" id="boost-parameter-basic-function-call-operator-result-tag-ns-arguments"> 4567<span id="boost-parameter-basic-function-call-operator"></span><h2><a class="toc-backref" href="#id66">7.10 <tt class="docutils literal">BOOST_PARAMETER_BASIC_FUNCTION_CALL_OPERATOR(result, tag_ns, arguments)</tt></a></h2> 4568<table class="docutils field-list" frame="void" rules="none"> 4569<col class="field-name" /> 4570<col class="field-body" /> 4571<tbody valign="top"> 4572<tr class="field"><th class="field-name">Defined in:</th><td class="field-body"><a class="reference external" href="../../../../boost/parameter/preprocessor.hpp">boost/parameter/preprocessor.hpp</a></td> 4573</tr> 4574</tbody> 4575</table> 4576<p>Generates a function call operator that can take in positional arguments, 4577composed arguments, named arguments, and deduced arguments.</p> 4578<table class="docutils field-list" frame="void" rules="none"> 4579<col class="field-name" /> 4580<col class="field-body" /> 4581<tbody valign="top"> 4582<tr class="field"><th class="field-name">Example usage:</th><td class="field-body"></td> 4583</tr> 4584</tbody> 4585</table> 4586<p>Define the named parameters that will comprise the argument specification that 4587this macro will use. Ensure that all their tag types are in the same 4588namespace, which is <tt class="docutils literal">tag</tt> by default.</p> 4589<pre class="literal-block"> 4590<a class="reference internal" href="#boost-parameter-name"><tt class="docutils literal">BOOST_PARAMETER_NAME</tt></a>(y) 4591<a class="reference internal" href="#boost-parameter-name"><tt class="docutils literal">BOOST_PARAMETER_NAME</tt></a>(z) 4592</pre> 4593<p>Use the macro as a substitute for a normal function call operator 4594header. Enclose the return type in parentheses. For each parameter, also 4595enclose the expected value type in parentheses. Since the value types are 4596mutually exclusive, you can wrap the parameters in a <tt class="docutils literal">(deduced …)</tt> 4597clause. This is especially useful when implementing multiple 4598Boost.Parameter-enabled function call operator overloads.</p> 4599<pre class="literal-block"> 4600class char_reader 4601{ 4602 int index; 4603 char const* key; 4604 4605 public: 4606 explicit char_reader(char const* k) : index(0), key(k) 4607 { 4608 } 4609 4610 BOOST_PARAMETER_BASIC_FUNCTION_CALL_OPERATOR((void), tag, 4611 (deduced 4612 (required 4613 (y, (int)) 4614 (z, (char const*)) 4615 ) 4616 ) 4617 ) 4618 { 4619 this->index = args[_y]; 4620 this->key = args[_z]; 4621 } 4622 4623 <a class="reference internal" href="#boost-parameter-basic-const-function-call-operator"><tt class="docutils literal">BOOST_PARAMETER_BASIC_CONST_FUNCTION_CALL_OPERATOR</tt></a>((char), tag, 4624 (deduced 4625 (required 4626 (y, (bool)) 4627 (z, (<a class="reference external" href="http://en.cppreference.com/w/cpp/container/map">std::map</a><char const*, <a class="reference external" href="http://en.cppreference.com/w/cpp/string/basic_string">std::string</a>>)) 4628 ) 4629 ) 4630 ) 4631 { 4632 return args[_y] ? ( 4633 (args[_z].find(this->key)->second)[this->index] 4634 ) : this->key[this->index]; 4635 } 4636}; 4637</pre> 4638<p>As with regular argument-dependent lookup, the value types of the arguments 4639passed in determine which function call operator overload gets invoked.</p> 4640<pre class="literal-block"> 4641char const* keys[] = {"foo", "bar", "baz"}; 4642<a class="reference external" href="http://en.cppreference.com/w/cpp/container/map">std::map</a><char const*, <a class="reference external" href="http://en.cppreference.com/w/cpp/string/basic_string">std::string</a>> k2s; 4643k2s[keys[0]] = <a class="reference external" href="http://en.cppreference.com/w/cpp/string/basic_string">std::string</a>("qux"); 4644k2s[keys[1]] = <a class="reference external" href="http://en.cppreference.com/w/cpp/string/basic_string">std::string</a>("wmb"); 4645k2s[keys[2]] = <a class="reference external" href="http://en.cppreference.com/w/cpp/string/basic_string">std::string</a>("zxc"); 4646char_reader r(keys[0]); 4647 4648// positional arguments 4649BOOST_TEST_EQ('q', (r(true, k2s))); 4650BOOST_TEST_EQ('f', (r(false, k2s))); 4651 4652// named arguments 4653r(_z = keys[1], _y = 1); 4654BOOST_TEST_EQ('m', (r(_z = k2s, _y = true))); 4655BOOST_TEST_EQ('a', (r(_z = k2s, _y = false))); 4656 4657// deduced arguments 4658r(keys[2], 2); 4659BOOST_TEST_EQ('c', (r(k2s, true))); 4660BOOST_TEST_EQ('z', (r(k2s, false))); 4661</pre> 4662<p>The <a class="reference external" href="../../test/preprocessor.cpp">preprocessor.cpp</a> test program demonstrates proper usage of this macro.</p> 4663<p><strong>Macro parameters:</strong></p> 4664<ul class="simple"> 4665<li><tt class="docutils literal">result</tt> is the parenthesized return type of the function call operator.</li> 4666<li><tt class="docutils literal">tag_namespace</tt> is the namespace in which the keywords used by the 4667function call operator resides.</li> 4668<li><tt class="docutils literal">arguments</tt> is a <a class="reference external" href="../../../preprocessor/doc/index.html">Boost.Preprocessor</a> <a class="reference external" href="../../../preprocessor/doc/data/sequences.html">sequence</a> of 4669<em>argument-specifiers</em>, as defined below.</li> 4670</ul> 4671<p><strong>Argument specifiers syntax:</strong></p> 4672<pre class="literal-block"> 4673argument-specifiers ::= <em>specifier-group0</em> {<em>specifier-group0</em>} 4674 4675specifier-group0 ::= <em>specifier-group1</em> | 4676 ( 4677 '<strong>(</strong>' '<strong>deduced</strong>' 4678 <em>specifier-group1</em> {<em>specifier-group1</em>} 4679 '<strong>)</strong>' 4680 ) 4681 4682specifier-group1 ::= 4683 ( 4684 '<strong>(</strong>' '<strong>optional</strong>' 4685 <em>specifier</em> {<em>specifier</em>} 4686 '<strong>)</strong>' 4687 ) | ( 4688 '<strong>(</strong>' '<strong>required</strong>' 4689 <em>specifier</em> {<em>specifier</em>} 4690 '<strong>)</strong>' 4691 ) 4692 4693specifier ::= 4694 '<strong>(</strong>' <em>argument-name</em> '<strong>,</strong>' <em>restriction</em> ')' 4695 4696restriction ::= 4697 ( '<strong>*</strong>' '<strong>(</strong>' <em>mfc</em> '<strong>)</strong>' ) | 4698 ( '<strong>(</strong>' <em>type-name</em> '<strong>)</strong>' ) | 4699 '<strong>*</strong>' 4700</pre> 4701<ul class="simple"> 4702<li><tt class="docutils literal"><span class="pre">argument-name</span></tt> is any valid C++ identifier.</li> 4703<li><tt class="docutils literal">mfc</tt> is an <a class="reference external" href="../../../mpl/doc/refmanual/metafunction-class.html">MPL Binary Metafunction Class</a> whose first argument will 4704be the type of the corresponding <tt class="docutils literal"><span class="pre">argument-name</span></tt>, whose second argument 4705will be the entire <a class="reference internal" href="#argumentpack"><span class="concept">ArgumentPack</span></a>, and whose return type is a <a class="reference external" href="../../../mpl/doc/refmanual/integral-constant.html">Boolean 4706Integral Constant</a>; however, user code <em>cannot</em> compute <tt class="docutils literal">mfc</tt> in terms 4707of <tt class="docutils literal"><span class="pre">previous-name</span> ## _type</tt>.</li> 4708<li><tt class="docutils literal"><span class="pre">type-name</span></tt> is either the name of a <strong>target type</strong> or an <a class="reference external" href="../../../mpl/doc/refmanual/metafunction-class.html">MPL Binary 4709Metafunction Class</a> whose first argument will be the type of the 4710corresponding <tt class="docutils literal"><span class="pre">argument-name</span></tt>, whose second argument will be the entire 4711<a class="reference internal" href="#argumentpack"><span class="concept">ArgumentPack</span></a>, and whose return type is the <strong>target type</strong>.</li> 4712</ul> 4713<p>Note that <em>specifier</em> does not include <em>default-value</em>. It is up to the 4714function body to determine the default value of all optional arguments.</p> 4715<p><strong>Approximate expansion:</strong></p> 4716<p>Where:</p> 4717<ul class="simple"> 4718<li><tt class="docutils literal">n</tt> denotes the <em>minimum</em> arity, as determined from <tt class="docutils literal">arguments</tt>.</li> 4719<li><tt class="docutils literal">m</tt> denotes the <em>maximum</em> arity, as determined from <tt class="docutils literal">arguments</tt>.</li> 4720</ul> 4721<pre class="literal-block"> 4722// If <strong>result</strong> is a template instantiation of <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::enable_if</a>, 4723// <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::enable_if_c</a>, <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::lazy_enable_if</a>, 4724// <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::lazy_enable_if_c</a>, <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::disable_if</a>, <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::disable_if_c</a>, 4725// <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::lazy_disable_if</a>, <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::lazy_disable_if_c</a>, or 4726// <a class="reference external" href="http://en.cppreference.com/w/cpp/types/enable_if">std::enable_if</a>: 4727template <typename Args> 4728using boost_param_result_ ## __LINE__ ## operator = <strong>result</strong>; 4729 4730// If <strong>result</strong> is a simple return type: 4731template <typename Args> 4732struct boost_param_result_ ## __LINE__ ## operator 4733{ 4734 typedef <strong>result</strong> type; 4735}; 4736 4737struct boost_param_params_ ## __LINE__ ## operator 4738 : <a class="reference internal" href="#parameters"><tt class="docutils literal">parameters</tt></a>< 4739 <em>list of parameter specifications, based on arguments</em> 4740 > 4741{ 4742}; 4743 4744typedef boost_param_params_ ## __LINE__ ## operator 4745 boost_param_parameters_ ## __LINE__ ## operator; 4746 4747template <typename A0, …, typename A ## <strong>n</strong>> 4748<strong>result</strong> operator()( 4749 A0&& a0, …, A ## <strong>n</strong>&& a ## <strong>n</strong> 4750 , typename boost_param_parameters_ ## __LINE__ ## operator::match< 4751 A0, …, A ## <strong>n</strong> 4752 >::type = boost_param_parameters_ ## __LINE__ ## operator() 4753) 4754{ 4755 return this->boost_param_impl ## __LINE__ ## operator( 4756 boost_param_parameters_ ## __LINE__ ## operator()( 4757 <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/forward">std::forward</a><A0>(a0) 4758 , … 4759 , <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/forward">std::forward</a><A ## <strong>n</strong>>(a ## <strong>n</strong>) 4760 ) 4761 ); 4762} 4763 4764<span class="vellipsis">⋮</span> 4765 4766template <typename A0, …, typename A ## <strong>m</strong>> 4767<strong>result</strong> operator()( 4768 A0&& a0, …, A ## <strong>m</strong>&& a ## <strong>m</strong> 4769 , typename boost_param_parameters_ ## __LINE__ ## operator::match< 4770 A0, …, A ## <strong>m</strong> 4771 >::type = boost_param_parameters_ ## __LINE__ ## operator() 4772) 4773{ 4774 return this->boost_param_impl ## __LINE__ ## operator( 4775 boost_param_parameters_ ## __LINE__ ## operator()( 4776 <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/forward">std::forward</a><A0>(a0) 4777 , … 4778 , <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/forward">std::forward</a><A ## <strong>m</strong>>(a ## <strong>m</strong>) 4779 ) 4780 ); 4781} 4782 4783template <typename Args> 4784typename boost_param_result_ ## __LINE__ ## operator<Args>::type 4785 boost_param_impl ## __LINE__ ## operator(Args const& args) 4786</pre> 4787<p>Only the <a class="reference internal" href="#argumentpack"><span class="concept">ArgumentPack</span></a> type <tt class="docutils literal">Args</tt> and its object instance <tt class="docutils literal">args</tt> are 4788available for use within the function call operator body.</p> 4789</div> 4790<div class="section" id="boost-parameter-basic-const-function-call-operator-result-tag-ns-args"> 4791<span id="boost-parameter-basic-const-function-call-operator"></span><h2><a class="toc-backref" href="#id67">7.11 <tt class="docutils literal">BOOST_PARAMETER_BASIC_CONST_FUNCTION_CALL_OPERATOR(result, tag_ns, args)</tt></a></h2> 4792<table class="docutils field-list" frame="void" rules="none"> 4793<col class="field-name" /> 4794<col class="field-body" /> 4795<tbody valign="top"> 4796<tr class="field"><th class="field-name">Defined in:</th><td class="field-body"><a class="reference external" href="../../../../boost/parameter/preprocessor.hpp">boost/parameter/preprocessor.hpp</a></td> 4797</tr> 4798</tbody> 4799</table> 4800<p>Generates a function call operator that can take in positional arguments, 4801composed arguments, named arguments, and deduced arguments.</p> 4802<table class="docutils field-list" frame="void" rules="none"> 4803<col class="field-name" /> 4804<col class="field-body" /> 4805<tbody valign="top"> 4806<tr class="field"><th class="field-name">Example usage:</th><td class="field-body"></td> 4807</tr> 4808</tbody> 4809</table> 4810<p>The return type of each of the following function templates falls under a 4811different value category.</p> 4812<pre class="literal-block"> 4813template <std::size_t N> 4814<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1> rvalue_bitset() 4815{ 4816 return <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1>(); 4817} 4818 4819template <std::size_t N> 4820<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1> const rvalue_const_bitset() 4821{ 4822 return <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1>(); 4823} 4824 4825template <std::size_t N> 4826<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1>& lvalue_bitset() 4827{ 4828 static <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1> lset = <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1>(); 4829 return lset; 4830} 4831 4832template <std::size_t N> 4833<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1> const& lvalue_const_bitset() 4834{ 4835 static <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1> const clset = <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1>(); 4836 return clset; 4837} 4838</pre> 4839<p>The <tt class="docutils literal"><span class="pre">U::evaluate_category</span></tt> static member function template has a simple job: 4840to return the correct value category when passed in an object returned by one 4841of the functions defined above. Assume that 4842<a class="reference internal" href="#boost-parameter-has-perfect-forwarding"><tt class="docutils literal">BOOST_PARAMETER_HAS_PERFECT_FORWARDING</tt></a> is defined.</p> 4843<pre class="literal-block"> 4844enum invoked 4845{ 4846 passed_by_lvalue_reference_to_const 4847 , passed_by_lvalue_reference 4848 , passed_by_rvalue_reference_to_const 4849 , passed_by_rvalue_reference 4850}; 4851 4852struct U 4853{ 4854 template <std::size_t N> 4855 static invoked evaluate_category(<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1> const&) 4856 { 4857 return passed_by_lvalue_reference_to_const; 4858 } 4859 4860 template <std::size_t N> 4861 static invoked evaluate_category(<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1>&) 4862 { 4863 return passed_by_lvalue_reference; 4864 } 4865 4866 template <std::size_t N> 4867 static invoked evaluate_category(<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1> const&&) 4868 { 4869 return passed_by_rvalue_reference_to_const; 4870 } 4871 4872 template <std::size_t N> 4873 static invoked evaluate_category(<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1>&&) 4874 { 4875 return passed_by_rvalue_reference; 4876 } 4877}; 4878</pre> 4879<p>Define the named parameters that will comprise the argument specification that 4880this macro will use. Ensure that all their tag types are in the same 4881namespace, which is <tt class="docutils literal">kw</tt> in this case. The identifiers with leading 4882underscores can be passed to the bracket operator of <tt class="docutils literal">args</tt> to extract the 4883same argument to which the corresponding named parameter (without underscores) 4884is bound, as will be shown later.</p> 4885<pre class="literal-block"> 4886<a class="reference internal" href="#boost-parameter-name"><tt class="docutils literal">BOOST_PARAMETER_NAME</tt></a>((_lrc, kw) in(lrc)) 4887<a class="reference internal" href="#boost-parameter-name"><tt class="docutils literal">BOOST_PARAMETER_NAME</tt></a>((_lr, kw) in_out(lr)) 4888<a class="reference internal" href="#boost-parameter-name"><tt class="docutils literal">BOOST_PARAMETER_NAME</tt></a>((_rrc, kw) in(rrc)) 4889<a class="reference internal" href="#boost-parameter-name"><tt class="docutils literal">BOOST_PARAMETER_NAME</tt></a>((_rr, kw) consume(rr)) 4890</pre> 4891<p>Use the macro as a substitute for a normal <tt class="docutils literal">const</tt> function call operator 4892header. Enclose the return type <tt class="docutils literal">bool</tt> in parentheses. For each parameter, 4893also enclose the expected value type in parentheses. Since the value types 4894are mutually exclusive, you can wrap the parameters in a <tt class="docutils literal">(deduced …)</tt> 4895clause. Otherwise, just as with a normal function, the order in which you 4896specify the parameters determines their position. However, unlike a normal 4897function, default values must be specified within the function body. Also 4898within the function body, you must pass the matching identifier with the 4899leading underscore to the bracket operator of <tt class="docutils literal">args</tt> to extract the 4900corresponding argument, but at least this doesn't require <tt class="docutils literal"><span class="pre">std::forward</span></tt> to 4901preserve value categories.</p> 4902<pre class="literal-block"> 4903struct B 4904{ 4905 B() 4906 { 4907 } 4908 4909 BOOST_PARAMETER_BASIC_CONST_FUNCTION_CALL_OPERATOR((bool), kw, 4910 (deduced 4911 (required 4912 (lrc, (<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><1>)) 4913 (lr, (<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><2>)) 4914 ) 4915 (optional 4916 (rrc, (<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><3>)) 4917 (rr, (<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><4>)) 4918 ) 4919 ) 4920 ) 4921 { 4922 BOOST_TEST_EQ( 4923 passed_by_lvalue_reference_to_const 4924 , U::evaluate_category<0>(args[_lrc]) 4925 ); 4926 BOOST_TEST_EQ( 4927 passed_by_lvalue_reference 4928 , U::evaluate_category<1>(args[_lr]) 4929 ); 4930 BOOST_TEST_EQ( 4931 passed_by_rvalue_reference_to_const 4932 , U::evaluate_category<2>( 4933 args[_rrc0 | rvalue_const_bitset<2>()] 4934 ) 4935 ); 4936 BOOST_TEST_EQ( 4937 passed_by_rvalue_reference 4938 , U::evaluate_category<3>( 4939 args[_rr0 | rvalue_bitset<3>()] 4940 ) 4941 ); 4942 4943 return true; 4944 } 4945}; 4946</pre> 4947<p>The following function calls are legal.</p> 4948<pre class="literal-block"> 4949B const b = B(); 4950b( // positional arguments 4951 lvalue_const_bitset<0>() 4952 , lvalue_bitset<1>() 4953 , rvalue_const_bitset<2>() 4954 , rvalue_bitset<3>() 4955); 4956b( // positional arguments 4957 lvalue_const_bitset<0>() 4958 , lvalue_bitset<1>() 4959); 4960b(( // composed arguments 4961 _rr0 = rvalue_bitset<3>() 4962 , _lrc0 = lvalue_const_bitset<0>() 4963 , _lr0 = lvalue_bitset<1>() 4964 , _rrc0 = rvalue_const_bitset<2>() 4965)); 4966b( // named arguments 4967 _rr0 = rvalue_bitset<3>() 4968 , _lrc0 = lvalue_const_bitset<0>() 4969 , _lr0 = lvalue_bitset<1>() 4970 , _rrc0 = rvalue_const_bitset<2>() 4971); 4972b( // named arguments 4973 _lr0 = lvalue_bitset<1>() 4974 , _lrc0 = lvalue_const_bitset<0>() 4975); 4976</pre> 4977<p>Because the parameters were wrapped in a <tt class="docutils literal">(deduced …)</tt> clause, the following 4978function calls are also legal.</p> 4979<pre class="literal-block"> 4980b( // deduced arguments 4981 rvalue_bitset<3>() 4982 , lvalue_const_bitset<0>() 4983 , lvalue_bitset<1>() 4984 , rvalue_const_bitset<2>() 4985); 4986b( // deduced arguments 4987 lvalue_bitset<1>() 4988 , lvalue_const_bitset<0>() 4989); 4990</pre> 4991<p>The <a class="reference external" href="../../test/preprocessor.cpp">preprocessor.cpp</a> test program demonstrates proper usage of this macro.</p> 4992<p><strong>Macro parameters:</strong></p> 4993<ul class="simple"> 4994<li><tt class="docutils literal">result</tt> is the parenthesized return type of the function call operator.</li> 4995<li><tt class="docutils literal">tag_namespace</tt> is the namespace in which the keywords used by the 4996function call operator resides.</li> 4997<li><tt class="docutils literal">arguments</tt> is a <a class="reference external" href="../../../preprocessor/doc/index.html">Boost.Preprocessor</a> <a class="reference external" href="../../../preprocessor/doc/data/sequences.html">sequence</a> of 4998<em>argument-specifiers</em>, as defined below.</li> 4999</ul> 5000<p><strong>Argument specifiers syntax:</strong></p> 5001<pre class="literal-block"> 5002argument-specifiers ::= <em>specifier-group0</em> {<em>specifier-group0</em>} 5003 5004specifier-group0 ::= <em>specifier-group1</em> | 5005 ( 5006 '<strong>(</strong>' '<strong>deduced</strong>' 5007 <em>specifier-group1</em> {<em>specifier-group1</em>} 5008 '<strong>)</strong>' 5009 ) 5010 5011specifier-group1 ::= 5012 ( 5013 '<strong>(</strong>' '<strong>optional</strong>' 5014 <em>specifier</em> {<em>specifier</em>} 5015 '<strong>)</strong>' 5016 ) | ( 5017 '<strong>(</strong>' '<strong>required</strong>' 5018 <em>specifier</em> {<em>specifier</em>} 5019 '<strong>)</strong>' 5020 ) 5021 5022specifier ::= 5023 '<strong>(</strong>' <em>argument-name</em> '<strong>,</strong>' <em>restriction</em> ')' 5024 5025restriction ::= 5026 ( '<strong>*</strong>' '<strong>(</strong>' <em>mfc</em> '<strong>)</strong>' ) | 5027 ( '<strong>(</strong>' <em>type-name</em> '<strong>)</strong>' ) | 5028 '<strong>*</strong>' 5029</pre> 5030<ul class="simple"> 5031<li><tt class="docutils literal"><span class="pre">argument-name</span></tt> is any valid C++ identifier.</li> 5032<li><tt class="docutils literal">mfc</tt> is an <a class="reference external" href="../../../mpl/doc/refmanual/metafunction-class.html">MPL Binary Metafunction Class</a> whose first argument will 5033be the type of the corresponding <tt class="docutils literal"><span class="pre">argument-name</span></tt>, whose second argument 5034will be the entire <a class="reference internal" href="#argumentpack"><span class="concept">ArgumentPack</span></a>, and whose return type is a <a class="reference external" href="../../../mpl/doc/refmanual/integral-constant.html">Boolean 5035Integral Constant</a>; however, user code <em>cannot</em> compute <tt class="docutils literal">mfc</tt> in terms 5036of <tt class="docutils literal"><span class="pre">previous-name</span> ## _type</tt>.</li> 5037<li><tt class="docutils literal"><span class="pre">type-name</span></tt> is either the name of a <strong>target type</strong> or an <a class="reference external" href="../../../mpl/doc/refmanual/metafunction-class.html">MPL Binary 5038Metafunction Class</a> whose first argument will be the type of the 5039corresponding <tt class="docutils literal"><span class="pre">argument-name</span></tt>, whose second argument will be the entire 5040<a class="reference internal" href="#argumentpack"><span class="concept">ArgumentPack</span></a>, and whose return type is the <strong>target type</strong>.</li> 5041</ul> 5042<p>Note that <em>specifier</em> does not include <em>default-value</em>. It is up to the 5043function body to determine the default value of all optional arguments.</p> 5044<p><strong>Approximate expansion:</strong></p> 5045<p>Where:</p> 5046<ul class="simple"> 5047<li><tt class="docutils literal">n</tt> denotes the <em>minimum</em> arity, as determined from <tt class="docutils literal">arguments</tt>.</li> 5048<li><tt class="docutils literal">m</tt> denotes the <em>maximum</em> arity, as determined from <tt class="docutils literal">arguments</tt>.</li> 5049</ul> 5050<pre class="literal-block"> 5051// If <strong>result</strong> is a template instantiation of <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::enable_if</a>, 5052// <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::enable_if_c</a>, <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::lazy_enable_if</a>, 5053// <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::lazy_enable_if_c</a>, <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::disable_if</a>, <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::disable_if_c</a>, 5054// <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::lazy_disable_if</a>, <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::lazy_disable_if_c</a>, or 5055// <a class="reference external" href="http://en.cppreference.com/w/cpp/types/enable_if">std::enable_if</a>: 5056template <typename Args> 5057using boost_param_result_const_ ## __LINE__ ## operator = <strong>result</strong>; 5058 5059// If <strong>result</strong> is a simple return type: 5060template <typename Args> 5061struct boost_param_result_const_ ## __LINE__ ## operator 5062{ 5063 typedef <strong>result</strong> type; 5064}; 5065 5066struct boost_param_params_const_ ## __LINE__ ## operator 5067 : <a class="reference internal" href="#parameters"><tt class="docutils literal">parameters</tt></a>< 5068 <em>list of parameter specifications, based on arguments</em> 5069 > 5070{ 5071}; 5072 5073typedef boost_param_params_const_ ## __LINE__ ## operator 5074 boost_param_parameters_const_ ## __LINE__ ## operator; 5075 5076template <typename A0, …, typename A ## <strong>n</strong>> 5077<strong>result</strong> operator()( 5078 A0&& a0, …, A ## <strong>n</strong>&& a ## <strong>n</strong> 5079 , typename boost_param_parameters_const_ ## __LINE__ ## operator 5080 ::match<A0, …, A ## <strong>n</strong>>::type 5081 = boost_param_parameters_const_ ## __LINE__ ## operator() 5082) const 5083{ 5084 return this->boost_param_impl_const ## __LINE__ ## operator( 5085 boost_param_parameters_const_ ## __LINE__ ## operator()( 5086 <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/forward">std::forward</a><A0>(a0) 5087 , … 5088 , <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/forward">std::forward</a><A ## <strong>n</strong>>(a ## <strong>n</strong>) 5089 ) 5090 ); 5091} 5092 5093<span class="vellipsis">⋮</span> 5094 5095template <typename A0, …, typename A ## <strong>m</strong>> 5096<strong>result</strong> operator()( 5097 A0&& a0, …, A ## <strong>m</strong>&& a ## <strong>m</strong> 5098 , typename boost_param_parameters_const_ ## __LINE__ ## operator 5099 ::match<A0, …, A ## <strong>m</strong>>::type 5100 = boost_param_parameters_const_ ## __LINE__ ## operator() 5101) const 5102{ 5103 return this->boost_param_impl_const ## __LINE__ ## operator( 5104 boost_param_parameters_const_ ## __LINE__ ## operator()( 5105 <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/forward">std::forward</a><A0>(a0) 5106 , … 5107 , <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/forward">std::forward</a><A ## <strong>m</strong>>(a ## <strong>m</strong>) 5108 ) 5109 ); 5110} 5111 5112template <typename Args> 5113typename boost_param_result_const_ ## __LINE__ ## operator<Args>::type 5114 boost_param_impl_const ## __LINE__ ## operator(Args const& args) const 5115</pre> 5116<p>Only the <a class="reference internal" href="#argumentpack"><span class="concept">ArgumentPack</span></a> type <tt class="docutils literal">Args</tt> and its object instance <tt class="docutils literal">args</tt> are 5117available for use within the function call operator body.</p> 5118</div> 5119<div class="section" id="boost-parameter-no-spec-function-result-name"> 5120<span id="boost-parameter-no-spec-function"></span><h2><a class="toc-backref" href="#id68">7.12 <tt class="docutils literal">BOOST_PARAMETER_NO_SPEC_FUNCTION(result, name)</tt></a></h2> 5121<table class="docutils field-list" frame="void" rules="none"> 5122<col class="field-name" /> 5123<col class="field-body" /> 5124<tbody valign="top"> 5125<tr class="field"><th class="field-name">Defined in:</th><td class="field-body"><a class="reference external" href="../../../../boost/parameter/preprocessor_no_spec.hpp">boost/parameter/preprocessor_no_spec.hpp</a></td> 5126</tr> 5127</tbody> 5128</table> 5129<p>Generates a function that can take in named arguments.</p> 5130<table class="docutils field-list" frame="void" rules="none"> 5131<col class="field-name" /> 5132<col class="field-body" /> 5133<tbody valign="top"> 5134<tr class="field"><th class="field-name">Example usage:</th><td class="field-body"></td> 5135</tr> 5136</tbody> 5137</table> 5138<p>The return type of each of the following function templates falls under a 5139different value category.</p> 5140<pre class="literal-block"> 5141template <std::size_t N> 5142<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1> rvalue_bitset() 5143{ 5144 return <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1>(); 5145} 5146 5147template <std::size_t N> 5148<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1> const rvalue_const_bitset() 5149{ 5150 return <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1>(); 5151} 5152 5153template <std::size_t N> 5154<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1>& lvalue_bitset() 5155{ 5156 static <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1> lset = <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1>(); 5157 return lset; 5158} 5159 5160template <std::size_t N> 5161<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1> const& lvalue_const_bitset() 5162{ 5163 static <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1> const clset = <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1>(); 5164 return clset; 5165} 5166</pre> 5167<p>The <tt class="docutils literal"><span class="pre">U::evaluate_category</span></tt> static member function template has a simple job: 5168to return the correct value category when passed in an object returned by one 5169of the functions defined above. Assume that 5170<a class="reference internal" href="#boost-parameter-has-perfect-forwarding"><tt class="docutils literal">BOOST_PARAMETER_HAS_PERFECT_FORWARDING</tt></a> is defined.</p> 5171<pre class="literal-block"> 5172enum invoked 5173{ 5174 passed_by_lvalue_reference_to_const 5175 , passed_by_lvalue_reference 5176 , passed_by_rvalue_reference_to_const 5177 , passed_by_rvalue_reference 5178}; 5179 5180struct U 5181{ 5182 template <std::size_t N> 5183 static invoked evaluate_category(<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1> const&) 5184 { 5185 return passed_by_lvalue_reference_to_const; 5186 } 5187 5188 template <std::size_t N> 5189 static invoked evaluate_category(<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1>&) 5190 { 5191 return passed_by_lvalue_reference; 5192 } 5193 5194 template <std::size_t N> 5195 static invoked evaluate_category(<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1> const&&) 5196 { 5197 return passed_by_rvalue_reference_to_const; 5198 } 5199 5200 template <std::size_t N> 5201 static invoked evaluate_category(<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1>&&) 5202 { 5203 return passed_by_rvalue_reference; 5204 } 5205}; 5206</pre> 5207<p>Named parameters are required when invoking the function; however, none of 5208their tags need to be in the same namespace.</p> 5209<pre class="literal-block"> 5210<a class="reference internal" href="#boost-parameter-name"><tt class="docutils literal">BOOST_PARAMETER_NAME</tt></a>((_lrc, kw0) in(lrc)) 5211<a class="reference internal" href="#boost-parameter-name"><tt class="docutils literal">BOOST_PARAMETER_NAME</tt></a>((_lr, kw1) in_out(lr)) 5212<a class="reference internal" href="#boost-parameter-name"><tt class="docutils literal">BOOST_PARAMETER_NAME</tt></a>((_rrc, kw2) in(rrc)) 5213<a class="reference internal" href="#boost-parameter-name"><tt class="docutils literal">BOOST_PARAMETER_NAME</tt></a>((_rr, kw3) consume(rr)) 5214</pre> 5215<p>Use the macro as a substitute for a variadic function header. Enclose the 5216return type <tt class="docutils literal">bool</tt> in parentheses.</p> 5217<pre class="literal-block"> 5218BOOST_PARAMETER_NO_SPEC_FUNCTION((bool), evaluate) 5219{ 5220 BOOST_TEST_EQ( 5221 passed_by_lvalue_reference_to_const 5222 , U::evaluate_category<0>(args[_lrc]) 5223 ); 5224 BOOST_TEST_EQ( 5225 passed_by_lvalue_reference 5226 , U::evaluate_category<1>(args[_lr]) 5227 ); 5228 BOOST_TEST_EQ( 5229 passed_by_rvalue_reference_to_const 5230 , U::evaluate_category<2>( 5231 args[_rrc | rvalue_const_bitset<2>()] 5232 ) 5233 ); 5234 BOOST_TEST_EQ( 5235 passed_by_rvalue_reference 5236 , U::evaluate_category<3>(args[_rr | rvalue_bitset<3>()]) 5237 ); 5238 5239 return true; 5240} 5241</pre> 5242<p>To invoke the function, bind all its arguments to named parameters.</p> 5243<pre class="literal-block"> 5244evaluate( 5245 _rr0 = rvalue_bitset<3>() 5246 , _lrc0 = lvalue_const_bitset<0>() 5247 , _lr0 = lvalue_bitset<1>() 5248 , _rrc0 = rvalue_const_bitset<2>() 5249); 5250evaluate( 5251 _lr0 = lvalue_bitset<1>() 5252 , _lrc0 = lvalue_const_bitset<0>() 5253); 5254</pre> 5255<p>The <a class="reference external" href="../../test/preprocessor_eval_cat_no_spec.cpp">preprocessor_eval_cat_no_spec.cpp</a> test program demonstrates proper usage of 5256this macro.</p> 5257<p><strong>Macro parameters:</strong></p> 5258<ul class="simple"> 5259<li><tt class="docutils literal">result</tt> is the parenthesized return type of the function.</li> 5260<li><tt class="docutils literal">name</tt> is the base name of the function; it determines the name of the 5261generated implementation function.</li> 5262</ul> 5263<p><strong>Argument specifiers syntax:</strong></p> 5264<p>None.</p> 5265<p><strong>Approximate expansion:</strong></p> 5266<pre class="literal-block"> 5267// If <strong>result</strong> is a template instantiation of <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::enable_if</a>, 5268// <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::enable_if_c</a>, <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::lazy_enable_if</a>, 5269// <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::lazy_enable_if_c</a>, <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::disable_if</a>, <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::disable_if_c</a>, 5270// <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::lazy_disable_if</a>, <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::lazy_disable_if_c</a>, or 5271// <a class="reference external" href="http://en.cppreference.com/w/cpp/types/enable_if">std::enable_if</a>: 5272template <typename TaggedArg0, typename ...TaggedArgs> 5273using boost_param_no_spec_result_ ## __LINE__ ## <strong>name</strong> = <strong>result</strong>; 5274 5275// If <strong>result</strong> is a simple return type: 5276template <typename TaggedArg0, typename ...TaggedArgs> 5277struct boost_param_no_spec_result_ ## __LINE__ ## <strong>name</strong> 5278{ 5279 typedef <strong>result</strong> type; 5280}; 5281 5282template <typename ResultType, typename Args> 5283ResultType 5284 boost_param_no_spec_impl ## __LINE__ ## <strong>name</strong>( 5285 (ResultType(*)()) 5286 , Args const& args 5287 ); 5288 5289template <typename TaggedArg0, typename ...TaggedArgs> 5290inline typename <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::lazy_enable_if</a>< 5291 <a class="reference internal" href="#are-tagged-arguments"><tt class="docutils literal">are_tagged_arguments</tt></a><TaggedArg0,TaggedArgs...> 5292 , boost_param_no_spec_result_ ## __LINE__ ## <strong>name</strong>< 5293 TaggedArg0 5294 , TaggedArgs... 5295 > 5296>::type 5297 <strong>name</strong>(TaggedArg0 const& arg0, TaggedArgs const&... args) 5298{ 5299 return boost_param_no_spec_impl ## __LINE__ ## <strong>name</strong>( 5300 static_cast< 5301 typename 5302 boost_param_no_spec_result_ ## __LINE__ ## <strong>name</strong>< 5303 TaggedArg0 5304 , TaggedArgs... 5305 >::type(*)() 5306 >(<a class="reference external" href="http://en.cppreference.com/w/cpp/language/nullptr">std::nullptr</a>) 5307 , <a class="reference internal" href="#compose"><tt class="docutils literal">compose</tt></a>(arg0, args...) 5308 ); 5309} 5310 5311template <typename ResultType, typename Args> 5312ResultType 5313 boost_param_no_spec_impl ## __LINE__ ## <strong>name</strong>( 5314 (ResultType(*)()) 5315 , Args const& args 5316 ) 5317</pre> 5318<p>Only the <a class="reference internal" href="#argumentpack"><span class="concept">ArgumentPack</span></a> type <tt class="docutils literal">Args</tt> and its object instance <tt class="docutils literal">args</tt> are 5319available for use within the function body.</p> 5320</div> 5321<div class="section" id="boost-parameter-no-spec-member-function-result-name"> 5322<span id="boost-parameter-no-spec-member-function"></span><h2><a class="toc-backref" href="#id69">7.13 <tt class="docutils literal">BOOST_PARAMETER_NO_SPEC_MEMBER_FUNCTION(result, name)</tt></a></h2> 5323<table class="docutils field-list" frame="void" rules="none"> 5324<col class="field-name" /> 5325<col class="field-body" /> 5326<tbody valign="top"> 5327<tr class="field"><th class="field-name">Defined in:</th><td class="field-body"><a class="reference external" href="../../../../boost/parameter/preprocessor_no_spec.hpp">boost/parameter/preprocessor_no_spec.hpp</a></td> 5328</tr> 5329</tbody> 5330</table> 5331<p>Generates a member function that can take in named arguments.</p> 5332<table class="docutils field-list" frame="void" rules="none"> 5333<col class="field-name" /> 5334<col class="field-body" /> 5335<tbody valign="top"> 5336<tr class="field"><th class="field-name">Example usage:</th><td class="field-body"></td> 5337</tr> 5338</tbody> 5339</table> 5340<p>When designing a front-end class template whose back-end is configurable via 5341parameterized inheritance, it can be useful to omit argument specifiers from 5342a named-parameter member function so that the delegate member functions of the 5343back-end classes can enforce their own specifications.</p> 5344<pre class="literal-block"> 5345template <typename B> 5346struct frontend : B 5347{ 5348 frontend() : B() 5349 { 5350 } 5351 5352 BOOST_PARAMETER_NO_SPEC_MEMBER_FUNCTION((void), initialize) 5353 { 5354 this->initialize_impl(args); 5355 } 5356}; 5357</pre> 5358<p>Named parameters are required when invoking the member function; however, none 5359of their tags need to be in the same namespace.</p> 5360<pre class="literal-block"> 5361<a class="reference internal" href="#boost-parameter-name"><tt class="docutils literal">BOOST_PARAMETER_NAME</tt></a>(a0) 5362<a class="reference internal" href="#boost-parameter-name"><tt class="docutils literal">BOOST_PARAMETER_NAME</tt></a>(a1) 5363<a class="reference internal" href="#boost-parameter-name"><tt class="docutils literal">BOOST_PARAMETER_NAME</tt></a>(a2) 5364</pre> 5365<p>For this example, each of the back-end class templates requires its own 5366parameter to be present in the argument pack. In practice, such parameters 5367should be optional, with default values.</p> 5368<pre class="literal-block"> 5369template <typename T> 5370class backend0 5371{ 5372 T a0; 5373 5374 public: 5375 backend0() : a0() 5376 { 5377 } 5378 5379 T const& get_a0() const 5380 { 5381 return this->a0; 5382 } 5383 5384 protected: 5385 template <typename ArgPack> 5386 void initialize_impl(ArgPack const& args) 5387 { 5388 this->a0 = args[_a0]; 5389 } 5390}; 5391 5392template <typename B, typename T> 5393class backend1 : public B 5394{ 5395 T a1; 5396 5397 public: 5398 backend1() : B(), a1() 5399 { 5400 } 5401 5402 T const& get_a1() const 5403 { 5404 return this->a1; 5405 } 5406 5407 protected: 5408 template <typename ArgPack> 5409 void initialize_impl(ArgPack const& args) 5410 { 5411 B::initialize_impl(args); 5412 this->a1 = args[_a1]; 5413 } 5414}; 5415 5416template <typename B, typename T> 5417class backend2 : public B 5418{ 5419 T a2; 5420 5421 public: 5422 backend2() : B(), a2() 5423 { 5424 } 5425 5426 T const& get_a2() const 5427 { 5428 return this->a2; 5429 } 5430 5431 protected: 5432 template <typename ArgPack> 5433 void initialize_impl(ArgPack const& args) 5434 { 5435 B::initialize_impl(args); 5436 this->a2 = args[_a2]; 5437 } 5438}; 5439</pre> 5440<p>This example shows that while <tt class="docutils literal">backend0</tt> must always be the root base class 5441template and that <tt class="docutils literal">frontend</tt> must always be the most derived class template, 5442the other back-ends can be chained together in different orders.</p> 5443<pre class="literal-block"> 5444char const* p = "foo"; 5445frontend< 5446 backend2<backend1<backend0<char const*>, char>, int> 5447> composed_obj0; 5448frontend< 5449 backend1<backend2<backend0<char const*>, int>, char> 5450> composed_obj1; 5451composed_obj0.initialize(_a2 = 4, _a1 = ' ', _a0 = p); 5452composed_obj1.initialize(_a0 = p, _a1 = ' ', _a2 = 4); 5453BOOST_TEST_EQ(composed_obj0.get_a0(), composed_obj1.get_a0()); 5454BOOST_TEST_EQ(composed_obj0.get_a1(), composed_obj1.get_a1()); 5455BOOST_TEST_EQ(composed_obj0.get_a2(), composed_obj1.get_a2()); 5456</pre> 5457<p>The <a class="reference external" href="../../test/parameterized_inheritance.cpp">parameterized_inheritance.cpp</a> and <a class="reference external" href="../../test/preprocessor_eval_cat_no_spec.cpp">preprocessor_eval_cat_no_spec.cpp</a> test 5458programs demonstrate proper usage of this macro.</p> 5459<p><strong>Macro parameters:</strong></p> 5460<ul class="simple"> 5461<li><tt class="docutils literal">result</tt> is the parenthesized return type of the function.</li> 5462<li><tt class="docutils literal">name</tt> is the base name of the function; it determines the name of the 5463generated implementation function. <tt class="docutils literal">name</tt> may be qualified by the 5464<tt class="docutils literal">static</tt> keyword to declare the member function and its helpers as not 5465associated with any object of the enclosing type.</li> 5466</ul> 5467<p><strong>Argument specifiers syntax:</strong></p> 5468<p>None.</p> 5469<p><strong>Approximate expansion:</strong></p> 5470<pre class="literal-block"> 5471// If <strong>result</strong> is a template instantiation of <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::enable_if</a>, 5472// <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::enable_if_c</a>, <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::lazy_enable_if</a>, 5473// <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::lazy_enable_if_c</a>, <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::disable_if</a>, <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::disable_if_c</a>, 5474// <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::lazy_disable_if</a>, <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::lazy_disable_if_c</a>, or 5475// <a class="reference external" href="http://en.cppreference.com/w/cpp/types/enable_if">std::enable_if</a>: 5476template <typename TaggedArg0, typename ...TaggedArgs> 5477using boost_param_no_spec_result_ ## __LINE__ ## <strong>name</strong> = <strong>result</strong>; 5478 5479// If <strong>result</strong> is a simple return type: 5480template <typename TaggedArg0, typename ...TaggedArgs> 5481struct boost_param_no_spec_result_ ## __LINE__ ## <strong>name</strong> 5482{ 5483 typedef <strong>result</strong> type; 5484}; 5485 5486template <typename TaggedArg0, typename ...TaggedArgs> 5487inline typename <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::lazy_enable_if</a>< 5488 <a class="reference internal" href="#are-tagged-arguments"><tt class="docutils literal">are_tagged_arguments</tt></a><TaggedArg0,TaggedArgs...> 5489 , boost_param_no_spec_result_ ## __LINE__ ## <strong>name</strong>< 5490 TaggedArg0 5491 , TaggedArgs... 5492 > 5493>::type 5494 <strong>name</strong>(TaggedArg0 const& arg0, TaggedArgs const&... args) 5495{ 5496 return this->boost_param_no_spec_impl ## __LINE__ ## <strong>name</strong>( 5497 static_cast< 5498 typename 5499 boost_param_no_spec_result_ ## __LINE__ ## <strong>name</strong>< 5500 TaggedArg0 5501 , TaggedArgs... 5502 >::type(*)() 5503 >(<a class="reference external" href="http://en.cppreference.com/w/cpp/language/nullptr">std::nullptr</a>) 5504 , <a class="reference internal" href="#compose"><tt class="docutils literal">compose</tt></a>(arg0, args...) 5505 ); 5506} 5507 5508template <typename ResultType, typename Args> 5509ResultType 5510 boost_param_no_spec_impl ## __LINE__ ## <strong>name</strong>( 5511 (ResultType(*)()) 5512 , Args const& args 5513 ) 5514</pre> 5515<p>Only the <a class="reference internal" href="#argumentpack"><span class="concept">ArgumentPack</span></a> type <tt class="docutils literal">Args</tt> and its object instance <tt class="docutils literal">args</tt> are 5516available for use within the function body.</p> 5517</div> 5518<div class="section" id="boost-parameter-no-spec-const-member-function-result-name"> 5519<span id="boost-parameter-no-spec-const-member-function"></span><h2><a class="toc-backref" href="#id70">7.14 <tt class="docutils literal">BOOST_PARAMETER_NO_SPEC_CONST_MEMBER_FUNCTION(result, name)</tt></a></h2> 5520<table class="docutils field-list" frame="void" rules="none"> 5521<col class="field-name" /> 5522<col class="field-body" /> 5523<tbody valign="top"> 5524<tr class="field"><th class="field-name">Defined in:</th><td class="field-body"><a class="reference external" href="../../../../boost/parameter/preprocessor_no_spec.hpp">boost/parameter/preprocessor_no_spec.hpp</a></td> 5525</tr> 5526</tbody> 5527</table> 5528<p>Generates a member function that can take in named arguments.</p> 5529<table class="docutils field-list" frame="void" rules="none"> 5530<col class="field-name" /> 5531<col class="field-body" /> 5532<tbody valign="top"> 5533<tr class="field"><th class="field-name">Example usage:</th><td class="field-body"></td> 5534</tr> 5535</tbody> 5536</table> 5537<p>The return type of each of the following function templates falls under a 5538different value category.</p> 5539<pre class="literal-block"> 5540template <std::size_t N> 5541<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1> rvalue_bitset() 5542{ 5543 return <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1>(); 5544} 5545 5546template <std::size_t N> 5547<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1> const rvalue_const_bitset() 5548{ 5549 return <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1>(); 5550} 5551 5552template <std::size_t N> 5553<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1>& lvalue_bitset() 5554{ 5555 static <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1> lset = <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1>(); 5556 return lset; 5557} 5558 5559template <std::size_t N> 5560<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1> const& lvalue_const_bitset() 5561{ 5562 static <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1> const clset = <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1>(); 5563 return clset; 5564} 5565</pre> 5566<p>The <tt class="docutils literal"><span class="pre">U::evaluate_category</span></tt> static member function template has a simple job: 5567to return the correct value category when passed in an object returned by one 5568of the functions defined above. Assume that 5569<a class="reference internal" href="#boost-parameter-has-perfect-forwarding"><tt class="docutils literal">BOOST_PARAMETER_HAS_PERFECT_FORWARDING</tt></a> is defined.</p> 5570<pre class="literal-block"> 5571enum invoked 5572{ 5573 passed_by_lvalue_reference_to_const 5574 , passed_by_lvalue_reference 5575 , passed_by_rvalue_reference_to_const 5576 , passed_by_rvalue_reference 5577}; 5578 5579struct U 5580{ 5581 template <std::size_t N> 5582 static invoked evaluate_category(<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1> const&) 5583 { 5584 return passed_by_lvalue_reference_to_const; 5585 } 5586 5587 template <std::size_t N> 5588 static invoked evaluate_category(<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1>&) 5589 { 5590 return passed_by_lvalue_reference; 5591 } 5592 5593 template <std::size_t N> 5594 static invoked evaluate_category(<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1> const&&) 5595 { 5596 return passed_by_rvalue_reference_to_const; 5597 } 5598 5599 template <std::size_t N> 5600 static invoked evaluate_category(<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1>&&) 5601 { 5602 return passed_by_rvalue_reference; 5603 } 5604}; 5605</pre> 5606<p>Named parameters are required when invoking the member function; however, none 5607of their tags need to be in the same namespace.</p> 5608<pre class="literal-block"> 5609<a class="reference internal" href="#boost-parameter-name"><tt class="docutils literal">BOOST_PARAMETER_NAME</tt></a>((_lrc, kw0) in(lrc)) 5610<a class="reference internal" href="#boost-parameter-name"><tt class="docutils literal">BOOST_PARAMETER_NAME</tt></a>((_lr, kw1) in_out(lr)) 5611<a class="reference internal" href="#boost-parameter-name"><tt class="docutils literal">BOOST_PARAMETER_NAME</tt></a>((_rrc, kw2) in(rrc)) 5612<a class="reference internal" href="#boost-parameter-name"><tt class="docutils literal">BOOST_PARAMETER_NAME</tt></a>((_rr, kw3) consume(rr)) 5613</pre> 5614<p>Use the macro as a substitute for a variadic function header. Enclose the 5615return type <tt class="docutils literal">bool</tt> in parentheses. The macro will qualify the function with 5616the <tt class="docutils literal">const</tt> keyword.</p> 5617<pre class="literal-block"> 5618struct D 5619{ 5620 D() 5621 { 5622 } 5623 5624 BOOST_PARAMETER_NO_SPEC_CONST_MEMBER_FUNCTION((bool), evaluate_m) 5625 { 5626 BOOST_TEST_EQ( 5627 passed_by_lvalue_reference_to_const 5628 , U::evaluate_category<0>(args[_lrc]) 5629 ); 5630 BOOST_TEST_EQ( 5631 passed_by_lvalue_reference 5632 , U::evaluate_category<1>(args[_lr]) 5633 ); 5634 BOOST_TEST_EQ( 5635 passed_by_rvalue_reference_to_const 5636 , U::evaluate_category<2>( 5637 args[_rrc | rvalue_const_bitset<2>()] 5638 ) 5639 ); 5640 BOOST_TEST_EQ( 5641 passed_by_rvalue_reference 5642 , U::evaluate_category<3>( 5643 args[_rr | rvalue_bitset<3>()] 5644 ) 5645 ); 5646 5647 return true; 5648 } 5649}; 5650</pre> 5651<p>To invoke the member function, bind all its arguments to named parameters.</p> 5652<pre class="literal-block"> 5653D const d = D(); 5654d.evaluate_m( 5655 _rr0 = rvalue_bitset<3>() 5656 , _lrc0 = lvalue_const_bitset<0>() 5657 , _lr0 = lvalue_bitset<1>() 5658 , _rrc0 = rvalue_const_bitset<2>() 5659); 5660d.evaluate_m( 5661 _lr0 = lvalue_bitset<1>() 5662 , _lrc0 = lvalue_const_bitset<0>() 5663); 5664</pre> 5665<p>The <a class="reference external" href="../../test/preprocessor_eval_cat_no_spec.cpp">preprocessor_eval_cat_no_spec.cpp</a> test program demonstrates proper usage of 5666this macro.</p> 5667<p><strong>Macro parameters:</strong></p> 5668<ul class="simple"> 5669<li><tt class="docutils literal">result</tt> is the parenthesized return type of the function.</li> 5670<li><tt class="docutils literal">name</tt> is the base name of the function; it determines the name of the 5671generated implementation function.</li> 5672</ul> 5673<p><strong>Argument specifiers syntax:</strong></p> 5674<p>None.</p> 5675<p><strong>Approximate expansion:</strong></p> 5676<pre class="literal-block"> 5677// If <strong>result</strong> is a template instantiation of <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::enable_if</a>, 5678// <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::enable_if_c</a>, <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::lazy_enable_if</a>, 5679// <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::lazy_enable_if_c</a>, <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::disable_if</a>, <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::disable_if_c</a>, 5680// <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::lazy_disable_if</a>, <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::lazy_disable_if_c</a>, or 5681// <a class="reference external" href="http://en.cppreference.com/w/cpp/types/enable_if">std::enable_if</a>: 5682template <typename TaggedArg0, typename ...TaggedArgs> 5683using boost_param_no_spec_result_const_ ## __LINE__ ## <strong>name</strong> = <strong>result</strong>; 5684 5685// If <strong>result</strong> is a simple return type: 5686template <typename TaggedArg0, typename ...TaggedArgs> 5687struct boost_param_no_spec_result_const_ ## __LINE__ ## <strong>name</strong> 5688{ 5689 typedef <strong>result</strong> type; 5690}; 5691 5692template <typename TaggedArg0, typename ...TaggedArgs> 5693inline typename <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::lazy_enable_if</a>< 5694 <a class="reference internal" href="#are-tagged-arguments"><tt class="docutils literal">are_tagged_arguments</tt></a><TaggedArg0,TaggedArgs...> 5695 , boost_param_no_spec_result_const_ ## __LINE__ ## <strong>name</strong>< 5696 TaggedArg0 5697 , TaggedArgs... 5698 > 5699>::type 5700 <strong>name</strong>(TaggedArg0 const& arg0, TaggedArgs const&... args) const 5701{ 5702 return this->boost_param_no_spec_impl_const ## __LINE__ ## <strong>name</strong>( 5703 static_cast< 5704 typename 5705 boost_param_no_spec_result_const_ ## __LINE__ ## <strong>name</strong>< 5706 TaggedArg0 5707 , TaggedArgs... 5708 >::type(*)() 5709 >(<a class="reference external" href="http://en.cppreference.com/w/cpp/language/nullptr">std::nullptr</a>) 5710 , <a class="reference internal" href="#compose"><tt class="docutils literal">compose</tt></a>(arg0, args...) 5711 ); 5712} 5713 5714template <typename ResultType, typename Args> 5715ResultType 5716 boost_param_no_spec_impl_const ## __LINE__ ## <strong>name</strong>( 5717 (ResultType(*)()) 5718 , Args const& args 5719 ) const 5720</pre> 5721<p>Only the <a class="reference internal" href="#argumentpack"><span class="concept">ArgumentPack</span></a> type <tt class="docutils literal">Args</tt> and its object instance <tt class="docutils literal">args</tt> are 5722available for use within the function body.</p> 5723</div> 5724<div class="section" id="boost-parameter-no-spec-function-call-operator-result"> 5725<span id="boost-parameter-no-spec-function-call-operator"></span><h2><a class="toc-backref" href="#id71">7.15 <tt class="docutils literal">BOOST_PARAMETER_NO_SPEC_FUNCTION_CALL_OPERATOR(result)</tt></a></h2> 5726<table class="docutils field-list" frame="void" rules="none"> 5727<col class="field-name" /> 5728<col class="field-body" /> 5729<tbody valign="top"> 5730<tr class="field"><th class="field-name">Defined in:</th><td class="field-body"><a class="reference external" href="../../../../boost/parameter/preprocessor_no_spec.hpp">boost/parameter/preprocessor_no_spec.hpp</a></td> 5731</tr> 5732</tbody> 5733</table> 5734<p>Generates a function call operator that can take in named arguments.</p> 5735<table class="docutils field-list" frame="void" rules="none"> 5736<col class="field-name" /> 5737<col class="field-body" /> 5738<tbody valign="top"> 5739<tr class="field"><th class="field-name">Example usage:</th><td class="field-body"></td> 5740</tr> 5741</tbody> 5742</table> 5743<p>When designing a front-end class template whose back-end is configurable via 5744parameterized inheritance, it can be useful to omit argument specifiers from 5745a named-parameter function call operator so that the delegate member functions 5746of the back-end classes can enforce their own specifications.</p> 5747<pre class="literal-block"> 5748template <typename B> 5749struct frontend : B 5750{ 5751 frontend() : B() 5752 { 5753 } 5754 5755 BOOST_PARAMETER_NO_SPEC_FUNCTION_CALL_OPERATOR((void)) 5756 { 5757 this->initialize_impl(args); 5758 } 5759}; 5760</pre> 5761<p>Named parameters are required when invoking the function call operator; 5762however, none of their tags need to be in the same namespace.</p> 5763<pre class="literal-block"> 5764<a class="reference internal" href="#boost-parameter-name"><tt class="docutils literal">BOOST_PARAMETER_NAME</tt></a>(a0) 5765<a class="reference internal" href="#boost-parameter-name"><tt class="docutils literal">BOOST_PARAMETER_NAME</tt></a>(a1) 5766<a class="reference internal" href="#boost-parameter-name"><tt class="docutils literal">BOOST_PARAMETER_NAME</tt></a>(a2) 5767</pre> 5768<p>For this example, each of the back-end class templates requires its own 5769parameter to be present in the argument pack. In practice, such parameters 5770should be optional, with default values.</p> 5771<pre class="literal-block"> 5772template <typename T> 5773class backend0 5774{ 5775 T a0; 5776 5777 public: 5778 backend0() : a0() 5779 { 5780 } 5781 5782 T const& get_a0() const 5783 { 5784 return this->a0; 5785 } 5786 5787 protected: 5788 template <typename ArgPack> 5789 void initialize_impl(ArgPack const& args) 5790 { 5791 this->a0 = args[_a0]; 5792 } 5793}; 5794 5795template <typename B, typename T> 5796class backend1 : public B 5797{ 5798 T a1; 5799 5800 public: 5801 backend1() : B(), a1() 5802 { 5803 } 5804 5805 T const& get_a1() const 5806 { 5807 return this->a1; 5808 } 5809 5810 protected: 5811 template <typename ArgPack> 5812 void initialize_impl(ArgPack const& args) 5813 { 5814 B::initialize_impl(args); 5815 this->a1 = args[_a1]; 5816 } 5817}; 5818 5819template <typename B, typename T> 5820class backend2 : public B 5821{ 5822 T a2; 5823 5824 public: 5825 backend2() : B(), a2() 5826 { 5827 } 5828 5829 T const& get_a2() const 5830 { 5831 return this->a2; 5832 } 5833 5834 protected: 5835 template <typename ArgPack> 5836 void initialize_impl(ArgPack const& args) 5837 { 5838 B::initialize_impl(args); 5839 this->a2 = args[_a2]; 5840 } 5841}; 5842</pre> 5843<p>This example shows that while <tt class="docutils literal">backend0</tt> must always be the root base class 5844template and that <tt class="docutils literal">frontend</tt> must always be the most derived class template, 5845the other back-ends can be chained together in different orders.</p> 5846<pre class="literal-block"> 5847char const* p = "foo"; 5848frontend< 5849 backend2<backend1<backend0<char const*>, char>, int> 5850> composed_obj0; 5851frontend< 5852 backend1<backend2<backend0<char const*>, int>, char> 5853> composed_obj1; 5854composed_obj0(_a2 = 4, _a1 = ' ', _a0 = p); 5855composed_obj1(_a0 = p, _a1 = ' ', _a2 = 4); 5856BOOST_TEST_EQ(composed_obj0.get_a0(), composed_obj1.get_a0()); 5857BOOST_TEST_EQ(composed_obj0.get_a1(), composed_obj1.get_a1()); 5858BOOST_TEST_EQ(composed_obj0.get_a2(), composed_obj1.get_a2()); 5859</pre> 5860<p>The <a class="reference external" href="../../test/parameterized_inheritance.cpp">parameterized_inheritance.cpp</a> and <a class="reference external" href="../../test/preprocessor_eval_cat_no_spec.cpp">preprocessor_eval_cat_no_spec.cpp</a> test 5861programs demonstrate proper usage of this macro.</p> 5862<p><strong>Macro parameters:</strong></p> 5863<ul class="simple"> 5864<li><tt class="docutils literal">result</tt> is the parenthesized return type of the function call operator.</li> 5865</ul> 5866<p><strong>Argument specifiers syntax:</strong></p> 5867<p>None.</p> 5868<p><strong>Approximate expansion:</strong></p> 5869<pre class="literal-block"> 5870// If <strong>result</strong> is a template instantiation of <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::enable_if</a>, 5871// <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::enable_if_c</a>, <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::lazy_enable_if</a>, 5872// <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::lazy_enable_if_c</a>, <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::disable_if</a>, <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::disable_if_c</a>, 5873// <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::lazy_disable_if</a>, <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::lazy_disable_if_c</a>, or 5874// <a class="reference external" href="http://en.cppreference.com/w/cpp/types/enable_if">std::enable_if</a>: 5875template <typename TaggedArg0, typename ...TaggedArgs> 5876using boost_param_no_spec_result_ ## __LINE__ ## operator = <strong>result</strong>; 5877 5878// If <strong>result</strong> is a simple return type: 5879template <typename TaggedArg0, typename ...TaggedArgs> 5880struct boost_param_no_spec_result_ ## __LINE__ ## operator 5881{ 5882 typedef <strong>result</strong> type; 5883}; 5884 5885template <typename TaggedArg0, typename ...TaggedArgs> 5886inline typename <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::lazy_enable_if</a>< 5887 <a class="reference internal" href="#are-tagged-arguments"><tt class="docutils literal">are_tagged_arguments</tt></a><TaggedArg0,TaggedArgs...> 5888 , boost_param_no_spec_result_ ## __LINE__ ## operator< 5889 TaggedArg0 5890 , TaggedArgs... 5891 > 5892>::type 5893 operator()(TaggedArg0 const& arg0, TaggedArgs const&... args) 5894{ 5895 return this->boost_param_no_spec_impl ## __LINE__ ## operator( 5896 static_cast< 5897 typename 5898 boost_param_no_spec_result_ ## __LINE__ ## operator< 5899 TaggedArg0 5900 , TaggedArgs... 5901 >::type(*)() 5902 >(<a class="reference external" href="http://en.cppreference.com/w/cpp/language/nullptr">std::nullptr</a>) 5903 , <a class="reference internal" href="#compose"><tt class="docutils literal">compose</tt></a>(arg0, args...) 5904 ); 5905} 5906 5907template <typename ResultType, typename Args> 5908ResultType 5909 boost_param_no_spec_impl ## __LINE__ ## operator( 5910 (ResultType(*)()) 5911 , Args const& args 5912 ) 5913</pre> 5914<p>Only the <a class="reference internal" href="#argumentpack"><span class="concept">ArgumentPack</span></a> type <tt class="docutils literal">Args</tt> and its object instance <tt class="docutils literal">args</tt> are 5915available for use within the function body.</p> 5916</div> 5917<div class="section" id="boost-parameter-no-spec-const-function-call-operator-result"> 5918<span id="boost-parameter-no-spec-const-function-call-operator"></span><h2><a class="toc-backref" href="#id72">7.16 <tt class="docutils literal">BOOST_PARAMETER_NO_SPEC_CONST_FUNCTION_CALL_OPERATOR(result)</tt></a></h2> 5919<table class="docutils field-list" frame="void" rules="none"> 5920<col class="field-name" /> 5921<col class="field-body" /> 5922<tbody valign="top"> 5923<tr class="field"><th class="field-name">Defined in:</th><td class="field-body"><a class="reference external" href="../../../../boost/parameter/preprocessor_no_spec.hpp">boost/parameter/preprocessor_no_spec.hpp</a></td> 5924</tr> 5925</tbody> 5926</table> 5927<p>Generates a function call operator that can take in named arguments.</p> 5928<table class="docutils field-list" frame="void" rules="none"> 5929<col class="field-name" /> 5930<col class="field-body" /> 5931<tbody valign="top"> 5932<tr class="field"><th class="field-name">Example usage:</th><td class="field-body"></td> 5933</tr> 5934</tbody> 5935</table> 5936<p>The return type of each of the following function templates falls under a 5937different value category.</p> 5938<pre class="literal-block"> 5939template <std::size_t N> 5940<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1> rvalue_bitset() 5941{ 5942 return <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1>(); 5943} 5944 5945template <std::size_t N> 5946<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1> const rvalue_const_bitset() 5947{ 5948 return <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1>(); 5949} 5950 5951template <std::size_t N> 5952<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1>& lvalue_bitset() 5953{ 5954 static <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1> lset = <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1>(); 5955 return lset; 5956} 5957 5958template <std::size_t N> 5959<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1> const& lvalue_const_bitset() 5960{ 5961 static <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1> const clset = <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1>(); 5962 return clset; 5963} 5964</pre> 5965<p>The <tt class="docutils literal"><span class="pre">U::evaluate_category</span></tt> static member function template has a simple job: 5966to return the correct value category when passed in an object returned by one 5967of the functions defined above. Assume that 5968<a class="reference internal" href="#boost-parameter-has-perfect-forwarding"><tt class="docutils literal">BOOST_PARAMETER_HAS_PERFECT_FORWARDING</tt></a> is defined.</p> 5969<pre class="literal-block"> 5970enum invoked 5971{ 5972 passed_by_lvalue_reference_to_const 5973 , passed_by_lvalue_reference 5974 , passed_by_rvalue_reference_to_const 5975 , passed_by_rvalue_reference 5976}; 5977 5978struct U 5979{ 5980 template <std::size_t N> 5981 static invoked evaluate_category(<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1> const&) 5982 { 5983 return passed_by_lvalue_reference_to_const; 5984 } 5985 5986 template <std::size_t N> 5987 static invoked evaluate_category(<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1>&) 5988 { 5989 return passed_by_lvalue_reference; 5990 } 5991 5992 template <std::size_t N> 5993 static invoked evaluate_category(<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1> const&&) 5994 { 5995 return passed_by_rvalue_reference_to_const; 5996 } 5997 5998 template <std::size_t N> 5999 static invoked evaluate_category(<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1>&&) 6000 { 6001 return passed_by_rvalue_reference; 6002 } 6003}; 6004</pre> 6005<p>Named parameters are required when invoking the function call operator; 6006however, none of their tags need to be in the same namespace.</p> 6007<pre class="literal-block"> 6008<a class="reference internal" href="#boost-parameter-name"><tt class="docutils literal">BOOST_PARAMETER_NAME</tt></a>((_lrc, kw0) in(lrc)) 6009<a class="reference internal" href="#boost-parameter-name"><tt class="docutils literal">BOOST_PARAMETER_NAME</tt></a>((_lr, kw1) in_out(lr)) 6010<a class="reference internal" href="#boost-parameter-name"><tt class="docutils literal">BOOST_PARAMETER_NAME</tt></a>((_rrc, kw2) in(rrc)) 6011<a class="reference internal" href="#boost-parameter-name"><tt class="docutils literal">BOOST_PARAMETER_NAME</tt></a>((_rr, kw3) consume(rr)) 6012</pre> 6013<p>Use the macro as a substitute for a variadic function call operator 6014header. Enclose the return type <tt class="docutils literal">bool</tt> in parentheses. The macro will 6015qualify the function with the <tt class="docutils literal">const</tt> keyword.</p> 6016<pre class="literal-block"> 6017struct D 6018{ 6019 D() 6020 { 6021 } 6022 6023 BOOST_PARAMETER_NO_SPEC_CONST_FUNCTION_CALL_OPERATOR((bool)) 6024 { 6025 BOOST_TEST_EQ( 6026 passed_by_lvalue_reference_to_const 6027 , U::evaluate_category<0>(args[_lrc]) 6028 ); 6029 BOOST_TEST_EQ( 6030 passed_by_lvalue_reference 6031 , U::evaluate_category<1>(args[_lr]) 6032 ); 6033 BOOST_TEST_EQ( 6034 passed_by_rvalue_reference_to_const 6035 , U::evaluate_category<2>( 6036 args[_rrc | rvalue_const_bitset<2>()] 6037 ) 6038 ); 6039 BOOST_TEST_EQ( 6040 passed_by_rvalue_reference 6041 , U::evaluate_category<3>( 6042 args[_rr | rvalue_bitset<3>()] 6043 ) 6044 ); 6045 6046 return true; 6047 } 6048}; 6049</pre> 6050<p>To invoke the function call operator, bind all its arguments to named 6051parameters.</p> 6052<pre class="literal-block"> 6053D const d = D(); 6054d( 6055 _rr0 = rvalue_bitset<3>() 6056 , _lrc0 = lvalue_const_bitset<0>() 6057 , _lr0 = lvalue_bitset<1>() 6058 , _rrc0 = rvalue_const_bitset<2>() 6059); 6060d( 6061 _lr0 = lvalue_bitset<1>() 6062 , _lrc0 = lvalue_const_bitset<0>() 6063); 6064</pre> 6065<p>The <a class="reference external" href="../../test/preprocessor_eval_cat_no_spec.cpp">preprocessor_eval_cat_no_spec.cpp</a> test program demonstrates proper usage of this 6066macro.</p> 6067<p><strong>Macro parameters:</strong></p> 6068<ul class="simple"> 6069<li><tt class="docutils literal">result</tt> is the parenthesized return type of the function call operator.</li> 6070</ul> 6071<p><strong>Argument specifiers syntax:</strong></p> 6072<p>None.</p> 6073<p><strong>Approximate expansion:</strong></p> 6074<pre class="literal-block"> 6075// If <strong>result</strong> is a template instantiation of <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::enable_if</a>, 6076// <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::enable_if_c</a>, <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::lazy_enable_if</a>, 6077// <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::lazy_enable_if_c</a>, <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::disable_if</a>, <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::disable_if_c</a>, 6078// <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::lazy_disable_if</a>, <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::lazy_disable_if_c</a>, or 6079// <a class="reference external" href="http://en.cppreference.com/w/cpp/types/enable_if">std::enable_if</a>: 6080template <typename TaggedArg0, typename ...TaggedArgs> 6081using boost_param_no_spec_result_const_ ## __LINE__ ## operator = <strong>result</strong>; 6082 6083// If <strong>result</strong> is a simple return type: 6084template <typename TaggedArg0, typename ...TaggedArgs> 6085struct boost_param_no_spec_result_const_ ## __LINE__ ## operator 6086{ 6087 typedef <strong>result</strong> type; 6088}; 6089 6090template <typename TaggedArg0, typename ...TaggedArgs> 6091inline typename <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::lazy_enable_if</a>< 6092 <a class="reference internal" href="#are-tagged-arguments"><tt class="docutils literal">are_tagged_arguments</tt></a><TaggedArg0,TaggedArgs...> 6093 , boost_param_no_spec_result_const_ ## __LINE__ ## operator< 6094 TaggedArg0 6095 , TaggedArgs... 6096 > 6097>::type 6098 operator()( 6099 TaggedArg0 const& arg0 6100 , TaggedArgs const&... args 6101 ) const 6102{ 6103 return this->boost_param_no_spec_impl_const ## __LINE__ ## operator( 6104 static_cast< 6105 typename 6106 boost_param_no_spec_result_const_ ## __LINE__ ## operator< 6107 TaggedArg0 6108 , TaggedArgs... 6109 >::type(*)() 6110 >(<a class="reference external" href="http://en.cppreference.com/w/cpp/language/nullptr">std::nullptr</a>) 6111 , <a class="reference internal" href="#compose"><tt class="docutils literal">compose</tt></a>(arg0, args...) 6112 ); 6113} 6114 6115template <typename ResultType, typename Args> 6116ResultType 6117 boost_param_no_spec_impl_const ## __LINE__ ## operator( 6118 (ResultType(*)()) 6119 , Args const& args 6120 ) const 6121</pre> 6122<p>Only the <a class="reference internal" href="#argumentpack"><span class="concept">ArgumentPack</span></a> type <tt class="docutils literal">Args</tt> and its object instance <tt class="docutils literal">args</tt> are 6123available for use within the function body.</p> 6124</div> 6125<div class="section" id="boost-parameter-no-spec-constructor-cls-impl"> 6126<span id="boost-parameter-no-spec-constructor"></span><h2><a class="toc-backref" href="#id73">7.17 <tt class="docutils literal">BOOST_PARAMETER_NO_SPEC_CONSTRUCTOR(cls, impl)</tt></a></h2> 6127<table class="docutils field-list" frame="void" rules="none"> 6128<col class="field-name" /> 6129<col class="field-body" /> 6130<tbody valign="top"> 6131<tr class="field"><th class="field-name">Defined in:</th><td class="field-body"><a class="reference external" href="../../../../boost/parameter/preprocessor_no_spec.hpp">boost/parameter/preprocessor_no_spec.hpp</a></td> 6132</tr> 6133</tbody> 6134</table> 6135<p>Generates a constructor that can take in named arguments.</p> 6136<table class="docutils field-list" frame="void" rules="none"> 6137<col class="field-name" /> 6138<col class="field-body" /> 6139<tbody valign="top"> 6140<tr class="field"><th class="field-name">Example usage:</th><td class="field-body"></td> 6141</tr> 6142</tbody> 6143</table> 6144<p>When designing a front-end class template whose back-end is configurable via 6145parameterized inheritance, it can be useful to omit argument specifiers from 6146a named-parameter constructor so that the delegate constructors of the 6147back-end classes can enforce their own specifications.</p> 6148<pre class="literal-block"> 6149template <typename B> 6150struct frontend : B 6151{ 6152 BOOST_PARAMETER_NO_SPEC_CONSTRUCTOR(frontend, (B)) 6153}; 6154</pre> 6155<p>Named parameters are required when invoking the constructor; however, none of 6156their tags need to be in the same namespace.</p> 6157<pre class="literal-block"> 6158<a class="reference internal" href="#boost-parameter-name"><tt class="docutils literal">BOOST_PARAMETER_NAME</tt></a>(a0) 6159<a class="reference internal" href="#boost-parameter-name"><tt class="docutils literal">BOOST_PARAMETER_NAME</tt></a>(a1) 6160<a class="reference internal" href="#boost-parameter-name"><tt class="docutils literal">BOOST_PARAMETER_NAME</tt></a>(a2) 6161</pre> 6162<p>For this example, each of the back-end class templates requires its own 6163parameter to be present in the argument pack. In practice, such parameters 6164should be optional, with default values.</p> 6165<pre class="literal-block"> 6166struct _enabler 6167{ 6168}; 6169 6170template <typename T> 6171class backend0 6172{ 6173 T a0; 6174 6175 public: 6176 template <typename ArgPack> 6177 explicit backend0( 6178 ArgPack const& args 6179 , typename <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::enable_if</a>< 6180 <a class="reference internal" href="#is-argument-pack"><tt class="docutils literal">is_argument_pack</tt></a><ArgPack> 6181 , _enabler 6182 >::type = _enabler() 6183 ) : a0(args[_a0]) 6184 { 6185 } 6186 6187 T const& get_a0() const 6188 { 6189 return this->a0; 6190 } 6191}; 6192 6193template <typename B, typename T> 6194class backend1 : public B 6195{ 6196 T a1; 6197 6198 public: 6199 template <typename ArgPack> 6200 explicit backend1( 6201 ArgPack const& args 6202 , typename <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::enable_if</a>< 6203 <a class="reference internal" href="#is-argument-pack"><tt class="docutils literal">is_argument_pack</tt></a><ArgPack> 6204 , _enabler 6205 >::type = _enabler() 6206 ) : B(args), a1(args[_a1]) 6207 { 6208 } 6209 6210 T const& get_a1() const 6211 { 6212 return this->a1; 6213 } 6214}; 6215 6216template <typename B, typename T> 6217class backend2 : public B 6218{ 6219 T a2; 6220 6221 public: 6222 template <typename ArgPack> 6223 explicit backend2( 6224 ArgPack const& args 6225 , typename <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::enable_if</a>< 6226 <a class="reference internal" href="#is-argument-pack"><tt class="docutils literal">is_argument_pack</tt></a><ArgPack> 6227 , _enabler 6228 >::type = _enabler() 6229 ) : B(args), a2(args[_a2]) 6230 { 6231 } 6232 6233 T const& get_a2() const 6234 { 6235 return this->a2; 6236 } 6237}; 6238</pre> 6239<p>This example shows that while <tt class="docutils literal">backend0</tt> must always be the root base class 6240template and that <tt class="docutils literal">frontend</tt> must always be the most derived class template, 6241the other back-ends can be chained together in different orders.</p> 6242<pre class="literal-block"> 6243char const* p = "foo"; 6244frontend< 6245 backend2<backend1<backend0<char const*>, char>, int> 6246> composed_obj0(_a2 = 4, _a1 = ' ', _a0 = p); 6247frontend< 6248 backend1<backend2<backend0<char const*>, int>, char> 6249> composed_obj1(_a0 = p, _a1 = ' ', _a2 = 4); 6250BOOST_TEST_EQ(composed_obj0.get_a0(), composed_obj1.get_a0()); 6251BOOST_TEST_EQ(composed_obj0.get_a1(), composed_obj1.get_a1()); 6252BOOST_TEST_EQ(composed_obj0.get_a2(), composed_obj1.get_a2()); 6253</pre> 6254<p>The <a class="reference external" href="../../test/parameterized_inheritance.cpp">parameterized_inheritance.cpp</a> and <a class="reference external" href="../../test/preprocessor_eval_cat_no_spec.cpp">preprocessor_eval_cat_no_spec.cpp</a> test 6255programs demonstrate proper usage of this macro.</p> 6256<p><strong>Macro parameters:</strong></p> 6257<ul class="simple"> 6258<li><tt class="docutils literal">cls</tt> is the name of the enclosing class.</li> 6259<li><tt class="docutils literal">impl</tt> is the parenthesized implementation base class for <tt class="docutils literal">cls</tt>.</li> 6260</ul> 6261<p><strong>Argument specifiers syntax:</strong></p> 6262<p>None.</p> 6263<p><strong>Approximate expansion:</strong></p> 6264<pre class="literal-block"> 6265template < 6266 typename TaggedArg0 6267 , typename ...TaggedArgs 6268 , typename = typename <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::enable_if</a>< 6269 <a class="reference internal" href="#are-tagged-arguments"><tt class="docutils literal">are_tagged_arguments</tt></a><TaggedArg0,TaggedArgs...> 6270 >::type 6271> 6272inline explicit <strong>cls</strong>( 6273 TaggedArg0 const& arg0 6274 , TaggedArgs const&... args 6275) : <strong>impl</strong>(<a class="reference internal" href="#compose"><tt class="docutils literal">compose</tt></a>(arg0, args...)) 6276{ 6277} 6278</pre> 6279</div> 6280<div class="section" id="boost-parameter-no-spec-no-base-constructor-cls-impl"> 6281<span id="boost-parameter-no-spec-no-base-constructor"></span><h2><a class="toc-backref" href="#id74">7.18 <tt class="docutils literal">BOOST_PARAMETER_NO_SPEC_NO_BASE_CONSTRUCTOR(cls, impl)</tt></a></h2> 6282<table class="docutils field-list" frame="void" rules="none"> 6283<col class="field-name" /> 6284<col class="field-body" /> 6285<tbody valign="top"> 6286<tr class="field"><th class="field-name">Defined in:</th><td class="field-body"><a class="reference external" href="../../../../boost/parameter/preprocessor_no_spec.hpp">boost/parameter/preprocessor_no_spec.hpp</a></td> 6287</tr> 6288</tbody> 6289</table> 6290<p>Generates a constructor that can take in named arguments.</p> 6291<table class="docutils field-list" frame="void" rules="none"> 6292<col class="field-name" /> 6293<col class="field-body" /> 6294<tbody valign="top"> 6295<tr class="field"><th class="field-name">Example usage:</th><td class="field-body"></td> 6296</tr> 6297</tbody> 6298</table> 6299<p>The return type of each of the following function templates falls under a 6300different value category.</p> 6301<pre class="literal-block"> 6302template <std::size_t N> 6303<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1> rvalue_bitset() 6304{ 6305 return <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1>(); 6306} 6307 6308template <std::size_t N> 6309<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1> const rvalue_const_bitset() 6310{ 6311 return <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1>(); 6312} 6313 6314template <std::size_t N> 6315<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1>& lvalue_bitset() 6316{ 6317 static <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1> lset = <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1>(); 6318 return lset; 6319} 6320 6321template <std::size_t N> 6322<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1> const& lvalue_const_bitset() 6323{ 6324 static <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1> const clset = <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1>(); 6325 return clset; 6326} 6327</pre> 6328<p>The <tt class="docutils literal"><span class="pre">U::evaluate_category</span></tt> static member function template has a simple job: 6329to return the correct value category when passed in an object returned by one 6330of the functions defined above. Assume that 6331<a class="reference internal" href="#boost-parameter-has-perfect-forwarding"><tt class="docutils literal">BOOST_PARAMETER_HAS_PERFECT_FORWARDING</tt></a> is defined.</p> 6332<pre class="literal-block"> 6333enum invoked 6334{ 6335 passed_by_lvalue_reference_to_const 6336 , passed_by_lvalue_reference 6337 , passed_by_rvalue_reference_to_const 6338 , passed_by_rvalue_reference 6339}; 6340 6341struct U 6342{ 6343 template <std::size_t N> 6344 static invoked evaluate_category(<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1> const&) 6345 { 6346 return passed_by_lvalue_reference_to_const; 6347 } 6348 6349 template <std::size_t N> 6350 static invoked evaluate_category(<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1>&) 6351 { 6352 return passed_by_lvalue_reference; 6353 } 6354 6355 template <std::size_t N> 6356 static invoked evaluate_category(<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1> const&&) 6357 { 6358 return passed_by_rvalue_reference_to_const; 6359 } 6360 6361 template <std::size_t N> 6362 static invoked evaluate_category(<a class="reference external" href="http://en.cppreference.com/w/cpp/utility/bitset">std::bitset</a><N + 1>&&) 6363 { 6364 return passed_by_rvalue_reference; 6365 } 6366}; 6367</pre> 6368<p>Named parameters are required when invoking the constructor; however, none of 6369their tags need to be in the same namespace.</p> 6370<pre class="literal-block"> 6371<a class="reference internal" href="#boost-parameter-name"><tt class="docutils literal">BOOST_PARAMETER_NAME</tt></a>((_lrc, kw0) in(lrc)) 6372<a class="reference internal" href="#boost-parameter-name"><tt class="docutils literal">BOOST_PARAMETER_NAME</tt></a>((_lr, kw1) in_out(lr)) 6373<a class="reference internal" href="#boost-parameter-name"><tt class="docutils literal">BOOST_PARAMETER_NAME</tt></a>((_rrc, kw2) in(rrc)) 6374<a class="reference internal" href="#boost-parameter-name"><tt class="docutils literal">BOOST_PARAMETER_NAME</tt></a>((_rr, kw3) consume(rr)) 6375</pre> 6376<p>Unlike <a class="reference internal" href="#boost-parameter-no-spec-constructor"><tt class="docutils literal">BOOST_PARAMETER_NO_SPEC_CONSTRUCTOR</tt></a>, this macro doesn't require a 6377base class, only a delegate function to which the generated constructor can 6378pass its <a class="reference internal" href="#argumentpack"><span class="concept">ArgumentPack</span></a>.</p> 6379<pre class="literal-block"> 6380struct D 6381{ 6382 BOOST_PARAMETER_NO_SPEC_NO_BASE_CONSTRUCTOR(D, D::_evaluate) 6383 6384 private: 6385 template <typename Args> 6386 static bool _evaluate(Args const& args) 6387 { 6388 BOOST_TEST_EQ( 6389 passed_by_lvalue_reference_to_const 6390 , U::evaluate_category<0>(args[_lrc]) 6391 ); 6392 BOOST_TEST_EQ( 6393 passed_by_lvalue_reference 6394 , U::evaluate_category<1>(args[_lr]) 6395 ); 6396 BOOST_TEST_EQ( 6397 passed_by_rvalue_reference_to_const 6398 , U::evaluate_category<2>( 6399 args[_rrc | rvalue_const_bitset<2>()] 6400 ) 6401 ); 6402 BOOST_TEST_EQ( 6403 passed_by_rvalue_reference 6404 , U::evaluate_category<3>( 6405 args[_rr | rvalue_bitset<3>()] 6406 ) 6407 ); 6408 6409 return true; 6410 } 6411}; 6412</pre> 6413<p>To invoke the constructor, bind all its arguments to named parameters.</p> 6414<pre class="literal-block"> 6415D dp0( 6416 _rr0 = rvalue_bitset<3>() 6417 , _lrc0 = lvalue_const_bitset<0>() 6418 , _lr0 = lvalue_bitset<1>() 6419 , _rrc0 = rvalue_const_bitset<2>() 6420); 6421D dp1( 6422 _lr0 = lvalue_bitset<1>() 6423 , _lrc0 = lvalue_const_bitset<0>() 6424); 6425</pre> 6426<p>The <a class="reference external" href="../../test/preprocessor_eval_cat_no_spec.cpp">preprocessor_eval_cat_no_spec.cpp</a> test program demonstrates proper usage of 6427this macro.</p> 6428<p><strong>Macro parameters:</strong></p> 6429<ul class="simple"> 6430<li><tt class="docutils literal">cls</tt> is the name of the enclosing class.</li> 6431<li><tt class="docutils literal">func</tt> is a function that takes in the <a class="reference internal" href="#argumentpack"><span class="concept">ArgumentPack</span></a> that the 6432generated constructor passes on.</li> 6433</ul> 6434<p><strong>Argument specifiers syntax:</strong></p> 6435<p>None.</p> 6436<p><strong>Approximate expansion:</strong></p> 6437<pre class="literal-block"> 6438template < 6439 typename TaggedArg0 6440 , typename ...TaggedArgs 6441 , typename = typename <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::enable_if</a>< 6442 <a class="reference internal" href="#are-tagged-arguments"><tt class="docutils literal">are_tagged_arguments</tt></a><TaggedArg0,TaggedArgs...> 6443 >::type 6444> 6445inline explicit <strong>cls</strong>( 6446 TaggedArg0 const& arg0 6447 , TaggedArgs const&... args 6448) 6449{ 6450 <strong>func</strong>(<a class="reference internal" href="#compose"><tt class="docutils literal">compose</tt></a>(arg0, args...)); 6451} 6452</pre> 6453</div> 6454<div class="section" id="boost-parameter-name-name"> 6455<span id="boost-parameter-name"></span><h2><a class="toc-backref" href="#id75">7.19 <tt class="docutils literal">BOOST_PARAMETER_NAME(name)</tt></a></h2> 6456<table class="docutils field-list" frame="void" rules="none"> 6457<col class="field-name" /> 6458<col class="field-body" /> 6459<tbody valign="top"> 6460<tr class="field"><th class="field-name">Defined in:</th><td class="field-body"><a class="reference external" href="../../../../boost/parameter/name.hpp">boost/parameter/name.hpp</a></td> 6461</tr> 6462</tbody> 6463</table> 6464<p>Declares a tag-type and keyword object.</p> 6465<p><strong>If</strong> <em>name</em> is of the form:</p> 6466<pre class="literal-block"> 6467(<em>object-name</em>, <em>namespace-name</em>) <em>qualifier</em>(<em>tag-name</em>) 6468</pre> 6469<p><strong>then</strong></p> 6470<table class="docutils field-list" frame="void" rules="none"> 6471<col class="field-name" /> 6472<col class="field-body" /> 6473<tbody valign="top"> 6474<tr class="field"><th class="field-name">Requires:</th><td class="field-body"><em>qualifier</em> is either <tt class="docutils literal">in</tt>, <tt class="docutils literal">out</tt>, <tt class="docutils literal">in_out</tt>, <tt class="docutils literal">consume</tt>, 6475<tt class="docutils literal">move_from</tt>, or <tt class="docutils literal">forward</tt>.</td> 6476</tr> 6477<tr class="field"><th class="field-name">Expands to:</th><td class="field-body"></td> 6478</tr> 6479</tbody> 6480</table> 6481<pre class="literal-block"> 6482namespace <em>namespace-name</em> { 6483 6484 struct <em>tag-name</em> 6485 { 6486 static constexpr char const* keyword_name() 6487 { 6488 return ## <em>tag-name</em>; 6489 } 6490 6491 typedef <em>unspecified</em> _; 6492 typedef <em>unspecified</em> _1; 6493 typedef boost::parameter::<em>qualifier</em> ## _reference qualifier; 6494 6495 // The following definitions are available only when 6496 // <a class="reference internal" href="#boost-parameter-can-use-mp11"><tt class="docutils literal">BOOST_PARAMETER_CAN_USE_MP11</tt></a> is defined. 6497 6498 template <typename ArgumentPack> 6499 using binding_fn = typename <a class="reference internal" href="#binding"><tt class="docutils literal">binding</tt></a>< 6500 ArgumentPack 6501 , <em>tag-name</em> 6502 >::type; 6503 6504 template <typename ArgumentPack> 6505 using fn = typename <a class="reference internal" href="#value-type"><tt class="docutils literal">value_type</tt></a><ArgumentPack, <em>tag-name</em>>::type; 6506 }; 6507} 6508 6509<a class="reference internal" href="#keyword"><tt class="docutils literal">keyword</tt></a><<em>tag-namespace</em>::<em>tag-name</em>> const& <em>object-name</em> 6510 = <a class="reference internal" href="#keyword"><tt class="docutils literal">keyword</tt></a><<em>tag-namespace</em>::<em>tag-name</em>>::instance; 6511</pre> 6512<p><strong>Else If</strong> <em>name</em> is of the form:</p> 6513<pre class="literal-block"> 6514(<em>tag-name</em>, <em>namespace-name</em>) <em>object-name</em> 6515</pre> 6516<p><strong>then</strong></p> 6517<p>Treats <em>name</em> as if it were of the form:</p> 6518<pre class="literal-block"> 6519(forward(<em>tag-name</em>), <em>namespace-name</em>) <em>object-name</em> 6520</pre> 6521<p><strong>Else If</strong> <em>name</em> is of the form:</p> 6522<pre class="literal-block"> 6523<em>qualifier</em>(<em>tag-name</em>) 6524</pre> 6525<p><strong>then</strong></p> 6526<table class="docutils field-list" frame="void" rules="none"> 6527<col class="field-name" /> 6528<col class="field-body" /> 6529<tbody valign="top"> 6530<tr class="field"><th class="field-name">Requires:</th><td class="field-body"><em>qualifier</em> is either <tt class="docutils literal">in</tt>, <tt class="docutils literal">out</tt>, <tt class="docutils literal">in_out</tt>, <tt class="docutils literal">consume</tt>, 6531<tt class="docutils literal">move_from</tt>, or <tt class="docutils literal">forward</tt>.</td> 6532</tr> 6533<tr class="field"><th class="field-name">Expands to:</th><td class="field-body"></td> 6534</tr> 6535</tbody> 6536</table> 6537<pre class="literal-block"> 6538namespace tag { 6539 6540 struct <em>tag-name</em> 6541 { 6542 static constexpr char const* keyword_name() 6543 { 6544 return ## <em>tag-name</em>; 6545 } 6546 6547 typedef <em>unspecified</em> _; 6548 typedef <em>unspecified</em> _1; 6549 typedef boost::parameter::<em>qualifier</em> ## _reference qualifier; 6550 6551 // The following definitions are available only when 6552 // <a class="reference internal" href="#boost-parameter-can-use-mp11"><tt class="docutils literal">BOOST_PARAMETER_CAN_USE_MP11</tt></a> is defined. 6553 6554 template <typename ArgumentPack> 6555 using binding_fn = typename <a class="reference internal" href="#binding"><tt class="docutils literal">binding</tt></a>< 6556 ArgumentPack 6557 , <em>tag-name</em> 6558 >::type; 6559 6560 template <typename ArgumentPack> 6561 using fn = typename <a class="reference internal" href="#value-type"><tt class="docutils literal">value_type</tt></a><ArgumentPack, <em>tag-name</em>>::type; 6562 }; 6563} 6564 6565<a class="reference internal" href="#keyword"><tt class="docutils literal">keyword</tt></a><tag::<em>tag-name</em>> const& _ ## <em>tag-name</em> 6566 = <a class="reference internal" href="#keyword"><tt class="docutils literal">keyword</tt></a><tag::<em>tag-name</em>>::instance; 6567</pre> 6568<p><strong>Else</strong></p> 6569<p>Treats <em>name</em> as if it were of the form:</p> 6570<pre class="literal-block"> 6571forward(<em>tag-name</em>) 6572</pre> 6573</div> 6574<div class="section" id="boost-parameter-nested-keyword-tag-namespace-name-alias"> 6575<span id="boost-parameter-nested-keyword"></span><h2><a class="toc-backref" href="#id76">7.20 <tt class="docutils literal">BOOST_PARAMETER_NESTED_KEYWORD(tag_namespace, name, alias)</tt></a></h2> 6576<table class="docutils field-list" frame="void" rules="none"> 6577<col class="field-name" /> 6578<col class="field-body" /> 6579<tbody valign="top"> 6580<tr class="field"><th class="field-name">Defined in:</th><td class="field-body"><a class="reference external" href="../../../../boost/parameter/nested_keyword.hpp">boost/parameter/nested_keyword.hpp</a></td> 6581</tr> 6582</tbody> 6583</table> 6584<p>Declares a tag-type, a keyword object, and an alias for that object nested in 6585the tag-type.</p> 6586<p><strong>If</strong> <em>name</em> is of the form:</p> 6587<pre class="literal-block"> 6588<em>qualifier</em>(<em>tag-name</em>) 6589</pre> 6590<p><strong>then</strong></p> 6591<table class="docutils field-list" frame="void" rules="none"> 6592<col class="field-name" /> 6593<col class="field-body" /> 6594<tbody valign="top"> 6595<tr class="field"><th class="field-name">Requires:</th><td class="field-body"><em>qualifier</em> is either <tt class="docutils literal">in</tt>, <tt class="docutils literal">out</tt>, <tt class="docutils literal">in_out</tt>, <tt class="docutils literal">consume</tt>, 6596<tt class="docutils literal">move_from</tt>, or <tt class="docutils literal">forward</tt>.</td> 6597</tr> 6598<tr class="field"><th class="field-name">Expands to:</th><td class="field-body"></td> 6599</tr> 6600</tbody> 6601</table> 6602<pre class="literal-block"> 6603namespace tag { 6604 6605 struct <em>tag-name</em> 6606 { 6607 static constexpr char const* keyword_name() 6608 { 6609 return ## <em>tag-name</em> ## _; 6610 } 6611 6612 typedef <em>unspecified</em> _; 6613 typedef <em>unspecified</em> _1; 6614 typedef boost::parameter::<em>qualifier</em> ## _reference qualifier; 6615 static <a class="reference internal" href="#keyword"><tt class="docutils literal">keyword</tt></a><<em>tag-name</em>> const& <em>alias</em>; 6616 6617 // The following definitions are available only when 6618 // <a class="reference internal" href="#boost-parameter-can-use-mp11"><tt class="docutils literal">BOOST_PARAMETER_CAN_USE_MP11</tt></a> is defined. 6619 6620 template <typename ArgumentPack> 6621 using binding_fn = typename <a class="reference internal" href="#binding"><tt class="docutils literal">binding</tt></a>< 6622 ArgumentPack 6623 , <em>tag-name</em> 6624 >::type; 6625 6626 template <typename ArgumentPack> 6627 using fn = typename <a class="reference internal" href="#value-type"><tt class="docutils literal">value_type</tt></a><ArgumentPack, <em>tag-name</em>>::type; 6628 }; 6629 6630 <a class="reference internal" href="#keyword"><tt class="docutils literal">keyword</tt></a><<em>tag-name</em>> const& tag::<em>tag-name</em>::<em>alias</em> 6631 = <a class="reference internal" href="#keyword"><tt class="docutils literal">keyword</tt></a><<em>tag-name</em>>::instance; 6632} 6633 6634<a class="reference internal" href="#keyword"><tt class="docutils literal">keyword</tt></a><tag::<em>tag-name</em>> const& tag::<em>tag-name</em>::<em>name</em> 6635 = <a class="reference internal" href="#keyword"><tt class="docutils literal">keyword</tt></a><tag::<em>tag-name</em>>::instance; 6636</pre> 6637<p><strong>Else</strong></p> 6638<p>Treats <em>name</em> as if it were of the form:</p> 6639<pre class="literal-block"> 6640forward(<em>tag-name</em>) 6641</pre> 6642</div> 6643<div class="section" id="boost-parameter-template-keyword-name"> 6644<span id="boost-parameter-template-keyword"></span><h2><a class="toc-backref" href="#id77">7.21 <tt class="docutils literal">BOOST_PARAMETER_TEMPLATE_KEYWORD(name)</tt></a></h2> 6645<table class="docutils field-list" frame="void" rules="none"> 6646<col class="field-name" /> 6647<col class="field-body" /> 6648<tbody valign="top"> 6649<tr class="field"><th class="field-name">Defined in:</th><td class="field-body"><a class="reference external" href="../../../../boost/parameter/template_keyword.hpp">boost/parameter/template_keyword.hpp</a></td> 6650</tr> 6651<tr class="field"><th class="field-name">Included by:</th><td class="field-body"><a class="reference external" href="../../../../boost/parameter/name.hpp">boost/parameter/name.hpp</a></td> 6652</tr> 6653<tr class="field"><th class="field-name">Expands to:</th><td class="field-body"></td> 6654</tr> 6655</tbody> 6656</table> 6657<pre class="literal-block"> 6658namespace tag { 6659 6660 struct <em>name</em>; 6661} 6662 6663template <typename T> 6664struct <em>name</em> : <a class="reference internal" href="#template-keyword"><tt class="docutils literal">template_keyword</tt></a><tag:: <em>name</em>, T> 6665{ 6666}; 6667</pre> 6668<p>The <a class="reference external" href="../../test/function_type_tpl_param.cpp">function_type_tpl_param.cpp</a> test program demonstrates proper usage of 6669this macro.</p> 6670</div> 6671<div class="section" id="boost-parameter-fun-r-n-l-h-p"> 6672<span id="boost-parameter-fun"></span><h2><a class="toc-backref" href="#id78">7.22 <tt class="docutils literal">BOOST_PARAMETER_FUN(r, n, l, h, p)</tt></a></h2> 6673<div class="admonition-deprecated admonition"> 6674<p class="first admonition-title">Deprecated</p> 6675<p class="last">This macro has been deprecated in favor of 6676<tt class="docutils literal">BOOST_PARAMETER_FUNCTION</tt>.</p> 6677</div> 6678<p>Generates a sequence of <a class="reference external" href="index.html#forwarding-functions">forwarding function</a> templates named 6679<tt class="docutils literal">n</tt>, with arities ranging from <tt class="docutils literal">l</tt> to <tt class="docutils literal">h</tt>, returning <tt class="docutils literal">r</tt>, 6680and using <tt class="docutils literal">p</tt> to control overload resolution and assign tags to 6681positional arguments.</p> 6682<table class="docutils field-list" frame="void" rules="none"> 6683<col class="field-name" /> 6684<col class="field-body" /> 6685<tbody valign="top"> 6686<tr class="field"><th class="field-name">Defined in:</th><td class="field-body"><a class="reference external" href="../../../../boost/parameter/macros.hpp">boost/parameter/macros.hpp</a></td> 6687</tr> 6688<tr class="field"><th class="field-name">Requires:</th><td class="field-body"><tt class="docutils literal">l</tt> and <tt class="docutils literal">h</tt> are nonnegative integer tokens 6689such that <tt class="docutils literal">l</tt> < <tt class="docutils literal">h</tt></td> 6690</tr> 6691<tr class="field"><th class="field-name">Expands to:</th><td class="field-body"></td> 6692</tr> 6693</tbody> 6694</table> 6695<pre class="literal-block"> 6696template <typename A1, typename A2, …, typename A ## <strong>l</strong>> 6697r 6698 name( 6699 A1 && a1, A2 && a2, …, A ## <strong>l</strong> && a ## <strong>l</strong> 6700 , typename <strong>p</strong>::match<A1, A2, …, A ## <strong>l</strong>>::type p = <strong>p</strong>() 6701 ) 6702{ 6703 return <strong>name</strong>_with_named_params( 6704 <strong>p</strong>( 6705 <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/forward">std::forward</a><A1>(a1) 6706 , <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/forward">std::forward</a><A2>(a2) 6707 , … 6708 , <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/forward">std::forward</a><A ## <strong>l</strong>>(a ## <strong>l</strong>) 6709 ) 6710 ); 6711} 6712 6713template < 6714 typename A1 6715 , typename A2 6716 , … 6717 , typename A ## <strong>l</strong> 6718 , typename A ## <a class="reference external" href="../../../preprocessor/doc/ref/inc.html">BOOST_PP_INC</a>(<strong>l</strong>) 6719> 6720r 6721 name( 6722 A1 && a1, A2 && a2, …, A ## <strong>l</strong> && a ## <strong>l</strong> 6723 , A ## <a class="reference external" href="../../../preprocessor/doc/ref/inc.html">BOOST_PP_INC</a>(<strong>l</strong>) const& a ## <a class="reference external" href="../../../preprocessor/doc/ref/inc.html">BOOST_PP_INC</a>(<strong>l</strong>) 6724 , typename <strong>p</strong>::match< 6725 A1, A2, …, A ## <strong>l</strong>, A ## <a class="reference external" href="../../../preprocessor/doc/ref/inc.html">BOOST_PP_INC</a>(<strong>l</strong>) 6726 >::type p = <strong>p</strong>() 6727 ) 6728{ 6729 return <strong>name</strong>_with_named_params( 6730 <strong>p</strong>( 6731 <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/forward">std::forward</a><A1>(a1) 6732 , <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/forward">std::forward</a><A2>(a2) 6733 , … 6734 , <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/forward">std::forward</a><A ## <strong>l</strong>>(a ## <strong>l</strong>) 6735 , <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/forward">std::forward</a><A ## <a class="reference external" href="../../../preprocessor/doc/ref/inc.html">BOOST_PP_INC</a>(<strong>l</strong>)>( 6736 a ## <a class="reference external" href="../../../preprocessor/doc/ref/inc.html">BOOST_PP_INC</a>(<strong>l</strong>) 6737 ) 6738 ) 6739 ); 6740} 6741 6742<span class="vellipsis">⋮</span> 6743 6744template <typename A1, typename A2, …, typename A ## <strong>h</strong>> 6745r 6746 name( 6747 A1 && a1, A2 && a2, …, A ## <strong>h</strong> && x ## <strong>h</strong> 6748 , typename <strong>p</strong>::match<A1, A2, …, A ## <strong>h</strong>>::type p = <strong>p</strong>() 6749 ) 6750{ 6751 return <strong>name</strong>_with_named_params( 6752 <strong>p</strong>( 6753 <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/forward">std::forward</a><A1>(a1) 6754 , <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/forward">std::forward</a><A2>(a2) 6755 , … 6756 , <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/forward">std::forward</a><A ## <strong>h</strong>>(a ## <strong>h</strong>) 6757 ) 6758 ); 6759} 6760</pre> 6761<p>The <a class="reference external" href="../../test/macros.cpp">macros.cpp</a> and <a class="reference external" href="../../test/macros_eval_category.cpp">macros_eval_category.cpp</a> test programs demonstrate proper 6762usage of this macro.</p> 6763</div> 6764<div class="section" id="boost-parameter-keyword-n-k"> 6765<span id="boost-parameter-keyword"></span><h2><a class="toc-backref" href="#id79">7.23 <tt class="docutils literal">BOOST_PARAMETER_KEYWORD(n, k)</tt></a></h2> 6766<div class="admonition-deprecated admonition"> 6767<p class="first admonition-title">Deprecated</p> 6768<p class="last">This macro has been deprecated in favor of 6769<tt class="docutils literal">BOOST_PARAMETER_NAME</tt>.</p> 6770</div> 6771<p>Generates the declaration of a <a class="reference internal" href="#keyword-tag-type">keyword tag type</a> named <tt class="docutils literal">k</tt> in 6772namespace <tt class="docutils literal">n</tt> and a corresponding <a class="reference internal" href="#keyword-object">keyword object</a> definition in 6773the enclosing namespace.</p> 6774<table class="docutils field-list" frame="void" rules="none"> 6775<col class="field-name" /> 6776<col class="field-body" /> 6777<tbody valign="top"> 6778<tr class="field"><th class="field-name">Defined in:</th><td class="field-body"><a class="reference external" href="../../../../boost/parameter/keyword.hpp">boost/parameter/keyword.hpp</a></td> 6779</tr> 6780<tr class="field"><th class="field-name">Expands to:</th><td class="field-body"></td> 6781</tr> 6782</tbody> 6783</table> 6784<pre class="literal-block"> 6785namespace <strong>n</strong> { 6786 6787 struct <strong>k</strong> 6788 { 6789 static constexpr char const* keyword_name() 6790 { 6791 return ## <em>k</em>; 6792 } 6793 6794 typedef <em>unspecified</em> _; 6795 typedef <em>unspecified</em> _1; 6796 typedef boost::parameter::forward_reference qualifier; 6797 6798 // The following definitions are available only when 6799 // <a class="reference internal" href="#boost-parameter-can-use-mp11"><tt class="docutils literal">BOOST_PARAMETER_CAN_USE_MP11</tt></a> is defined. 6800 6801 template <typename ArgumentPack> 6802 using binding_fn = typename <a class="reference internal" href="#binding"><tt class="docutils literal">binding</tt></a>< 6803 ArgumentPack 6804 , <em>k</em> 6805 >::type; 6806 6807 template <typename ArgumentPack> 6808 using fn = typename <a class="reference internal" href="#value-type"><tt class="docutils literal">value_type</tt></a><ArgumentPack, <em>k</em>>::type; 6809 }; 6810} 6811 6812namespace { 6813 6814 <a class="reference internal" href="#keyword"><tt class="docutils literal">keyword</tt></a><<em>n</em>::<strong>k</strong>> const& <strong>k</strong> 6815 = <a class="reference internal" href="#keyword"><tt class="docutils literal">keyword</tt></a><<em>n</em>::<strong>k</strong>>::instance; 6816} 6817</pre> 6818</div> 6819<div class="section" id="boost-parameter-match-p-a-x"> 6820<h2><a class="toc-backref" href="#id80">7.24 <tt class="docutils literal">BOOST_PARAMETER_MATCH(p, a, x)</tt></a></h2> 6821<p>Generates a defaulted parameter declaration for a <a class="reference external" href="index.html#forwarding-functions">forwarding function</a>.</p> 6822<table class="docutils field-list" frame="void" rules="none"> 6823<col class="field-name" /> 6824<col class="field-body" /> 6825<tbody valign="top"> 6826<tr class="field"><th class="field-name">Defined in:</th><td class="field-body"><a class="reference external" href="../../../../boost/parameter/match.hpp">boost/parameter/match.hpp</a></td> 6827</tr> 6828<tr class="field"><th class="field-name">Requires:</th><td class="field-body"><tt class="docutils literal">a</tt> is a <a class="reference external" href="../../../preprocessor/doc/data.html">Boost.Preprocessor sequence</a> of the form</td> 6829</tr> 6830</tbody> 6831</table> 6832<pre class="literal-block"> 6833(A0)(A1)…(A ## <em>n</em>) 6834</pre> 6835<table class="docutils field-list" frame="void" rules="none"> 6836<col class="field-name" /> 6837<col class="field-body" /> 6838<tbody valign="top"> 6839<tr class="field"><th class="field-name">Expands to:</th><td class="field-body"></td> 6840</tr> 6841</tbody> 6842</table> 6843<pre class="literal-block"> 6844typename <strong>p</strong>::match<<strong>A0</strong>, <strong>A1</strong>, …, <strong>A</strong> ## <em>n</em>>::type 6845 <strong>x</strong> = <strong>p</strong>() 6846</pre> 6847</div> 6848</div> 6849<div class="section" id="configuration-macros"> 6850<h1><a class="toc-backref" href="#id81">8 Configuration Macros</a></h1> 6851<div class="section" id="id21"> 6852<span id="boost-parameter-has-perfect-forwarding"></span><h2><a class="toc-backref" href="#id82">8.1 <tt class="docutils literal">BOOST_PARAMETER_HAS_PERFECT_FORWARDING</tt></a></h2> 6853<p>Determines whether or not the library supports perfect forwarding, or the 6854preservation of parameter value categories. Users can manually disable this 6855macro by <tt class="docutils literal">#defining</tt> the <a class="reference internal" href="#boost-parameter-disable-perfect-forwarding"><tt class="docutils literal">BOOST_PARAMETER_DISABLE_PERFECT_FORWARDING</tt></a> 6856macro. Otherwise, the library will <tt class="docutils literal">#define</tt> this macro if and only if it 6857is not already defined, and if the configuration macros 6858<a class="reference external" href="../../../config/doc/html/boost_config/boost_macro_reference.html#boost_config.boost_macro_reference.macros_that_describe_c__03_defects"><tt class="docutils literal">BOOST_NO_FUNCTION_TEMPLATE_ORDERING</tt></a>, <a class="reference external" href="../../../config/doc/html/boost_config/boost_macro_reference.html#boost_config.boost_macro_reference.macros_that_describe_c__03_defects"><tt class="docutils literal">BOOST_NO_SFINAE</tt></a>, 6859<a class="reference external" href="../../../config/doc/html/boost_config/boost_macro_reference.html#boost_config.boost_macro_reference.macros_that_describe_c__11_features_not_supported"><tt class="docutils literal">BOOST_NO_CXX11_RVALUE_REFERENCES</tt></a>, <a class="reference external" href="../../../config/doc/html/boost_config/boost_macro_reference.html#boost_config.boost_macro_reference.macros_that_describe_c__11_features_not_supported"><tt class="docutils literal">BOOST_NO_CXX11_VARIADIC_TEMPLATES</tt></a>, and 6860<a class="reference external" href="../../../config/doc/html/boost_config/boost_macro_reference.html#boost_config.boost_macro_reference.macros_that_describe_c__11_features_not_supported"><tt class="docutils literal">BOOST_NO_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGS</tt></a> are not already defined by 6861<a class="reference external" href="../../../config/doc/html/index.html">Boost.Config</a>.</p> 6862<table class="docutils field-list" frame="void" rules="none"> 6863<col class="field-name" /> 6864<col class="field-body" /> 6865<tbody valign="top"> 6866<tr class="field"><th class="field-name">Defined in:</th><td class="field-body"><a class="reference external" href="../../../../boost/parameter/config.hpp">boost/parameter/config.hpp</a></td> 6867</tr> 6868</tbody> 6869</table> 6870</div> 6871<div class="section" id="id22"> 6872<span id="boost-parameter-disable-perfect-forwarding"></span><h2><a class="toc-backref" href="#id83">8.2 <tt class="docutils literal">BOOST_PARAMETER_DISABLE_PERFECT_FORWARDING</tt></a></h2> 6873<p>It may be necessary to test user code in case perfect forwarding support is 6874unavailable. Users can <tt class="docutils literal">#define</tt> this macro either in their project 6875settings or before including any library header files. Doing so will leave 6876both <a class="reference internal" href="#boost-parameter-has-perfect-forwarding"><tt class="docutils literal">BOOST_PARAMETER_HAS_PERFECT_FORWARDING</tt></a> and 6877<a class="reference internal" href="#boost-parameter-can-use-mp11"><tt class="docutils literal">BOOST_PARAMETER_CAN_USE_MP11</tt></a> undefined.</p> 6878</div> 6879<div class="section" id="id23"> 6880<span id="boost-parameter-can-use-mp11"></span><h2><a class="toc-backref" href="#id84">8.3 <tt class="docutils literal">BOOST_PARAMETER_CAN_USE_MP11</tt></a></h2> 6881<p>Determines whether or not the library can use <a class="reference external" href="../../../mp11/doc/html/mp11.html">Boost.MP11</a>, a C++11 6882metaprogramming library. Users can manually disable this macro by 6883<tt class="docutils literal">#defining</tt> the <a class="reference internal" href="#boost-parameter-disable-mp11-usage"><tt class="docutils literal">BOOST_PARAMETER_DISABLE_MP11_USAGE</tt></a> macro or the 6884<a class="reference internal" href="#boost-parameter-disable-perfect-forwarding"><tt class="docutils literal">BOOST_PARAMETER_DISABLE_PERFECT_FORWARDING</tt></a> macro. Otherwise, the library 6885will <tt class="docutils literal">#define</tt> this macro if and only if it is not already defined, if 6886<a class="reference internal" href="#boost-parameter-has-perfect-forwarding"><tt class="docutils literal">BOOST_PARAMETER_HAS_PERFECT_FORWARDING</tt></a> is defined, and if the configuration 6887macros <a class="reference external" href="../../../config/doc/html/boost_config/boost_macro_reference.html#boost_config.boost_macro_reference.macros_that_describe_c__11_features_not_supported"><tt class="docutils literal">BOOST_NO_CXX11_CONSTEXPR</tt></a>, <a class="reference external" href="../../../config/doc/html/boost_config/boost_macro_reference.html#boost_config.boost_macro_reference.macros_that_describe_c__11_features_not_supported"><tt class="docutils literal">BOOST_NO_CXX11_DECLTYPE_N3276</tt></a>, 6888<a class="reference external" href="../../../config/doc/html/boost_config/boost_macro_reference.html#boost_config.boost_macro_reference.macros_that_describe_c__11_features_not_supported"><tt class="docutils literal">BOOST_NO_CXX11_AUTO_DECLARATIONS</tt></a>, <a class="reference external" href="../../../config/doc/html/boost_config/boost_macro_reference.html#boost_config.boost_macro_reference.macros_that_describe_c__11_features_not_supported"><tt class="docutils literal">BOOST_NO_CXX11_TEMPLATE_ALIASES</tt></a>, 6889<a class="reference external" href="../../../config/doc/html/boost_config/boost_macro_reference.html#boost_config.boost_macro_reference.macros_that_describe_c__11_features_not_supported"><tt class="docutils literal">BOOST_NO_CXX11_STATIC_ASSERT</tt></a>, <a class="reference external" href="../../../config/doc/html/boost_config/boost_macro_reference.html#boost_config.boost_macro_reference.macros_that_describe_c__11_features_not_supported"><tt class="docutils literal">BOOST_NO_CXX11_HDR_TYPE_TRAITS</tt></a>, 6890<a class="reference external" href="../../../config/doc/html/boost_config/boost_macro_reference.html#boost_config.boost_macro_reference.macros_that_describe_c__11_features_not_supported"><tt class="docutils literal">BOOST_NO_CXX11_HDR_INITIALIZER_LIST</tt></a>, and <a class="reference external" href="../../../config/doc/html/boost_config/boost_macro_reference.html#boost_config.boost_macro_reference.macros_that_describe_c__11_features_not_supported"><tt class="docutils literal">BOOST_NO_CXX11_HDR_TUPLE</tt></a> 6891are not already defined by <a class="reference external" href="../../../config/doc/html/index.html">Boost.Config</a>.</p> 6892<div class="admonition-usage-note admonition"> 6893<p class="first admonition-title">Usage Note</p> 6894<p class="last"><a class="reference external" href="../../../mp11/doc/html/mp11.html">Boost.MP11</a> and <a class="reference external" href="../../../mpl/doc/index.html">Boost.MPL</a> are <strong>not</strong> mutually exclusive. It's 6895perfectly acceptable to specify deduced parameters using both quoted 6896metafunctions and metafunction classes, for example. See 6897<a class="reference external" href="../../test/evaluate_category.cpp">evaluate_category.cpp</a>.</p> 6898</div> 6899<table class="docutils field-list" frame="void" rules="none"> 6900<col class="field-name" /> 6901<col class="field-body" /> 6902<tbody valign="top"> 6903<tr class="field"><th class="field-name">Defined in:</th><td class="field-body"><a class="reference external" href="../../../../boost/parameter/config.hpp">boost/parameter/config.hpp</a></td> 6904</tr> 6905<tr class="field"><th class="field-name">Example usage:</th><td class="field-body"></td> 6906</tr> 6907</tbody> 6908</table> 6909<p>Given the following definitions:</p> 6910<pre class="literal-block"> 6911<a class="reference internal" href="#boost-parameter-name"><tt class="docutils literal">BOOST_PARAMETER_NAME</tt></a>(x) 6912 6913template <typename A0> 6914typename <a class="reference external" href="../../../core/doc/html/core/enable_if.html">boost::enable_if</a><<a class="reference external" href="http://en.cppreference.com/w/cpp/types/is_same">std::is_same</a><int,A0>,int>::type 6915 sfinae(A0 const& a0) 6916{ 6917 return 0; 6918} 6919</pre> 6920<p><a class="reference external" href="../../../mp11/doc/html/mp11.html">Boost.MP11</a> allows deduced parameters to be defined more succinctly:</p> 6921<pre class="literal-block"> 6922template <typename T, typename Args> 6923using predicate = <a class="reference external" href="http://en.cppreference.com/w/cpp/types/is_convertible">std::is_convertible</a><T,char const*>; 6924 6925<a class="reference internal" href="#boost-parameter-function"><tt class="docutils literal">BOOST_PARAMETER_FUNCTION</tt></a>((int), sfinae, tag, 6926 (deduced 6927 (optional 6928 (x 6929 , *(<a class="reference external" href="../../../mp11/doc/html/mp11.html#mp_quotef">boost::mp11::mp_quote</a><predicate>) 6930 , static_cast<char const*>(<a class="reference external" href="http://en.cppreference.com/w/cpp/language/nullptr">std::nullptr</a>) 6931 ) 6932 ) 6933 ) 6934) 6935{ 6936 return 1; 6937} 6938</pre> 6939<p>Without <a class="reference external" href="../../../mp11/doc/html/mp11.html">Boost.MP11</a>, deduced parameter definitions tend to be more verbose:</p> 6940<pre class="literal-block"> 6941struct predicate 6942{ 6943 template <typename T, typename Args> 6944 struct apply 6945 : <a class="reference external" href="../../../mpl/doc/refmanual/if.html">mpl::if_</a>< 6946 <a class="reference external" href="../../../type_traits/doc/html/boost_typetraits/is_convertible.html">boost::is_convertible</a><T,char const*> 6947 , <a class="reference external" href="../../../mpl/doc/refmanual/bool.html">mpl::true_</a> // Still have to convert to a 6948 , <a class="reference external" href="../../../mpl/doc/refmanual/bool.html">mpl::false_</a> // <a class="reference external" href="../../../mpl/doc/refmanual/integral-constant.html">Boolean Integral Constant</a>. 6949 > 6950 { 6951 }; 6952}; 6953 6954<a class="reference internal" href="#boost-parameter-function"><tt class="docutils literal">BOOST_PARAMETER_FUNCTION</tt></a>((int), sfinae, tag, 6955 (deduced 6956 (optional 6957 (x 6958 , *(predicate) 6959 , static_cast<char const*>(<a class="reference external" href="http://en.cppreference.com/w/cpp/language/nullptr">std::nullptr</a>) 6960 ) 6961 ) 6962 ) 6963) 6964{ 6965 return 1; 6966} 6967</pre> 6968<p>Either way, the following assertions will succeed:</p> 6969<pre class="literal-block"> 6970assert(1 == sfinae()); 6971assert(1 == sfinae("foo")); 6972assert(0 == sfinae(1)); 6973</pre> 6974<p>As another example, given the following declarations and definitions:</p> 6975<pre class="literal-block"> 6976<a class="reference internal" href="#boost-parameter-name"><tt class="docutils literal">BOOST_PARAMETER_NAME</tt></a>(x) 6977<a class="reference internal" href="#boost-parameter-name"><tt class="docutils literal">BOOST_PARAMETER_NAME</tt></a>(y) 6978 6979template <typename E, typename Args> 6980void check0(E const& e, Args const& args); 6981 6982template <typename P, typename E, typename ...Args> 6983void check(E const& e, Args const&... args) 6984{ 6985 check0(e, P()(args...)); 6986} 6987</pre> 6988<p>Argument packs qualify as <a class="reference external" href="../../../mp11/doc/html/mp11.html">Boost.MP11</a>-style lists containing 6989<a class="reference internal" href="#keyword-tag-type">keyword tag type</a>s:</p> 6990<pre class="literal-block"> 6991template <typename Args> 6992struct some_functor 6993{ 6994 template <typename K> 6995 void operator()(K&&) const 6996 { 6997 // K is one of tag::x, tag::y, etc. 6998 } 6999}; 7000 7001template <typename E, typename Args> 7002void check0(E const& e, Args const& args) 7003{ 7004 boost::mp11::mp_for_each<E>(some_functor<Args>()); 7005} 7006</pre> 7007<p>The first check determines whether or not the argument type of <tt class="docutils literal">_y</tt> is the 7008same as the reference type of <tt class="docutils literal">_x</tt>, while the second check determines 7009whether or not the argument type of <tt class="docutils literal">_y</tt> is convertible to the value type of 7010<tt class="docutils literal">_x</tt>. Here, it's possible to access the reference and value result types of 7011indexing an argument pack a little more directly:</p> 7012<pre class="literal-block"> 7013// Use mp_bind on tag::x::binding_fn to access the reference type of _x. 7014check< 7015 <a class="reference internal" href="#parameters"><tt class="docutils literal">parameters</tt></a>< 7016 tag::x 7017 , <a class="reference internal" href="#optional"><tt class="docutils literal">optional</tt></a>< 7018 <a class="reference internal" href="#deduced"><tt class="docutils literal">deduced</tt></a><tag::y> 7019 , <a class="reference external" href="../../../mp11/doc/html/mp11.html#mp_bindf_t">boost::mp11::mp_bind</a>< 7020 <a class="reference external" href="http://en.cppreference.com/w/cpp/types/is_same">std::is_same</a> // <a class="reference external" href="../../../type_traits/doc/html/boost_typetraits/is_same.html">boost::is_same</a>, standard version. 7021 , <a class="reference external" href="../../../mp11/doc/html/mp11.html#1_9">boost::mp11::_1</a> // will be bound to the argument type of _y. 7022 , <a class="reference external" href="../../../mp11/doc/html/mp11.html#mp_bindf_t">boost::mp11::mp_bind</a>< 7023 tag::x::binding_fn 7024 , <a class="reference external" href="../../../mp11/doc/html/mp11.html#1_9">boost::mp11::_2</a> // will be bound to the argument pack type. 7025 > 7026 > 7027 > 7028 > 7029>((_x = 0, _y = 1), 0, 1); 7030 7031// Use mp_bind_q on tag::x to access the value type of _x. 7032check< 7033 <a class="reference internal" href="#parameters"><tt class="docutils literal">parameters</tt></a>< 7034 tag::x 7035 , <a class="reference internal" href="#optional"><tt class="docutils literal">optional</tt></a>< 7036 <a class="reference internal" href="#deduced"><tt class="docutils literal">deduced</tt></a><tag::y> 7037 , <a class="reference external" href="../../../mp11/doc/html/mp11.html#mp_bindf_t">boost::mp11::mp_bind</a>< 7038 <a class="reference external" href="http://en.cppreference.com/w/cpp/types/is_convertible">std::is_convertible</a> // <a class="reference external" href="../../../type_traits/doc/html/boost_typetraits/is_convertible.html">boost::is_convertible</a>, standard version. 7039 , <a class="reference external" href="../../../mp11/doc/html/mp11.html#1_9">boost::mp11::_1</a> // will be bound to the argument type of _y. 7040 , <a class="reference external" href="../../../mp11/doc/html/mp11.html#mp_bind_qq_t">boost::mp11::mp_bind_q</a>< 7041 tag::x 7042 , <a class="reference external" href="../../../mp11/doc/html/mp11.html#1_9">boost::mp11::_2</a> // will be bound to the argument pack type. 7043 > 7044 > 7045 > 7046 > 7047>((_x = 0U, _y = 1U), 0U, 1U); 7048</pre> 7049<p>Argument packs still qualify as <a class="reference external" href="../../../mpl/doc/index.html">Boost.MPL</a>-style lists containing 7050<a class="reference internal" href="#keyword-tag-type">keyword tag type</a>s:</p> 7051<pre class="literal-block"> 7052template <typename Args> 7053struct some_functor 7054{ 7055 template <typename K> 7056 void operator()(K) const 7057 { 7058 // K is one of tag::x, tag::y, etc. 7059 } 7060}; 7061 7062template <typename E, typename Args> 7063void check0(E const& e, Args const& args) 7064{ 7065 boost::mpl::for_each<E>(some_functor<Args>()); 7066} 7067</pre> 7068<p>However, without <a class="reference external" href="../../../mp11/doc/html/mp11.html">Boost.MP11</a>, the corresponding checks become a little more 7069verbose:</p> 7070<pre class="literal-block"> 7071check< 7072 <a class="reference internal" href="#parameters"><tt class="docutils literal">parameters</tt></a>< 7073 tag::x 7074 , <a class="reference internal" href="#optional"><tt class="docutils literal">optional</tt></a>< 7075 <a class="reference internal" href="#deduced"><tt class="docutils literal">deduced</tt></a><tag::y> 7076 , <a class="reference external" href="../../../mpl/doc/refmanual/if.html">mpl::if_</a>< 7077 <a class="reference external" href="../../../type_traits/doc/html/boost_typetraits/is_same.html">boost::is_same</a>< 7078 <a class="reference external" href="../../../type_traits/doc/html/boost_typetraits/add_lvalue_reference.html">boost::add_lvalue_reference</a><<a class="reference external" href="../../../mp11/doc/html/mp11.html#1_9">boost::mp11::_1</a>> 7079 , <a class="reference internal" href="#binding"><tt class="docutils literal">binding</tt></a><<a class="reference external" href="../../../mp11/doc/html/mp11.html#1_9">boost::mp11::_2</a>, tag::x> 7080 > 7081 , <a class="reference external" href="../../../mpl/doc/refmanual/bool.html">mpl::true_</a> // Still have to convert to a 7082 , <a class="reference external" href="../../../mpl/doc/refmanual/bool.html">mpl::false_</a> // <a class="reference external" href="../../../mpl/doc/refmanual/integral-constant.html">Boolean Integral Constant</a>. 7083 > 7084 > 7085 > 7086>((_x = 0, _y = 1), 0, 1); 7087 7088// Use tag::x::_ or tag::x::_1 to access the value type of _x. 7089check< 7090 <a class="reference internal" href="#parameters"><tt class="docutils literal">parameters</tt></a>< 7091 tag::x 7092 , <a class="reference internal" href="#optional"><tt class="docutils literal">optional</tt></a>< 7093 <a class="reference internal" href="#deduced"><tt class="docutils literal">deduced</tt></a><tag::y> 7094 , <a class="reference external" href="../../../mpl/doc/refmanual/if.html">mpl::if_</a>< 7095 <a class="reference external" href="../../../type_traits/doc/html/boost_typetraits/is_convertible.html">boost::is_convertible</a><<a class="reference external" href="../../../mp11/doc/html/mp11.html#1_9">boost::mp11::_1</a>, tag::x::_1> 7096 , <a class="reference external" href="../../../mpl/doc/refmanual/bool.html">mpl::true_</a> // Still have to convert to a 7097 , <a class="reference external" href="../../../mpl/doc/refmanual/bool.html">mpl::false_</a> // <a class="reference external" href="../../../mpl/doc/refmanual/integral-constant.html">Boolean Integral Constant</a>. 7098 > 7099 > 7100 > 7101>((_x = 0U, _y = 1U), 0U, 1U); 7102</pre> 7103<p>The <a class="reference external" href="../../test/singular.cpp">singular.cpp</a>, <a class="reference external" href="../../test/compose.cpp">compose.cpp</a>, <a class="reference external" href="../../test/optional_deduced_sfinae.cpp">optional_deduced_sfinae.cpp</a>, and 7104<a class="reference external" href="../../test/deduced_dependent_predicate.cpp">deduced_dependent_predicate.cpp</a> test programs demonstrate proper usage of this 7105macro.</p> 7106</div> 7107<div class="section" id="id24"> 7108<span id="boost-parameter-disable-mp11-usage"></span><h2><a class="toc-backref" href="#id85">8.4 <tt class="docutils literal">BOOST_PARAMETER_DISABLE_MP11_USAGE</tt></a></h2> 7109<p>It may be necessary to disable usage of <a class="reference external" href="../../../mp11/doc/html/mp11.html">Boost.MP11</a> for compilers that 7110cannot support it. Users can <tt class="docutils literal">#define</tt> this macro either in their project 7111settings or before including any library header files. Doing so will leave 7112<a class="reference internal" href="#boost-parameter-can-use-mp11"><tt class="docutils literal">BOOST_PARAMETER_CAN_USE_MP11</tt></a> undefined.</p> 7113</div> 7114<div class="section" id="id25"> 7115<span id="boost-parameter-variadic-mpl-sequence"></span><h2><a class="toc-backref" href="#id86">8.5 <tt class="docutils literal">BOOST_PARAMETER_VARIADIC_MPL_SEQUENCE</tt></a></h2> 7116<p>If <a class="reference internal" href="#boost-parameter-has-perfect-forwarding"><tt class="docutils literal">BOOST_PARAMETER_HAS_PERFECT_FORWARDING</tt></a> is <tt class="docutils literal">#defined</tt>, then determines 7117the <a class="reference external" href="../../../mpl/doc/refmanual/variadic-sequence.html">MPL Variadic Sequence</a> underlying the nested <tt class="docutils literal">parameter_spec</tt> type of 7118<tt class="docutils literal">parameters</tt>. If the user does not manually <tt class="docutils literal">#define</tt> this macro, then the 7119library will <tt class="docutils literal">#define</tt> it as <a class="reference external" href="../../../mp11/doc/html/mp11.html#mp_listt"><tt class="docutils literal"><span class="pre">boost::mp11::mp_list</span></tt></a> if 7120<a class="reference internal" href="#boost-parameter-can-use-mp11"><tt class="docutils literal">BOOST_PARAMETER_CAN_USE_MP11</tt></a> is defined, <a class="reference external" href="../../../fusion/doc/html/fusion/container/list.html"><tt class="docutils literal"><span class="pre">boost::fusion::list</span></tt></a> if 7121<a class="reference external" href="../../../../boost/fusion/container/list/list_fwd.hpp"><tt class="docutils literal">BOOST_FUSION_HAS_VARIADIC_LIST</tt></a> is defined (by <a class="reference external" href="../../../fusion/doc/html/index.html">Boost.Fusion</a>), 7122<a class="reference external" href="../../../fusion/doc/html/fusion/container/deque.html"><tt class="docutils literal"><span class="pre">boost::fusion::deque</span></tt></a> if <a class="reference external" href="../../../../boost/fusion/container/deque/deque_fwd.hpp"><tt class="docutils literal">BOOST_FUSION_HAS_VARIADIC_DEQUE</tt></a> is defined 7123(by <a class="reference external" href="../../../fusion/doc/html/index.html">Boost.Fusion</a>), or <a class="reference external" href="../../../mpl/doc/refmanual/vector.html"><tt class="docutils literal"><span class="pre">boost::mpl::vector</span></tt></a> otherwise.</p> 7124<table class="docutils field-list" frame="void" rules="none"> 7125<col class="field-name" /> 7126<col class="field-body" /> 7127<tbody valign="top"> 7128<tr class="field"><th class="field-name">Example:</th><td class="field-body"></td> 7129</tr> 7130</tbody> 7131</table> 7132<pre class="literal-block"> 7133#define BOOST_PARAMETER_VARIADIC_MPL_SEQUENCE <a class="reference external" href="../../../fusion/doc/html/fusion/container/vector.html"><tt class="docutils literal"><span class="pre">boost::fusion::vector</span></tt></a> 7134</pre> 7135<table class="docutils field-list" frame="void" rules="none"> 7136<col class="field-name" /> 7137<col class="field-body" /> 7138<tbody valign="top"> 7139<tr class="field"><th class="field-name">Defined in:</th><td class="field-body"><a class="reference external" href="../../../../boost/parameter/parameters.hpp">boost/parameter/parameters.hpp</a></td> 7140</tr> 7141</tbody> 7142</table> 7143</div> 7144<div class="section" id="id26"> 7145<span id="boost-parameter-max-arity"></span><h2><a class="toc-backref" href="#id87">8.6 <tt class="docutils literal">BOOST_PARAMETER_MAX_ARITY</tt></a></h2> 7146<p>If <a class="reference internal" href="#boost-parameter-has-perfect-forwarding"><tt class="docutils literal">BOOST_PARAMETER_HAS_PERFECT_FORWARDING</tt></a> is <tt class="docutils literal">#defined</tt>, then:</p> 7147<ul class="simple"> 7148<li>If the <a class="reference external" href="../../../mpl/doc/refmanual/variadic-sequence.html">MPL Variadic Sequence</a> underlying the nested <tt class="docutils literal">parameter_spec</tt> 7149type of <tt class="docutils literal">parameters</tt> does not have a size limit--which is the case with 7150<a class="reference external" href="../../../mp11/doc/html/mp11.html#mp_listt"><tt class="docutils literal"><span class="pre">boost::mp11::mp_list</span></tt></a>, <a class="reference external" href="../../../fusion/doc/html/fusion/container/list.html"><tt class="docutils literal"><span class="pre">boost::fusion::list</span></tt></a>, and <a class="reference external" href="../../../fusion/doc/html/fusion/container/deque.html"><tt class="docutils literal"><span class="pre">boost::fusion::deque</span></tt></a>, but not 7151<a class="reference external" href="../../../mpl/doc/refmanual/vector.html"><tt class="docutils literal"><span class="pre">boost::mpl::vector</span></tt></a>--then this macro can be safely ignored. User code that 7152manually defines <a class="reference internal" href="#boost-parameter-variadic-mpl-sequence"><tt class="docutils literal">BOOST_PARAMETER_VARIADIC_MPL_SEQUENCE</tt></a> should also 7153manually define this macro to the size limit of the sequence if it has 7154one.</li> 7155</ul> 7156<p>If <a class="reference internal" href="#boost-parameter-has-perfect-forwarding"><tt class="docutils literal">BOOST_PARAMETER_HAS_PERFECT_FORWARDING</tt></a> is <strong>not</strong> <tt class="docutils literal">#defined</tt>, then:</p> 7157<ul class="simple"> 7158<li>Mutable references must be wrapped by <a class="reference external" href="../../../core/doc/html/core/ref.html"><tt class="docutils literal"><span class="pre">boost::ref</span></tt></a> or <a class="reference external" href="http://en.cppreference.com/w/cpp/utility/functional/ref"><tt class="docutils literal"><span class="pre">std::ref</span></tt></a> if passed 7159by position to Boost.Parameter-enabled functions with arity greater than 7160or equal to <a class="reference internal" href="#boost-parameter-exponential-overload-threshold-arity"><tt class="docutils literal">BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY</tt></a>.</li> 7161</ul> 7162<table class="docutils field-list" frame="void" rules="none"> 7163<col class="field-name" /> 7164<col class="field-body" /> 7165<tbody valign="top"> 7166<tr class="field"><th class="field-name">Defined in:</th><td class="field-body"><a class="reference external" href="../../../../boost/parameter/config.hpp">boost/parameter/config.hpp</a></td> 7167</tr> 7168<tr class="field"><th class="field-name">Default Value:</th><td class="field-body"><a class="reference external" href="../../../mpl/doc/refmanual/limit-vector-size.html"><tt class="docutils literal">BOOST_MPL_LIMIT_VECTOR_SIZE</tt></a> (defined by <a class="reference external" href="../../../mpl/doc/index.html">Boost.MPL</a>) if 7169perfect forwarding is supported, <tt class="docutils literal">8</tt> otherwise.</td> 7170</tr> 7171<tr class="field"><th class="field-name">Minimum Value:</th><td class="field-body"><tt class="docutils literal">2</tt></td> 7172</tr> 7173<tr class="field"><th class="field-name">Maximum Value:</th><td class="field-body"><a class="reference internal" href="#boost-parameter-compose-max-arity"><tt class="docutils literal">BOOST_PARAMETER_COMPOSE_MAX_ARITY</tt></a></td> 7174</tr> 7175</tbody> 7176</table> 7177</div> 7178<div class="section" id="id27"> 7179<span id="boost-parameter-compose-max-arity"></span><h2><a class="toc-backref" href="#id88">8.7 <tt class="docutils literal">BOOST_PARAMETER_COMPOSE_MAX_ARITY</tt></a></h2> 7180<p>If <a class="reference internal" href="#boost-parameter-has-perfect-forwarding"><tt class="docutils literal">BOOST_PARAMETER_HAS_PERFECT_FORWARDING</tt></a> is <strong>not</strong> <tt class="docutils literal">#defined</tt>, then 7181determines the maximum number of arguments supported by the <tt class="docutils literal">compose</tt> function 7182and by the <a class="reference internal" href="#boost-parameter-no-spec-function"><tt class="docutils literal">BOOST_PARAMETER_NO_SPEC_FUNCTION</tt></a>, 7183<a class="reference internal" href="#boost-parameter-no-spec-member-function"><tt class="docutils literal">BOOST_PARAMETER_NO_SPEC_MEMBER_FUNCTION</tt></a>, 7184<a class="reference internal" href="#boost-parameter-no-spec-const-member-function"><tt class="docutils literal">BOOST_PARAMETER_NO_SPEC_CONST_MEMBER_FUNCTION</tt></a>, 7185<a class="reference internal" href="#boost-parameter-no-spec-function-call-operator"><tt class="docutils literal">BOOST_PARAMETER_NO_SPEC_FUNCTION_CALL_OPERATOR</tt></a>, 7186<a class="reference internal" href="#boost-parameter-no-spec-const-function-call-operator"><tt class="docutils literal">BOOST_PARAMETER_NO_SPEC_CONST_FUNCTION_CALL_OPERATOR</tt></a>, 7187<a class="reference internal" href="#boost-parameter-no-spec-constructor"><tt class="docutils literal">BOOST_PARAMETER_NO_SPEC_CONSTRUCTOR</tt></a>, and 7188<a class="reference internal" href="#boost-parameter-no-spec-no-base-constructor"><tt class="docutils literal">BOOST_PARAMETER_NO_SPEC_NO_BASE_CONSTRUCTOR</tt></a> code generation macros.</p> 7189<table class="docutils field-list" frame="void" rules="none"> 7190<col class="field-name" /> 7191<col class="field-body" /> 7192<tbody valign="top"> 7193<tr class="field"><th class="field-name">Defined in:</th><td class="field-body"><a class="reference external" href="../../../../boost/parameter/config.hpp">boost/parameter/config.hpp</a></td> 7194</tr> 7195<tr class="field"><th class="field-name">Default Value:</th><td class="field-body"><tt class="docutils literal">20</tt> for a few older compilers, <tt class="docutils literal">64</tt> otherwise</td> 7196</tr> 7197<tr class="field"><th class="field-name">Minimum Value:</th><td class="field-body"><tt class="docutils literal">2</tt></td> 7198</tr> 7199</tbody> 7200</table> 7201</div> 7202<div class="section" id="id28"> 7203<span id="boost-parameter-exponential-overload-threshold-arity"></span><h2><a class="toc-backref" href="#id89">8.8 <tt class="docutils literal">BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY</tt></a></h2> 7204<p>If this library does <strong>not</strong> support perfect forwarding, determines the number 7205of arguments less than which <tt class="docutils literal">parameters</tt> generates an exponential number of 7206function call operator overloads, and greater than or equal to which 7207<tt class="docutils literal">parameters</tt> does not. Will only be <tt class="docutils literal">#defined</tt> by the library if it is 7208not already <tt class="docutils literal">#defined</tt> and <a class="reference internal" href="#boost-parameter-has-perfect-forwarding"><tt class="docutils literal">BOOST_PARAMETER_HAS_PERFECT_FORWARDING</tt></a> is 7209<strong>not</strong> <tt class="docutils literal">#defined</tt>.</p> 7210<table class="docutils field-list" frame="void" rules="none"> 7211<col class="field-name" /> 7212<col class="field-body" /> 7213<tbody valign="top"> 7214<tr class="field"><th class="field-name">Defined in:</th><td class="field-body"><a class="reference external" href="../../../../boost/parameter/config.hpp">boost/parameter/config.hpp</a></td> 7215</tr> 7216<tr class="field"><th class="field-name">Default Value:</th><td class="field-body"><tt class="docutils literal">0</tt></td> 7217</tr> 7218<tr class="field"><th class="field-name">Minimum Value:</th><td class="field-body"><tt class="docutils literal">0</tt></td> 7219</tr> 7220</tbody> 7221</table> 7222</div> 7223<div class="section" id="outside-of-this-library"> 7224<h2><a class="toc-backref" href="#id90">8.9 ...Outside Of This Library</a></h2> 7225<ol class="arabic simple"> 7226<li>If <a class="reference external" href="../../../config/doc/html/index.html">Boost.Config</a> defines the macro 7227<a class="reference external" href="../../../config/doc/html/boost_config/boost_macro_reference.html#boost_config.boost_macro_reference.macros_that_describe_c__03_defects"><tt class="docutils literal">BOOST_NO_FUNCTION_TEMPLATE_ORDERING</tt></a>, then the macros 7228<a class="reference internal" href="#boost-parameter-has-perfect-forwarding"><tt class="docutils literal">BOOST_PARAMETER_HAS_PERFECT_FORWARDING</tt></a> and 7229<a class="reference internal" href="#boost-parameter-can-use-mp11"><tt class="docutils literal">BOOST_PARAMETER_CAN_USE_MP11</tt></a> will be left undefined; otherwise, the 7230code generation macros would not work correctly.</li> 7231<li>If <a class="reference external" href="../../../config/doc/html/index.html">Boost.Config</a> defines the macro <a class="reference external" href="../../../config/doc/html/boost_config/boost_macro_reference.html#boost_config.boost_macro_reference.macros_that_describe_c__03_defects"><tt class="docutils literal">BOOST_NO_SFINAE</tt></a>, then the macros 7232<a class="reference internal" href="#boost-parameter-has-perfect-forwarding"><tt class="docutils literal">BOOST_PARAMETER_HAS_PERFECT_FORWARDING</tt></a> and 7233<a class="reference internal" href="#boost-parameter-can-use-mp11"><tt class="docutils literal">BOOST_PARAMETER_CAN_USE_MP11</tt></a> will be left undefined; otherwise, keyword 7234types generated by <a class="reference internal" href="#boost-parameter-name"><tt class="docutils literal">BOOST_PARAMETER_NAME</tt></a> and 7235<a class="reference internal" href="#boost-parameter-nested-keyword"><tt class="docutils literal">BOOST_PARAMETER_NESTED_KEYWORD</tt></a> would not work correctly.</li> 7236<li>If <a class="reference external" href="../../../config/doc/html/index.html">Boost.Config</a> defines the macro 7237<a class="reference external" href="../../../config/doc/html/boost_config/boost_macro_reference.html#boost_config.boost_macro_reference.macros_that_describe_c__11_features_not_supported"><tt class="docutils literal">BOOST_NO_CXX11_RVALUE_REFERENCES</tt></a>, then the macros 7238<a class="reference internal" href="#boost-parameter-has-perfect-forwarding"><tt class="docutils literal">BOOST_PARAMETER_HAS_PERFECT_FORWARDING</tt></a> and 7239<a class="reference internal" href="#boost-parameter-can-use-mp11"><tt class="docutils literal">BOOST_PARAMETER_CAN_USE_MP11</tt></a> will be left undefined.</li> 7240<li>If <a class="reference external" href="../../../config/doc/html/index.html">Boost.Config</a> defines the macro <a class="reference external" href="../../../config/doc/html/boost_config/boost_macro_reference.html#boost_config.boost_macro_reference.macros_that_describe_c__11_features_not_supported"><tt class="docutils literal">BOOST_NO_CXX11_VARIADIC_TEMPLATES</tt></a>, 7241then the macros <a class="reference internal" href="#boost-parameter-has-perfect-forwarding"><tt class="docutils literal">BOOST_PARAMETER_HAS_PERFECT_FORWARDING</tt></a> and 7242<a class="reference internal" href="#boost-parameter-can-use-mp11"><tt class="docutils literal">BOOST_PARAMETER_CAN_USE_MP11</tt></a> will be left undefined.</li> 7243<li>If <a class="reference external" href="../../../config/doc/html/index.html">Boost.Config</a> defines the macro 7244<a class="reference external" href="../../../config/doc/html/boost_config/boost_macro_reference.html#boost_config.boost_macro_reference.macros_that_describe_c__11_features_not_supported"><tt class="docutils literal">BOOST_NO_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGS</tt></a>, then the macros 7245<a class="reference internal" href="#boost-parameter-has-perfect-forwarding"><tt class="docutils literal">BOOST_PARAMETER_HAS_PERFECT_FORWARDING</tt></a> and 7246<a class="reference internal" href="#boost-parameter-can-use-mp11"><tt class="docutils literal">BOOST_PARAMETER_CAN_USE_MP11</tt></a> will be left undefined.</li> 7247<li>If <a class="reference external" href="../../../config/doc/html/index.html">Boost.Config</a> defines the macro <a class="reference external" href="../../../config/doc/html/boost_config/boost_macro_reference.html#boost_config.boost_macro_reference.macros_that_describe_c__11_features_not_supported"><tt class="docutils literal">BOOST_NO_CXX11_CONSTEXPR</tt></a>, then the 7248macro <a class="reference internal" href="#boost-parameter-can-use-mp11"><tt class="docutils literal">BOOST_PARAMETER_CAN_USE_MP11</tt></a> will be left undefined.</li> 7249<li>If <a class="reference external" href="../../../config/doc/html/index.html">Boost.Config</a> defines the macro <a class="reference external" href="../../../config/doc/html/boost_config/boost_macro_reference.html#boost_config.boost_macro_reference.macros_that_describe_c__11_features_not_supported"><tt class="docutils literal">BOOST_NO_CXX11_DECLTYPE_N3276</tt></a>, 7250then the macro <a class="reference internal" href="#boost-parameter-can-use-mp11"><tt class="docutils literal">BOOST_PARAMETER_CAN_USE_MP11</tt></a> will be left undefined.</li> 7251<li>If <a class="reference external" href="../../../config/doc/html/index.html">Boost.Config</a> defines the macro <a class="reference external" href="../../../config/doc/html/boost_config/boost_macro_reference.html#boost_config.boost_macro_reference.macros_that_describe_c__11_features_not_supported"><tt class="docutils literal">BOOST_NO_CXX11_AUTO_DECLARATIONS</tt></a>, 7252then the macro <a class="reference internal" href="#boost-parameter-can-use-mp11"><tt class="docutils literal">BOOST_PARAMETER_CAN_USE_MP11</tt></a> will be left undefined.</li> 7253<li>If <a class="reference external" href="../../../config/doc/html/index.html">Boost.Config</a> defines the macro <a class="reference external" href="../../../config/doc/html/boost_config/boost_macro_reference.html#boost_config.boost_macro_reference.macros_that_describe_c__11_features_not_supported"><tt class="docutils literal">BOOST_NO_CXX11_TEMPLATE_ALIASES</tt></a>, 7254then the macro <a class="reference internal" href="#boost-parameter-can-use-mp11"><tt class="docutils literal">BOOST_PARAMETER_CAN_USE_MP11</tt></a> will be left undefined.</li> 7255<li>If <a class="reference external" href="../../../config/doc/html/index.html">Boost.Config</a> defines the macro <a class="reference external" href="../../../config/doc/html/boost_config/boost_macro_reference.html#boost_config.boost_macro_reference.macros_that_describe_c__11_features_not_supported"><tt class="docutils literal">BOOST_NO_CXX11_STATIC_ASSERT</tt></a>, then 7256the macro <a class="reference internal" href="#boost-parameter-can-use-mp11"><tt class="docutils literal">BOOST_PARAMETER_CAN_USE_MP11</tt></a> will be left undefined.</li> 7257<li>If <a class="reference external" href="../../../config/doc/html/index.html">Boost.Config</a> defines the macro <a class="reference external" href="../../../config/doc/html/boost_config/boost_macro_reference.html#boost_config.boost_macro_reference.macros_that_describe_c__11_features_not_supported"><tt class="docutils literal">BOOST_NO_CXX11_HDR_TYPE_TRAITS</tt></a>, 7258then the macro <a class="reference internal" href="#boost-parameter-can-use-mp11"><tt class="docutils literal">BOOST_PARAMETER_CAN_USE_MP11</tt></a> will be left undefined.</li> 7259<li>If <a class="reference external" href="../../../config/doc/html/index.html">Boost.Config</a> defines the macro 7260<a class="reference external" href="../../../config/doc/html/boost_config/boost_macro_reference.html#boost_config.boost_macro_reference.macros_that_describe_c__11_features_not_supported"><tt class="docutils literal">BOOST_NO_CXX11_HDR_INITIALIZER_LIST</tt></a>, then the macro 7261<a class="reference internal" href="#boost-parameter-can-use-mp11"><tt class="docutils literal">BOOST_PARAMETER_CAN_USE_MP11</tt></a> will be left undefined.</li> 7262<li>If <a class="reference external" href="../../../config/doc/html/index.html">Boost.Config</a> defines the macro <a class="reference external" href="../../../config/doc/html/boost_config/boost_macro_reference.html#boost_config.boost_macro_reference.macros_that_describe_c__11_features_not_supported"><tt class="docutils literal">BOOST_NO_CXX11_HDR_TUPLE</tt></a>, then the 7263macro <a class="reference internal" href="#boost-parameter-can-use-mp11"><tt class="docutils literal">BOOST_PARAMETER_CAN_USE_MP11</tt></a> will be left undefined.</li> 7264<li>If <a class="reference external" href="../../../fusion/doc/html/index.html">Boost.Fusion</a> defines the macro <a class="reference external" href="../../../../boost/fusion/container/list/list_fwd.hpp"><tt class="docutils literal">BOOST_FUSION_HAS_VARIADIC_LIST</tt></a>, 7265if this library defines the macro 7266<a class="reference internal" href="#boost-parameter-has-perfect-forwarding"><tt class="docutils literal">BOOST_PARAMETER_HAS_PERFECT_FORWARDING</tt></a>, and if 7267<a class="reference internal" href="#boost-parameter-variadic-mpl-sequence"><tt class="docutils literal">BOOST_PARAMETER_VARIADIC_MPL_SEQUENCE</tt></a> is left undefined, then the 7268<a class="reference external" href="../../../mpl/doc/refmanual/variadic-sequence.html">MPL Variadic Sequence</a> underlying the nested <tt class="docutils literal">parameter_spec</tt> type of 7269<tt class="docutils literal">parameters</tt> will be <a class="reference external" href="../../../fusion/doc/html/fusion/container/list.html"><tt class="docutils literal"><span class="pre">boost::fusion::list</span></tt></a>.</li> 7270<li>If <a class="reference external" href="../../../fusion/doc/html/index.html">Boost.Fusion</a> defines the macro <a class="reference external" href="../../../../boost/fusion/container/deque/deque_fwd.hpp"><tt class="docutils literal">BOOST_FUSION_HAS_VARIADIC_DEQUE</tt></a>, 7271if this library defines the macro 7272<a class="reference internal" href="#boost-parameter-has-perfect-forwarding"><tt class="docutils literal">BOOST_PARAMETER_HAS_PERFECT_FORWARDING</tt></a>, and if 7273<a class="reference internal" href="#boost-parameter-variadic-mpl-sequence"><tt class="docutils literal">BOOST_PARAMETER_VARIADIC_MPL_SEQUENCE</tt></a> is left undefined, then the 7274<a class="reference external" href="../../../mpl/doc/refmanual/variadic-sequence.html">MPL Variadic Sequence</a> underlying the nested <tt class="docutils literal">parameter_spec</tt> type of 7275<tt class="docutils literal">parameters</tt> will be <a class="reference external" href="../../../fusion/doc/html/fusion/container/deque.html"><tt class="docutils literal"><span class="pre">boost::fusion::deque</span></tt></a>.</li> 7276<li>The value that <a class="reference external" href="../../../mpl/doc/index.html">Boost.MPL</a> defines the macro 7277<a class="reference external" href="../../../mpl/doc/refmanual/limit-vector-size.html"><tt class="docutils literal">BOOST_MPL_LIMIT_VECTOR_SIZE</tt></a> as will be the value that this library 7278defines the macro <a class="reference internal" href="#boost-parameter-max-arity"><tt class="docutils literal">BOOST_PARAMETER_MAX_ARITY</tt></a> as if this library defines 7279the macro <a class="reference internal" href="#boost-parameter-has-perfect-forwarding"><tt class="docutils literal">BOOST_PARAMETER_HAS_PERFECT_FORWARDING</tt></a>.</li> 7280</ol> 7281</div> 7282</div> 7283<div class="section" id="tutorial"> 7284<h1><a class="toc-backref" href="#id91">9 Tutorial</a></h1> 7285<p>Follow <a class="reference external" href="index.html#tutorial">this link</a> to the Boost.Parameter tutorial documentation.</p> 7286<hr class="docutils" /> 7287<table class="docutils footnote" frame="void" id="thread" rules="none"> 7288<colgroup><col class="label" /><col /></colgroup> 7289<tbody valign="top"> 7290<tr><td class="label"><a class="fn-backref" href="#id2">[1]</a></td><td>References to tag objects may be initialized multiple 7291times. This scenario can only occur in the presence of 7292threading. Because the C++ standard doesn't consider threading, 7293it doesn't explicitly allow or forbid multiple initialization of 7294references. That said, it's hard to imagine an implementation 7295where it could make a difference.</td></tr> 7296</tbody> 7297</table> 7298<table class="docutils footnote" frame="void" id="no-result-of" rules="none"> 7299<colgroup><col class="label" /><col /></colgroup> 7300<tbody valign="top"> 7301<tr><td class="label">[2]</td><td><em>(<a class="fn-backref" href="#id6">1</a>, <a class="fn-backref" href="#id12">2</a>, <a class="fn-backref" href="#id15">3</a>)</em> Where <a class="reference external" href="../../../utility/utility.htm#BOOST_NO_RESULT_OF"><tt class="docutils literal">BOOST_NO_RESULT_OF</tt></a> is <tt class="docutils literal">#defined</tt>, 7302<a class="reference external" href="../../../utility/utility.htm#result_of"><tt class="docutils literal"><span class="pre">boost::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> 7303</tbody> 7304</table> 7305</div> 7306</div> 7307<div class="footer"> 7308<hr class="footer" /> 7309Generated on: 2020-08-11 14:59 UTC. 7310Generated by <a class="reference external" href="http://docutils.sourceforge.net/">Docutils</a> from <a class="reference external" href="http://docutils.sourceforge.net/rst.html">reStructuredText</a> source. 7311 7312</div> 7313</body> 7314</html> 7315