Template:par/doc
This is one of the family of templates used for creation of parameter list.
List template families
- dsc **** : For creation of member variable/function lists.
- dcl **** : For creation of detailed declaration lists (those including actual declaration code).
- sdsc **** : For creation of lists representing various syntaxes of a language feature. Used in subpages of cpp/language.
- par **** : For creation of lists explaining function parameters.
- spar **** : For creation of lists explaining syntax parameters.
- nv **** : For creation of feature lists in navbars.
- elink **** : For creation of External links lists.
{{par begin}}
- starts the parameter list
{{par end}}
- ends the parameter list
{{par|parameter }}
- adds an item to the parameter list.
{{par hreq}}
- results in "Type requirements"
{{par req|requirement }}
- adds a generic type requirement
{{par req named|parameter name |req1 |req2 (optional)|... |reqn (optional)|overload=applicable overload (optional)|overloads=applicable overloads (optional)|notes=notes (optional)}}
- adds a named requirement
{{par req named deref|expression |req1 |req2 (optional)|... |reqn (optional)|overload=applicable overload (optional)|overloads=applicable overloads (optional)|notes=notes (optional)}}
- adds a named requirement on the result of dereference of type
{{par req insertable|parameter name |req1 |req2 (optional)|req3 (optional)|target=insert target (optional)|overload=applicable overload (optional)|overloads=applicable overloads (optional)|notes=notes (optional)}}
- adds DefaultInsertable, CopyInsertable and MoveInsertable requirements, if
target
is not provided, the default insert target is *this
{{par inc|location |param1 (optional)|param2 (optional)|... }}
- Sets
dcl-list-template-name
variable to location, includes the template from location and unsets the variable. Use this template whenever copying param list items from a template; this will add an edit link to them. The unnamed parameters param1, param2, ... are passed to the template.
Specific cases
- functions passed as parameters:
{{par pred0|parameter name |value=return value (optional)|condition }}
- predicate with no arguments
{{par pred1|parameter name |value=return value (optional)|condition |t1=type |p1=pointer type }}
- unary predicate (only one of t1 and p1 can be provided)
{{par pred2|parameter name |value=return value (optional)|condition |t1=type |p1=pointer type |t2=type (optional)|p2=pointer type (optional)}}
- binary predicate (only one of t1 and p1, and one of t2 and p2 can be provided)
{{par pred2 eq|parameter name |t1=type |p1=pointer type |t2=type (optional)|p2=pointer type (optional)}}
- binary equality predicate (only one of t1 and p1, and one of t2 and p2 can be provided)
{{par cmp|parameter name |value=return value (optional)|condition |t1=type |p1=pointer type |t2=type (optional)|p2=pointer type (optional)}}
- comparison function (only one of t1 and p1, and one of t2 and p2 can be provided)
{{par cmp ord|parameter name |value=return value (optional)|condition |t1=type |p1=pointer type |t2=type (optional)|p2=pointer type (optional)}}
- comparison function for ordering (only one of t1 and p1, and one of t2 and p2 can be provided)
{{par ccmp|parameter name |additional explanation (optional)}}
- C-style comparison function
{{par opf|parameter name |action |t1=type |p1=pointer type }}
- function (only one of t1 and p1 can be provided)
{{par op1|parameter name |action |rt=type |rp=pointer type |t1=type |p1=pointer type }}
- unary operation (only one of rt and rp, and one of t1 and p1 can be provided)
{{par op2|parameter name |action |rt=type |rp=pointer type |t1=type |p1=pointer type |t2=type (optional)|p2=pointer type (optional)}}
- binary operation (only one of rt and rp, one of t1 and p1, and one of t2 and p2 can be provided)
{{par gen|parameter name |action |rt=type |rp=pointer type }}
- generator (only one of rt and rp can be provided)
- Parameters
- parameter name is the name of the predicate parameter.
value
is the expected return value when the condition is satisfied (defaults to true).t1
,t2
,p1
,p2
are types that the predicate is required to accept as its first and second parameters respectively.p1
andp2
describe a pointer parameter, i.e. it will be dereferenced before passed to the predicate. For each parameter, only one of eithert*
orp*
can be used. Ift2/p2
are not defined,t1,p1
are used for the second parameter instead.
[edit] Example
{{par begin}} {{par|count|the size of the list}} {{par pred2|p|p1=ForwardIt|t2=T|if the elements should be exchanged}} {{par end}}
The above results in the following:
count | - | the size of the list |
p | - | binary predicate which returns true if the elements should be exchanged. The signature of the predicate function should be equivalent to the following: bool pred(const Type1 &a, const Type2 &b); While the signature does not need to have const &, the function must not modify the objects passed to it and must be able to accept all values of type (possibly const) |