Template:param list/doc

来自cppreference.com

This is one of the family of templates used for creation of parameter list.

List template families

  • dcl list **** : For creation of member variable/function lists.
  • ddcl list **** : For creation of detailed declaration lists (those including actual declaration code)
  • sdcl list **** : For creation of lists representing various syntaxes of a language feature. Used in subpages of cpp/language
  • param list **** : For creation of lists explaining function parameters.
  • sb list **** : For creation of feature lists in navbars.

{{param list begin}}

starts the parameter list

{{param list end}}

ends the parameter list

{{param list item| parameter| explanation}}

adds an item to the parameter list.

{{param list hreq}}

results in "Type requirements"

{{param list req| requirement}}

adds a generic type requirement

{{param list req concept| parameter_name| concept| concept2 (可选)| ...| concept_n (可选)| notes=notes}}

adds a concept requirement

{{param list req concept deref| expression| concept| concept2 (可选)| ...| concept_n (可选)| notes=notes}}

adds a concept requirement on the result of dereference of type

Specific cases

functions passed as parameters:

{{param list pred0| parameter_name| value=return_value (可选)| condition}}

predicate with no arguments

{{param list pred1| parameter_name| value=return_value (可选)| condition| t1=type or p1=pointer_type}}

unary predicate

{{param list pred2| parameter_name| value=return_value (可选)| condition| t1=type or p1=pointer_type| t2=type or p2=pointer_type (可选)}}

binary predicate

{{param list pred2 eq| parameter_name| t1=type or p1=pointer_type| t2=type or p2=pointer_type (可选)}}

binary equality predicate

{{param list cmp| parameter_name| value=return_value (可选)| condition| t1=type or p1=pointer_type| t2=type or p2=pointer_type (可选)}}

comparison function

{{param list ccmp| parameter_name| additional_explanation (可选)}}

C-style comparison function

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

function

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

unary operation

{{param list op2| parameter_name| action| rt=type or rp=pointer_type| t1=type or p1=pointer_type| t2=type or p2=pointer_type (可选)}}

binary operation

{{param list 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.
类型  Type1 必须能使类型 ForwardIt 的对象能够 be dereferenced and then 隐式转换为  Type1。类型  Type2 必须能使类型 T 的对象能够隐式转换为  Type2