Namespaces
Variants
Actions

Template:par

From cppreference.com

|- class="t-par" | | - |

[edit] [{{purge}}] Template documentation

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.

{{par begin}}

starts the parameter list

{{par end}}

ends the parameter list

{{par| parameter| explanation}}

adds an item to the parameter list.

{{par hreq}}

results in "Type requirements"

{{par req| requirement}}

adds a generic type requirement

{{par req concept| parameter_name| concept| concept2 (optional)| ...| concept_n (optional)| overload=applicable overload(optional)| overloads=applicable overloads(optional)| notes=notes}}

adds a concept requirement.

{{par req concept deref| expression| concept| concept2 (optional)| overload=applicable overload(optional)| overloads=applicable overloads(optional)| ...| concept_n (optional)}}

adds a concept requirement on the result of dereference of type

{{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 or p1=pointer_type}}

unary predicate

{{par pred2| parameter_name| value=return_value (optional)| condition| t1=type or p1=pointer_type| t2=type or p2=pointer_type (optional)}}

binary predicate

{{par pred2 eq| parameter_name| t1=type or p1=pointer_type| t2=type or p2=pointer_type (optional)}}

binary equality predicate

{{par cmp| parameter_name| value=return_value (optional)| condition| t1=type or p1=pointer_type| t2=type or p2=pointer_type (optional)}}

comparison function

{{par cmp ord| parameter_name| value=return_value (optional)| condition| t1=type or p1=pointer_type| t2=type or p2=pointer_type (optional)}}

comparison function for ordering

{{par ccmp| parameter_name| additional_explanation (optional)}}

C-style comparison function

{{par opf| parameter_name| action| t1=type or p1=pointer_type}}

function

{{par op1| parameter_name| action| rt=type or rp=pointer_type| t1=type or p1=pointer_type}}

unary operation

{{par op2| parameter_name| action| rt=type or rp=pointer_type| t1=type or p1=pointer_type| t2=type or p2=pointer_type (optional)}}

binary operation

{{par gen| parameter_name| action| rt=type or rp=pointer_type}}

generator
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 and p2 describe a pointer parameter, i.e. it will be dereferenced before passed to the predicate. For each parameter, only one of either t* or p* can be used. If t2/p2 are not defined, t1,p1 are used for the second parameter instead.

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);

The signature does not need to have const &, but the function must not modify the objects passed to it.
The type Type1 must be such that an object of type ForwardIt can be dereferenced and then implicitly converted to Type1. The type Type2 must be such that an object of type T can be implicitly converted to Type2.