| [12] | 1 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|---|
| 2 | The Boost Parameter Library Reference Documentation |
|---|
| 3 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|---|
| 4 | |
|---|
| 5 | |(logo)|__ |
|---|
| 6 | |
|---|
| 7 | .. |(logo)| image:: ../../../../boost.png |
|---|
| 8 | :alt: Boost |
|---|
| 9 | |
|---|
| 10 | __ ../../../../index.htm |
|---|
| 11 | |
|---|
| 12 | :Authors: David Abrahams, Daniel Wallin |
|---|
| 13 | :Contact: dave@boost-consulting.com, dalwan01@student.umu.se |
|---|
| 14 | :organization: `Boost Consulting`_ |
|---|
| 15 | :date: $Date: 2005/07/17 19:53:01 $ |
|---|
| 16 | |
|---|
| 17 | :copyright: Copyright David Abrahams, Daniel Wallin |
|---|
| 18 | 2005. Distributed under the Boost Software License, |
|---|
| 19 | Version 1.0. (See accompanying file LICENSE_1_0.txt |
|---|
| 20 | or copy at http://www.boost.org/LICENSE_1_0.txt) |
|---|
| 21 | |
|---|
| 22 | .. _`Boost Consulting`: http://www.boost-consulting.com |
|---|
| 23 | |
|---|
| 24 | |
|---|
| 25 | ////////////////////////////////////////////////////////////////////////////// |
|---|
| 26 | |
|---|
| 27 | .. contents:: |
|---|
| 28 | :depth: 2 |
|---|
| 29 | |
|---|
| 30 | ////////////////////////////////////////////////////////////////////////////// |
|---|
| 31 | |
|---|
| 32 | .. role:: class |
|---|
| 33 | :class: class |
|---|
| 34 | |
|---|
| 35 | .. role:: concept |
|---|
| 36 | :class: concept |
|---|
| 37 | |
|---|
| 38 | .. role:: function |
|---|
| 39 | :class: function |
|---|
| 40 | |
|---|
| 41 | .. |ArgumentPack| replace:: :concept:`ArgumentPack` |
|---|
| 42 | .. |ParameterSpec| replace:: :concept:`ParameterSpec` |
|---|
| 43 | |
|---|
| 44 | .. role:: vellipsis |
|---|
| 45 | :class: vellipsis |
|---|
| 46 | |
|---|
| 47 | .. section-numbering:: |
|---|
| 48 | :depth: 2 |
|---|
| 49 | |
|---|
| 50 | Preliminaries |
|---|
| 51 | ============= |
|---|
| 52 | |
|---|
| 53 | This section covers some basic information you'll need to know in |
|---|
| 54 | order to understand this reference |
|---|
| 55 | |
|---|
| 56 | Namespaces |
|---|
| 57 | ---------- |
|---|
| 58 | |
|---|
| 59 | In this document, all unqualified identifiers should be assumed to |
|---|
| 60 | be defined in namespace ``boost::parameter`` unless otherwise |
|---|
| 61 | specified. |
|---|
| 62 | |
|---|
| 63 | Exceptions |
|---|
| 64 | ---------- |
|---|
| 65 | |
|---|
| 66 | No operation described in this document |
|---|
| 67 | throws an exception unless otherwise specified. |
|---|
| 68 | |
|---|
| 69 | Thread Safety |
|---|
| 70 | ------------- |
|---|
| 71 | |
|---|
| 72 | All components of this library can be used safely from multiple |
|---|
| 73 | threads without synchronization. [#thread]_ |
|---|
| 74 | |
|---|
| 75 | Typography |
|---|
| 76 | ---------- |
|---|
| 77 | |
|---|
| 78 | Names written in :concept:`sans serif type` represent concepts_. |
|---|
| 79 | |
|---|
| 80 | In code blocks, *italic type* represents unspecified text that |
|---|
| 81 | satisfies the requirements given in the detailed description that |
|---|
| 82 | follows the code block. |
|---|
| 83 | |
|---|
| 84 | In a specification of the tokens generated by a macro, **bold |
|---|
| 85 | type** is used to highlight the position of the expanded macro |
|---|
| 86 | argument in the result. |
|---|
| 87 | |
|---|
| 88 | The special character β represents the value of |BOOST_PARAMETER_MAX_ARITY|_. |
|---|
| 89 | |
|---|
| 90 | ////////////////////////////////////////////////////////////////////////////// |
|---|
| 91 | |
|---|
| 92 | Terminology |
|---|
| 93 | =========== |
|---|
| 94 | |
|---|
| 95 | .. |kw| replace:: keyword |
|---|
| 96 | .. _kw: |
|---|
| 97 | |
|---|
| 98 | keyword |
|---|
| 99 | The name of a function parameter. |
|---|
| 100 | |
|---|
| 101 | .. _keyword tag type: |
|---|
| 102 | .. |keyword tag type| replace:: `keyword tag type`_ |
|---|
| 103 | |
|---|
| 104 | keyword tag type |
|---|
| 105 | A type used to uniquely identify a function parameter. Typically |
|---|
| 106 | its name will be the same as that of the parameter. |
|---|
| 107 | |
|---|
| 108 | .. _positional: |
|---|
| 109 | .. |positional| replace:: `positional`_ |
|---|
| 110 | |
|---|
| 111 | positional argument |
|---|
| 112 | An argument passed with no explicit |kw|. Its parameter is |
|---|
| 113 | determined in the usual C++ way: by position with respect to a |
|---|
| 114 | parameter list. |
|---|
| 115 | |
|---|
| 116 | .. _tag type: |
|---|
| 117 | .. |tag type| replace:: `tag type`_ |
|---|
| 118 | |
|---|
| 119 | tag type |
|---|
| 120 | Shorthand for “\ |keyword tag type|.” |
|---|
| 121 | |
|---|
| 122 | .. _keyword object: |
|---|
| 123 | .. |keyword object| replace:: `keyword object`_ |
|---|
| 124 | |
|---|
| 125 | keyword object |
|---|
| 126 | An instance of |keyword|_ ``<T>`` for some |tag |
|---|
| 127 | type| ``T``. |
|---|
| 128 | |
|---|
| 129 | .. _tagged reference: |
|---|
| 130 | .. |tagged reference| replace:: `tagged reference`_ |
|---|
| 131 | |
|---|
| 132 | tagged reference |
|---|
| 133 | An object whose type is associated with a |keyword tag type| (the |
|---|
| 134 | object's *keyword*), and that holds a reference (to the object's |
|---|
| 135 | *value*). |
|---|
| 136 | |
|---|
| 137 | As a shorthand, a “tagged reference to ``x``\ ” means a tagged |
|---|
| 138 | reference whose *value* is ``x``. |
|---|
| 139 | |
|---|
| 140 | .. _tagged default: |
|---|
| 141 | .. |tagged default| replace:: `tagged default`_ |
|---|
| 142 | |
|---|
| 143 | tagged default |
|---|
| 144 | A |tagged reference| whose *value* represents the value of a |
|---|
| 145 | default argument. |
|---|
| 146 | |
|---|
| 147 | .. _tagged lazy default: |
|---|
| 148 | .. |tagged lazy default| replace:: `tagged lazy default`_ |
|---|
| 149 | |
|---|
| 150 | tagged lazy default |
|---|
| 151 | A |tagged reference| whose *value*, when invoked with no |
|---|
| 152 | arguments, computes a default argument value. |
|---|
| 153 | |
|---|
| 154 | .. _intended argument type: |
|---|
| 155 | .. |intended argument type| replace:: `intended argument type`_ |
|---|
| 156 | |
|---|
| 157 | intended argument type |
|---|
| 158 | The *intended argument type* of a single-element |ArgumentPack|_ is the |
|---|
| 159 | type of its element's *value*. The intended argument type of any other |
|---|
| 160 | type ``X`` is ``X`` itself. |
|---|
| 161 | |
|---|
| 162 | .. Note:: |
|---|
| 163 | |
|---|
| 164 | In this reference, we will use concept names (and other names) |
|---|
| 165 | to describe both types and objects, depending on context. So |
|---|
| 166 | for example, “an |ArgumentPack|_\ ” can refer to a type that |
|---|
| 167 | models |ArgumentPack|_ *or* an object of such a type. |
|---|
| 168 | |
|---|
| 169 | ////////////////////////////////////////////////////////////////////////////// |
|---|
| 170 | |
|---|
| 171 | Concepts |
|---|
| 172 | ======== |
|---|
| 173 | |
|---|
| 174 | This section describes the generic type concepts_ used by the Parameter library. |
|---|
| 175 | |
|---|
| 176 | .. _concepts: ../../../../more/generic_programming.html#concept |
|---|
| 177 | |
|---|
| 178 | |ArgumentPack| |
|---|
| 179 | -------------- |
|---|
| 180 | |
|---|
| 181 | An |ArgumentPack| is a collection of |tagged reference|\ s to the |
|---|
| 182 | actual arguments passed to a function. |
|---|
| 183 | |
|---|
| 184 | Requirements |
|---|
| 185 | ............ |
|---|
| 186 | |
|---|
| 187 | In the table below, |
|---|
| 188 | |
|---|
| 189 | * ``A`` is a model of |ArgumentPack| |
|---|
| 190 | * ``x`` is an instance of ``A`` |
|---|
| 191 | * ``u`` is a |keyword object| of type ``K`` |
|---|
| 192 | * ``v`` is a |tagged default| with |tag type| ``L`` and *value* of type ``D`` |
|---|
| 193 | * ``w`` is a |tagged lazy default| with |tag type| ``M`` and *value* of type ``E const`` |
|---|
| 194 | * ``z`` is an |ArgumentPack| containing a single element (as created by |keyword|_\ ``<…>::operator=``) |
|---|
| 195 | |
|---|
| 196 | Any exceptions are thrown from the invocation of ``w``\ 's *value* |
|---|
| 197 | will be propagated to the caller. |
|---|
| 198 | |
|---|
| 199 | .. table:: |ArgumentPack| requirements |
|---|
| 200 | |
|---|
| 201 | +----------+-----------------------------+------------------+--------------------------------------+ |
|---|
| 202 | |Expression| Type |Requirements |Semantics/Notes | |
|---|
| 203 | +==========+=============================+==================+======================================+ |
|---|
| 204 | |``x[u]`` |``binding<A,K>::type`` |``x`` contains an |Returns *b*\ 's *value* (by | |
|---|
| 205 | | | |element *b* whose |reference). | |
|---|
| 206 | | | ||kw|_ is ``K`` | | |
|---|
| 207 | +----------+-----------------------------+------------------+--------------------------------------+ |
|---|
| 208 | |``x[u]`` |``binding<A,L,D>::type`` |*none* |If ``x`` contains an element *b* whose| |
|---|
| 209 | | | | ||kw|_ is the same as ``u``\ 's, | |
|---|
| 210 | | | | |returns *b*\ 's *value* (by | |
|---|
| 211 | | | | |reference). Otherwise, returns ``u``\| |
|---|
| 212 | | | | |'s *value*. | |
|---|
| 213 | +----------+-----------------------------+------------------+--------------------------------------+ |
|---|
| 214 | |``x[w]`` |``lazy_binding<A,M,E>::type``|*none* |If ``x`` contains an element *b* whose| |
|---|
| 215 | | | | ||kw|_ is the same as ``w``\ 's, | |
|---|
| 216 | | | | |returns *b*\ 's *value* (by | |
|---|
| 217 | | | | |reference). Otherwise, invokes ``w``\| |
|---|
| 218 | | | | |'s *value* and returns the result. | |
|---|
| 219 | +----------+-----------------------------+------------------+--------------------------------------+ |
|---|
| 220 | |``x, z`` |Model of |ArgumentPack| |*none* |Returns an |ArgumentPack|_ containing | |
|---|
| 221 | | | | |all the elements of both ``x`` and | |
|---|
| 222 | | | | |``z``. | |
|---|
| 223 | +----------+-----------------------------+------------------+--------------------------------------+ |
|---|
| 224 | |
|---|
| 225 | |
|---|
| 226 | |
|---|
| 227 | .. _parameterspec: |
|---|
| 228 | |
|---|
| 229 | |ParameterSpec| |
|---|
| 230 | --------------- |
|---|
| 231 | |
|---|
| 232 | A |ParameterSpec| describes the type requirements for arguments |
|---|
| 233 | corresponding to a given |kw|_ and indicates whether the argument |
|---|
| 234 | is optional or required. The table below details the allowed forms |
|---|
| 235 | and describes their condition for satisfaction by an actual |
|---|
| 236 | argument type. In each row, |
|---|
| 237 | |
|---|
| 238 | .. _conditions: |
|---|
| 239 | |
|---|
| 240 | * ``K`` is the |ParameterSpec|\ 's |keyword tag type| |
|---|
| 241 | * ``A`` is an |intended argument type| associated with ``K``, if any |
|---|
| 242 | * ``F`` is a unary `MPL lambda expression`_ |
|---|
| 243 | |
|---|
| 244 | .. _`MPL lambda expression`: ../../../mpl/doc/refmanual/lambda-expression.html |
|---|
| 245 | |
|---|
| 246 | .. table:: |ParameterSpec| allowed forms and conditions of satisfaction |
|---|
| 247 | |
|---|
| 248 | +----------------------+--------------+--------------------------------+ |
|---|
| 249 | |Type |``A`` required|Condition ``A`` must satisfy | |
|---|
| 250 | +======================+==============+================================+ |
|---|
| 251 | ||keyword|_\ ``<K>`` |no |*n/a* | |
|---|
| 252 | +----------------------+--------------+--------------------------------+ |
|---|
| 253 | ||optional|_\ ``<K,F>``|no |``mpl::apply<F,A>::type::value``| |
|---|
| 254 | | | |is ``true``. | |
|---|
| 255 | +----------------------+--------------+--------------------------------+ |
|---|
| 256 | ||required|_\ ``<K,F>``|yes |``mpl::apply<F,A>::type::value``| |
|---|
| 257 | | | |is ``true``. | |
|---|
| 258 | +----------------------+--------------+--------------------------------+ |
|---|
| 259 | |
|---|
| 260 | The information in a |ParameterSpec| is used to `limit`__ the |
|---|
| 261 | arguments that will be matched by `forwarding functions`_. |
|---|
| 262 | |
|---|
| 263 | __ overloadcontrol_ |
|---|
| 264 | .. _overloadcontrol: index.html#controlling-overload-resolution |
|---|
| 265 | .. _forwarding functions: index.html#forwarding-functions |
|---|
| 266 | |
|---|
| 267 | |
|---|
| 268 | ////////////////////////////////////////////////////////////////////////////// |
|---|
| 269 | |
|---|
| 270 | Class Templates |
|---|
| 271 | =============== |
|---|
| 272 | |
|---|
| 273 | .. |keyword| replace:: ``keyword`` |
|---|
| 274 | .. _keyword: |
|---|
| 275 | |
|---|
| 276 | ``keyword`` |
|---|
| 277 | ----------- |
|---|
| 278 | |
|---|
| 279 | The type of every |keyword object| is a specialization of |keyword|. |
|---|
| 280 | |
|---|
| 281 | :Defined in: `boost/parameter/keyword.hpp`__ |
|---|
| 282 | |
|---|
| 283 | __ ../../../../boost/parameter/keyword.hpp |
|---|
| 284 | |
|---|
| 285 | .. parsed-literal:: |
|---|
| 286 | |
|---|
| 287 | template <class Tag> |
|---|
| 288 | struct keyword |
|---|
| 289 | { |
|---|
| 290 | template <class T> |ArgumentPack|_ `operator=`_\(T& value) const; |
|---|
| 291 | template <class T> |ArgumentPack|_ `operator=`_\(T const& value) const; |
|---|
| 292 | |
|---|
| 293 | template <class T> *tagged default* `operator|`_\(T& x) const; |
|---|
| 294 | template <class T> *tagged default* `operator|`_\(T const& x) const; |
|---|
| 295 | |
|---|
| 296 | template <class F> *tagged lazy default* `operator||`_\(F const&) const; |
|---|
| 297 | |
|---|
| 298 | static keyword<Tag>& get_\(); |
|---|
| 299 | }; |
|---|
| 300 | |
|---|
| 301 | |
|---|
| 302 | .. |operator=| replace:: ``operator=`` |
|---|
| 303 | .. _operator=: |
|---|
| 304 | |
|---|
| 305 | ``operator=`` |
|---|
| 306 | .. parsed-literal:: |
|---|
| 307 | |
|---|
| 308 | template <class T> |ArgumentPack|_ operator=(T& value) const; |
|---|
| 309 | template <class T> |ArgumentPack|_ operator=(T const& value) const; |
|---|
| 310 | |
|---|
| 311 | :Requires: nothing |
|---|
| 312 | |
|---|
| 313 | :Returns: |
|---|
| 314 | an |ArgumentPack|_ containing a single |tagged reference| to |
|---|
| 315 | ``value`` with |kw|_ ``Tag`` |
|---|
| 316 | |
|---|
| 317 | .. _operator|: |
|---|
| 318 | |
|---|
| 319 | ``operator|`` |
|---|
| 320 | .. parsed-literal:: |
|---|
| 321 | |
|---|
| 322 | template <class T> *tagged default* operator|(T& x) const; |
|---|
| 323 | template <class T> *tagged default* operator|(T const& x) const; |
|---|
| 324 | |
|---|
| 325 | :Returns: a |tagged default| with *value* ``x`` and |kw|_ ``Tag``. |
|---|
| 326 | |
|---|
| 327 | .. _operator||: |
|---|
| 328 | |
|---|
| 329 | ``operator||`` |
|---|
| 330 | .. parsed-literal:: |
|---|
| 331 | |
|---|
| 332 | template <class F> *tagged lazy default* operator||(F const& g) const; |
|---|
| 333 | |
|---|
| 334 | :Requires: ``g()`` is valid, with type ``boost::``\ |result_of|_\ |
|---|
| 335 | ``<F()>::type``. [#no_result_of]_ |
|---|
| 336 | |
|---|
| 337 | |
|---|
| 338 | :Returns: a |tagged lazy default| with *value* ``g`` and |kw|_ ``Tag``. |
|---|
| 339 | |
|---|
| 340 | .. _get: |
|---|
| 341 | |
|---|
| 342 | ``get`` |
|---|
| 343 | .. parsed-literal:: |
|---|
| 344 | |
|---|
| 345 | static keyword<Tag>& get\(); |
|---|
| 346 | |
|---|
| 347 | :Returns: a “singleton instance”: the same object will be |
|---|
| 348 | returned on each invocation of ``get()``. |
|---|
| 349 | |
|---|
| 350 | :Thread Safety: ``get()`` can be called from multiple threads |
|---|
| 351 | simultaneously. |
|---|
| 352 | |
|---|
| 353 | ``parameters`` |
|---|
| 354 | -------------- |
|---|
| 355 | |
|---|
| 356 | Provides an interface for assembling the actual arguments to a |
|---|
| 357 | `forwarding function` into an |ArgumentPack|, in which any |
|---|
| 358 | |positional| arguments will be tagged according to the |
|---|
| 359 | corresponding template argument to ``parameters``. |
|---|
| 360 | |
|---|
| 361 | .. _forwarding function: `forwarding functions`_ |
|---|
| 362 | |
|---|
| 363 | :Defined in: `boost/parameter/parameters.hpp`__ |
|---|
| 364 | |
|---|
| 365 | __ ../../../../boost/parameter/parameters.hpp |
|---|
| 366 | |
|---|
| 367 | .. parsed-literal:: |
|---|
| 368 | |
|---|
| 369 | template <class P0 = *unspecified*, class P1 = *unspecified*, …class P\ β = *unspecified*> |
|---|
| 370 | struct parameters |
|---|
| 371 | { |
|---|
| 372 | template <class A0, class A1 = *unspecified*, …class A\ β = *unspecified*> |
|---|
| 373 | struct `match`_ |
|---|
| 374 | { |
|---|
| 375 | typedef … type; |
|---|
| 376 | }; |
|---|
| 377 | |
|---|
| 378 | template <class A0> |
|---|
| 379 | |ArgumentPack|_ `operator()`_\(A0 const& a0) const; |
|---|
| 380 | |
|---|
| 381 | template <class A0, class A1> |
|---|
| 382 | |ArgumentPack|_ `operator()`_\(A0 const& a0, A1 const& a1) const; :vellipsis:`\ |
|---|
| 383 | . |
|---|
| 384 | . |
|---|
| 385 | . |
|---|
| 386 | ` |
|---|
| 387 | template <class A0, class A1, …class A\ β> |
|---|
| 388 | |ArgumentPack|_ `operator()`_\(A0 const& a0, A1 const& a1, …A\ β const& a\ β) const; |
|---|
| 389 | }; |
|---|
| 390 | |
|---|
| 391 | |
|---|
| 392 | :Requires: ``P0``, ``P1``, … ``P``\ β are models of |ParameterSpec|_. |
|---|
| 393 | |
|---|
| 394 | |
|---|
| 395 | .. Note:: |
|---|
| 396 | |
|---|
| 397 | In this section, ``R``\ *i* and ``K``\ *i* are defined as |
|---|
| 398 | follows, for any argument type ``A``\ *i*: |
|---|
| 399 | |
|---|
| 400 | |
|---|
| 401 | | ``R``\ *i* is ``A``\ *i*\ 's |intended argument type| |
|---|
| 402 | | |
|---|
| 403 | | if ``A``\ *i* is a result type of ``keyword<T>::``\ |operator=|_ |
|---|
| 404 | | then |
|---|
| 405 | | ``K``\ *i* is ``T`` |
|---|
| 406 | | else |
|---|
| 407 | | ``K``\ *i* is ``P``\ *i*\ 's |keyword tag type|. |
|---|
| 408 | |
|---|
| 409 | |
|---|
| 410 | .. _match: |
|---|
| 411 | |
|---|
| 412 | ``match`` |
|---|
| 413 | A |Metafunction|_ used to remove a `forwarding function`_ from overload resolution. |
|---|
| 414 | |
|---|
| 415 | :Returns: if ``P0``, ``P1``, …\ ``P``\ β are *satisfied* (see |
|---|
| 416 | below), then ``parameters<P0,P1,…Pβ>``. Otherwise, |
|---|
| 417 | ``match<A0,A1,…Aβ>::type`` is not defined. |
|---|
| 418 | |
|---|
| 419 | ``P0``, ``P1``, …\ ``P``\ β are **satisfied** if, for |
|---|
| 420 | every *j* in 0…β, either: |
|---|
| 421 | |
|---|
| 422 | * ``P``\ *j* is the *unspecified* default |
|---|
| 423 | * **or**, ``P``\ *j* is a specialization of |keyword|_, |
|---|
| 424 | |
|---|
| 425 | * **or**, ``P``\ *j* is |optional|_ ``<X,F>`` and either |
|---|
| 426 | |
|---|
| 427 | - ``X`` is not ``K``\ *i* for any *i*, |
|---|
| 428 | - **or** ``X`` is some ``K``\ *i* and ``mpl::apply<F,R``\ *i*\ |
|---|
| 429 | ``>::type::value`` is ``true`` |
|---|
| 430 | |
|---|
| 431 | * **or**, ``P``\ *j* is |required|_ ``<X,F>``, and |
|---|
| 432 | |
|---|
| 433 | - ``X`` is some ``K``\ *i*, **and** |
|---|
| 434 | - ``mpl::apply<F,R``\ *i*\ ``>::type::value`` is ``true`` |
|---|
| 435 | |
|---|
| 436 | .. _operator(): |
|---|
| 437 | |
|---|
| 438 | ``operator()`` |
|---|
| 439 | .. parsed-literal:: |
|---|
| 440 | |
|---|
| 441 | template <class A0> |ArgumentPack|_ operator()(A0 const& a0) const; :vellipsis:`\ |
|---|
| 442 | . |
|---|
| 443 | . |
|---|
| 444 | . |
|---|
| 445 | ` |
|---|
| 446 | template <class A0, …class A\ β> |ArgumentPack|_ `operator()`_\(A0 const& a0, …A\ β const& a\ β) const; |
|---|
| 447 | |
|---|
| 448 | :Returns: |
|---|
| 449 | An |ArgumentPack|_ containing, for each ``a``\ *i*, |
|---|
| 450 | |
|---|
| 451 | - if ``a``\ *i*, is a single-element |ArgumentPack|, its element |
|---|
| 452 | - Otherwise, a |tagged reference| with |kw|_ ``K``\ *i* and *value* ``a``\ *i* |
|---|
| 453 | |
|---|
| 454 | |
|---|
| 455 | .. |optional| replace:: ``optional`` |
|---|
| 456 | .. |required| replace:: ``required`` |
|---|
| 457 | |
|---|
| 458 | .. _optional: |
|---|
| 459 | .. _required: |
|---|
| 460 | |
|---|
| 461 | ``optional``, ``required`` |
|---|
| 462 | -------------------------- |
|---|
| 463 | |
|---|
| 464 | These templates describe the requirements on a function parameter. |
|---|
| 465 | |
|---|
| 466 | :Defined in: `boost/parameter/parameters.hpp`__ |
|---|
| 467 | |
|---|
| 468 | __ ../../../../boost/parameter/parameters.hpp |
|---|
| 469 | |
|---|
| 470 | :Specializations model: |ParameterSpec|_ |
|---|
| 471 | |
|---|
| 472 | .. parsed-literal:: |
|---|
| 473 | |
|---|
| 474 | template <class Tag, class Predicate = *unspecified*> |
|---|
| 475 | struct optional; |
|---|
| 476 | |
|---|
| 477 | template <class Tag, class Predicate = *unspecified*> |
|---|
| 478 | struct required; |
|---|
| 479 | |
|---|
| 480 | The default value of ``Predicate`` is an unspecified |Metafunction|_ that returns |
|---|
| 481 | ``mpl::true_`` for any argument. |
|---|
| 482 | |
|---|
| 483 | .. |Metafunction| replace:: :concept:`Metafunction` |
|---|
| 484 | .. _Metafunction: ../../../mpl/doc/refmanual/metafunction.html |
|---|
| 485 | |
|---|
| 486 | ////////////////////////////////////////////////////////////////////////////// |
|---|
| 487 | |
|---|
| 488 | Metafunctions |
|---|
| 489 | ============= |
|---|
| 490 | |
|---|
| 491 | A |Metafunction|_ is conceptually a function that operates on, and |
|---|
| 492 | returns, C++ types. |
|---|
| 493 | |
|---|
| 494 | ``binding`` |
|---|
| 495 | ----------- |
|---|
| 496 | |
|---|
| 497 | Returns the result type of indexing an argument pack with a |
|---|
| 498 | |keyword tag type| or with a |tagged default|. |
|---|
| 499 | |
|---|
| 500 | :Defined n: `boost/parameter/binding.hpp`__ |
|---|
| 501 | |
|---|
| 502 | __ ../../../../boost/parameter/binding.hpp |
|---|
| 503 | |
|---|
| 504 | .. parsed-literal:: |
|---|
| 505 | |
|---|
| 506 | template <class A, class K, class D = void> |
|---|
| 507 | struct binding |
|---|
| 508 | { |
|---|
| 509 | typedef … type; |
|---|
| 510 | }; |
|---|
| 511 | |
|---|
| 512 | :Requires: ``A`` is a model of |ArgumentPack|_. |
|---|
| 513 | |
|---|
| 514 | :Returns: the reference type of the |tagged reference| in ``A`` |
|---|
| 515 | having |keyword tag type| ``K``, if any. If no such |tagged |
|---|
| 516 | reference| exists, returns ``D``. |
|---|
| 517 | |
|---|
| 518 | ``lazy_binding`` |
|---|
| 519 | ---------------- |
|---|
| 520 | |
|---|
| 521 | Returns the result type of indexing an argument pack with a |tagged |
|---|
| 522 | lazy default|. |
|---|
| 523 | |
|---|
| 524 | :Defined in: |
|---|
| 525 | `boost/parameter/binding.hpp`__ |
|---|
| 526 | |
|---|
| 527 | __ ../../../../boost/parameter/binding.hpp |
|---|
| 528 | |
|---|
| 529 | .. parsed-literal:: |
|---|
| 530 | |
|---|
| 531 | template <class A, class K, class F> |
|---|
| 532 | struct lazy_binding |
|---|
| 533 | { |
|---|
| 534 | typedef … type; |
|---|
| 535 | }; |
|---|
| 536 | |
|---|
| 537 | :Requires: ``A`` is a model of |ArgumentPack|_. |
|---|
| 538 | |
|---|
| 539 | :Returns: the reference type of the |tagged reference| in ``A`` |
|---|
| 540 | having |keyword tag type| ``K``, if any. If no such |tagged |
|---|
| 541 | reference| exists, returns ``boost::``\ |result_of|_\ ``<F()>::type``. [#no_result_of]_ |
|---|
| 542 | |
|---|
| 543 | |
|---|
| 544 | ////////////////////////////////////////////////////////////////////////////// |
|---|
| 545 | |
|---|
| 546 | Code Generation Macros |
|---|
| 547 | ====================== |
|---|
| 548 | |
|---|
| 549 | Macros in this section can be used to ease the writing of code |
|---|
| 550 | using the Parameter libray by eliminating repetitive boilerplate. |
|---|
| 551 | |
|---|
| 552 | ``BOOST_PARAMETER_FUN(r,n,l,h,p)`` |
|---|
| 553 | ---------------------------------- |
|---|
| 554 | |
|---|
| 555 | Generates a sequence of `forwarding function`_ templates named |
|---|
| 556 | ``n``, with arities ranging from ``l`` to ``h`` , returning ``r``, |
|---|
| 557 | and using ``p`` to control overload resolution and assign tags to |
|---|
| 558 | positional arguments. |
|---|
| 559 | |
|---|
| 560 | :Defined in: `boost/parameter/macros.hpp`__ |
|---|
| 561 | |
|---|
| 562 | __ ../../../../boost/parameter/macros.hpp |
|---|
| 563 | |
|---|
| 564 | :Requires: ``l`` and ``h`` are nonnegative integer tokens such |
|---|
| 565 | that ``l`` < ``h`` |
|---|
| 566 | |
|---|
| 567 | Generates |
|---|
| 568 | .. parsed-literal:: |
|---|
| 569 | |
|---|
| 570 | template <class A1, class A2, …class A##\ **l**> |
|---|
| 571 | r name( |
|---|
| 572 | A1 const& a1, A2 const& a2, …A\ **l** const& x\ **l** |
|---|
| 573 | , typename **p**::match<A1,A2,…A\ **l**>::type p = **p**\ ()) |
|---|
| 574 | { |
|---|
| 575 | return **name**\ _with_named_params(**p**\ (x1,x2,…x\ **l**)); |
|---|
| 576 | } |
|---|
| 577 | |
|---|
| 578 | template <class A1, class A2, …class A\ **l**, class A\ ##\ BOOST_PP_INC_\ (**l**)> |
|---|
| 579 | r name( |
|---|
| 580 | A1 const& a1, A2 const& a2, …A\ **l** const& x\ **l** |
|---|
| 581 | , A\ ##\ BOOST_PP_INC_\ (**l**) const& x\ ##\ BOOST_PP_INC_\ (**l**) |
|---|
| 582 | , typename **p**::match<A1,A2,…A\ **l**,A\ ##\ BOOST_PP_INC_\ (**l**)>::type p = **p**\ ()) |
|---|
| 583 | { |
|---|
| 584 | return **name**\ _with_named_params(**p**\ (x1,x2,…x\ **l**,x\ ##\ BOOST_PP_INC_\ (**l**))); |
|---|
| 585 | } :vellipsis:`\ |
|---|
| 586 | . |
|---|
| 587 | . |
|---|
| 588 | . |
|---|
| 589 | ` |
|---|
| 590 | template <class A1, class A2, …class A\ **h**> |
|---|
| 591 | r name( |
|---|
| 592 | A1 const& a1, A2 const& a2, …A\ **h** const& x\ **h** |
|---|
| 593 | , typename **p**::match<A1,A2,…A\ **h**>::type p = **p**\ ()) |
|---|
| 594 | { |
|---|
| 595 | return **name**\ _with_named_params(**p**\ (a1,a2,…a\ **h**)); |
|---|
| 596 | } |
|---|
| 597 | |
|---|
| 598 | |
|---|
| 599 | .. _BOOST_PP_INC: ../../../preprocessor/doc/ref/inc.html |
|---|
| 600 | |
|---|
| 601 | ``BOOST_PARAMETER_KEYWORD(n,k)`` |
|---|
| 602 | -------------------------------- |
|---|
| 603 | |
|---|
| 604 | Generates the declaration of a |keyword tag type| named ``k`` in |
|---|
| 605 | namespace ``n``, and a corresponding |keyword object| definition in |
|---|
| 606 | the enclosing namespace. |
|---|
| 607 | |
|---|
| 608 | :Defined in: `boost/parameter/keyword.hpp`__ |
|---|
| 609 | |
|---|
| 610 | __ ../../../../boost/parameter/keyword.hpp |
|---|
| 611 | |
|---|
| 612 | Generates |
|---|
| 613 | .. parsed-literal:: |
|---|
| 614 | |
|---|
| 615 | namespace **n** { struct **k**; } |
|---|
| 616 | namespace { |
|---|
| 617 | boost::parameter::keyword<*tag-namespace*::**k**>& **k** |
|---|
| 618 | = boost::parameter::keyword<*tag-namespace*::**k**>::get(); |
|---|
| 619 | } |
|---|
| 620 | |
|---|
| 621 | ``BOOST_PARAMETER_MATCH(p,a,x)`` |
|---|
| 622 | -------------------------------- |
|---|
| 623 | |
|---|
| 624 | Generates a defaulted parameter declaration for a `forwarding |
|---|
| 625 | function`_. |
|---|
| 626 | |
|---|
| 627 | :Defined in: `boost/parameter/match.hpp`__ |
|---|
| 628 | |
|---|
| 629 | __ ../../../../boost/parameter/match.hpp |
|---|
| 630 | |
|---|
| 631 | :Requires: ``a`` is a `Boost.Preprocessor sequence`__ |
|---|
| 632 | of the form |
|---|
| 633 | |
|---|
| 634 | .. parsed-literal:: |
|---|
| 635 | |
|---|
| 636 | (A0)(A1)…(A\ *n*) |
|---|
| 637 | |
|---|
| 638 | __ http://www.boost.org/libs/preprocessor/doc/data.html |
|---|
| 639 | |
|---|
| 640 | Generates |
|---|
| 641 | .. parsed-literal:: |
|---|
| 642 | |
|---|
| 643 | typename **p**::match<**A0**\ ,\ **A1**\ …,\ **A**\ *n*>::type **x** = **p**\ () |
|---|
| 644 | |
|---|
| 645 | |
|---|
| 646 | Configuration Macros |
|---|
| 647 | ==================== |
|---|
| 648 | |
|---|
| 649 | ``BOOST_PARAMETER_MAX_ARITY`` |
|---|
| 650 | ----------------------------- |
|---|
| 651 | |
|---|
| 652 | Determines the maximum number of arguments supported by the |
|---|
| 653 | library. Will only be ``#defined`` by the library if it is not |
|---|
| 654 | already ``#defined``. |
|---|
| 655 | |
|---|
| 656 | .. |BOOST_PARAMETER_MAX_ARITY| replace:: ``BOOST_PARAMETER_MAX_ARITY`` |
|---|
| 657 | |
|---|
| 658 | :Defined in: `boost/parameter/config.hpp`__ |
|---|
| 659 | |
|---|
| 660 | __ ../../../../boost/parameter/config.hpp |
|---|
| 661 | |
|---|
| 662 | :Default Value: ``5`` |
|---|
| 663 | |
|---|
| 664 | Tutorial |
|---|
| 665 | ======== |
|---|
| 666 | |
|---|
| 667 | Follow `this link`__ to the Boost.Parameter tutorial |
|---|
| 668 | documentation. |
|---|
| 669 | |
|---|
| 670 | __ index.html#tutorial |
|---|
| 671 | |
|---|
| 672 | ////////////////////////////////////////////////////////////// |
|---|
| 673 | |
|---|
| 674 | .. [#thread] References to tag objects may be initialized multiple |
|---|
| 675 | times. This scenario can only occur in the presence of |
|---|
| 676 | threading. Because the C++ standard doesn't consider threading, |
|---|
| 677 | it doesn't explicitly allow or forbid multiple initialization of |
|---|
| 678 | references. That said, it's hard to imagine an implementation |
|---|
| 679 | where it could make a difference. |
|---|
| 680 | |
|---|
| 681 | .. [#no_result_of] Where |BOOST_NO_RESULT_OF|_ is ``#defined``, |
|---|
| 682 | ``boost::``\ |result_of|_\ ``<F()>::type`` is replaced by |
|---|
| 683 | ``F::result_type``. |
|---|
| 684 | |
|---|
| 685 | .. |result_of| replace:: ``result_of`` |
|---|
| 686 | .. _result_of: ../../../utility/utility.htm#result_of |
|---|
| 687 | |
|---|
| 688 | .. |BOOST_NO_RESULT_OF| replace:: ``BOOST_NO_RESULT_OF`` |
|---|
| 689 | .. _BOOST_NO_RESULT_OF: ../../../utility/utility.htm#BOOST_NO_RESULT_OF |
|---|