Help:Templates
This page describes the templates used in this wiki.
Templates provide means to achieve the following objectives:
- Quality. It becomes easy to modify the content and hence to fix errors. Duplicated content needs to be edited only once.
- Consistency. Templates make the right way to do things implicit.
- Usability. Advanced formatting is made easy by the templates.
There are a lot of templates in this wiki. The list of all templates is available at Special:AllPages. Since this wiki uses Mediawiki CMS, all templates present in the Wikipedia project can be used here. As an additional benefit, the template documentation can be used to learn Mediawiki template syntax.
Contents |
[edit] Lists
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.
[edit] Typography helper templates
This is one of the templates used to output special symbols:
{{!}} - outputs |
{{!!}} - outputs ||
{{=}} - outputs =
{{==}} - outputs ==
{{!=}} - outputs |=
{{(!}} - outputs {|
{{!)}} - outputs |}
| The above documentation is transcluded from Template:!/doc. (edit | history) Subpages of this page. |
[edit] Formatting
Adds formatting to the enclosed text:
| Usage | Description | Resulting HTML elements | Preview |
|---|---|---|---|
| {{tt|text}} | text in monospace font | <code>
|
text
|
| {{ttb|text}} | text in bold monospace font | <code><b>
|
text
|
| {{petty|text}} | smallish text | <small>
|
text |
| {{small|text}} | small text | ..."font-size:0.7em; line-height:130%"... | text |
| {{smalltt|text}} | small text in monospace font | equivalent to {{small|<code>text</code>}} | text
|
| {{sub|text}} | subscripted text in normal font | <sub>
|
text |
| {{sup|text}} | superscripted text in normal font | <sup>
|
text |
| The above documentation is transcluded from Template:tt/doc. (edit | history) Subpages of this page. |
[edit] Syntax highlighting
These are templates used for syntax highlighting.
{{c| 1=code| lang=language (optional)}}
- A base template that is intended to highlight code inline.
langis optional; value returned by {{get_lang}} is used by default. Applies a semi-transparent dark background. - Example:
{{c|std::string(80, '_');}}results in std::string(80, '_'); - Example:
{{c|1= auto x = std::array{1, 2, 3};}}results in auto x = std::array{1, 2, 3}; - Note that 1= is necessary if equal sign = is present somewhere in the expression.
{{c/core| 1=code| lang=language (optional)}}
- Same as {{c}} just no background (e.g. the bounding box) is applied. Intended to be used in other templates only.
- Example:
{{c/core|std::puts("C++");}}results in std::puts("C++");
{{co| 1=code| lang=language (optional)}}
- Same as {{c/core}} just no background (e.g. the bounding box) is applied. Intended to be used in tables where bounding boxes are set by the table's frame.
- Example:
{{co|std::basic_regex<char>}}results in std::basic_regex<char>
{{box| 1=tags}}
- Alike {{c}}, applies one shared bounding box to a formatted text generated by several given tags.
- Example:
{{box|{{lc|std::pair}}{{tt|''<int,char>''}}}}results in std::pair<int,char> - Example:
{{box | {{co|"C++";}} {{ltt std|cpp/algorithm/swap}}{{tt|''<int>''}}{{c/core|(x,y); /*.*/}} }}results in "C++"; std::swap<int>(x,y); /*.*/
{{cc| 1=code| lang=language (optional)}}
- A base template that is intended to highlight larger amounts of code inline. Usually used when the {{c}} template doesn't display the code readable, but {{source}} would waste too much space.
langis optional; value returned by {{get_lang}} is used by default. - Example:
{{cc|1= assert(std::hypot(3, 4) == 5);}}results in assert(std::hypot(3, 4) == 5);
{{source| 1=code| lang=language (optional)}}
- A base template that is intended to highlight large amounts of code.
langis optional; value returned by {{get_lang}} is used by default. - For example, the code:
{{source|1=
int main()
{
__builtin_printf("Hello, C++\n");
}
}}
- results in
int main() { __builtin_printf("Hello, C++\n"); }
{{eq fun| lang=language|code1|code2 (optional)|...|code4 (optional)}}
- A base template for representing code snippets in Possible implementation sections. The arguments
code1,code2, etc. are code for each version of the function template being described (e.g., std::fill-family in the case below). If no code is supplied at all, the template results in {{todo}}.langis optional — value returned by {{get_lang}} is used by default. - For example, the code:
{{eq fun
| 1=
template<class ForwardIt, class T>
void fill(ForwardIt first, ForwardIt last, const T& value)
{
for (; first != last; ++first)
*first = value;
}
| 2=
template<class OutputIt, class Size, class T>
OutputIt fill_n(OutputIt first, Size count, const T& value)
{
for (Size i = 0; i < count; i++)
*first++ = value;
return first;
}
}}
- results in:
| First version |
|---|
template<class ForwardIt, class T> void fill(ForwardIt first, ForwardIt last, const T& value) { for (; first != last; ++first) *first = value; } |
| Second version |
template<class OutputIt, class Size, class T> OutputIt fill_n(OutputIt first, Size count, const T& value) { for (Size i = 0; i < count; i++) *first++ = value; return first; } |
{{eq impl| lang=language|code1|code2 (optional)|...|code4 (optional)|title1=Title1 (optional)|...|Title4 (optional)}}
Additional params:
{{eq impl|ver1=link1 (optional)|...|ver4=link4 (optional)}}
- Same as {{eq fun}} with two additional capabilities:
- A substitution of any of the default title with a custom one via optional parameter(s)
title1=Your title, ...,title4=Your title . Default titles are the same as of aforementioned template {{eq fun}}, i.e. First version, ..., Fourth version. - An auto-generation of internal link "under" the title text. If
verNis specified, this template generates an internal HTML link with target name "Version num". For example, if ver2=3 the internal link "#Version 3" will be generated. This capability works together with generation of internal anchors by {{dcla}} and {{dcl rev multi}} to link Possible implementation code sections to declarations in Synopsis.
{{example|description (optional)|lang=language (optional)| code=code_to_display| p=true_if_nondeterministic (optional)| std=language standard (optional)|output=sample output (optional)}}
- A base template to represent examples. If
codeis not present, the template results in {{todo}}.langdefaults to a value returned by {{get_lang}}.outputspecifies the output which is displayed by the code. If the output is not deterministic,pshould be set totrueto indicate this (then "Possible output:" is shown instead of just "Output:").
- The following language standards are available:
- cxx98, cxx03, cxx11, cxx14, c89, c99, c11.
- For example, the code:
{{example
| Commenting string
| code=
int main()
{
__builtin_puts("Hello, C++");
}
| p=true
| output=
Hello, C++
}}
- results in:
Commenting string
int main() { __builtin_puts("Hello, C++"); }
Possible output:
Hello, C++
| The above documentation is transcluded from Template:source/doc. (edit | history) Subpages of this page. |
[edit] Links
[edit] This is one of templates used to make links
[edit] Absolute links
{{lt|path|title (optional)}} - link to a page using absolute path. The default title is only the last part of the path. The link appears in normal font.
- Example:
{{lt|cpp/language/statements}}results in the link: statements. - Example:
{{lt|cpp/language/statements|Labeled statements}}results in the link: Labeled statements. - Note: the previous example is just another way to create the same link using the standard template
-
[[cpp/language/statements|Labeled statements]], which also results in Labeled statements.
{{ltt|path|title (optional)}} - link to a page using absolute path. The default title is only the last part of the path. Link font is teletype.
- Example:
{{ltt|cpp/language/switch}}results in the link: switch. - Example:
{{ltt|cpp/language/switch|switch(expr)}}results in the link: switch(expr).
{{ltf|path|title (optional)|args=arguments (optional)}} - link to a page using absolute path. The default title is only the last part of the path. Link font is teletype. Parentheses indicating function are appended, which enclose the optional arguments.
- Example:
{{ltf|cpp/error/terminate}}results in the link: terminate(). - Example:
{{ltf|cpp/error/terminate|std::terminate}}results in the link: std::terminate(). - Example:
{{ltf|cpp/error/set_terminate|std::set_terminate|args=nullptr}}results in the link: std::set_terminate(nullptr).
{{l2tt|page|title1 (optional)|title2 (optional)}} - makes a link to a page using absolute path. The title is formed from the two last parts of the path with :: be inserted between them. Each of these parts can be overridden by title1 and title2. Link font is teletype.
- Example:
{{l2tt|cpp/container/vector/size}}results in the link: vector::size. - Example:
{{l2tt|cpp/container/vector/size|size() const}}results in the link: vector::size() const. - Example:
{{l2tt|cpp/container/vector/size|size()|std::vector<T>}}results in the link: std::vector<T>::size().
{{l2tf|page|title1 (optional)|title2 (optional)|args=arguments (optional)|suffix=suffix (optional)}} - makes a link to a page using absolute path. The title is formed from the two last parts of the path with :: be inserted between them. Each of these parts can be overridden by title1 and title2. Link font is teletype. Parentheses indicating function are appended, which enclose the optional arguments and are followed by the optional suffix.
- Example:
{{l2tf|cpp/container/vector/size}}results in the link: vector::size(). - Example:
{{l2tf|cpp/container/vector/size|suffix=const}}results in the link: vector::size() const. - Example:
{{l2tf|cpp/container/vector/size|size|std::vector<T>}}results in the link: std::vector<T>::size().
[edit] Absolute links with prefix std::
The following convenience templates generate links whose titles begin with std::. They can be used in places where {{lc}} fails to generate a link.
{{ltt std|path}} - link to a page using absolute path. The title is std:: followed by the last part of the path. Link font is teletype.
- Example:
{{ltt std|cpp/container/mdspan}}results in the link: std::mdspan.
{{ltf std|path}} - link to a page using absolute path. The title is std:: followed by the last part of the path and parentheses indicating function. Link font is teletype.
- Example:
{{ltf std|cpp/io/print}}results in the link: std::print().
{{l2tt std|path}} - link to a page using absolute path. The title is std:: followed by the last two parts of the path joined by ::. Link font is teletype.
- Example:
{{l2tt std|cpp/utility/basic_stacktrace/current}}results in the link: std::basic_stacktrace::current.
{{l2tf std|path}} - link to a page using absolute path. The title is std:: followed by the last two parts of the path joined by :: and parentheses indicating function. Link font is teletype.
- Example:
{{l2tf std|cpp/utility/expected/value}}results in the link: std::expected::value().
[edit] Relative links
{{rl|page|title (optional)}} - makes a link to a page relative to this page. The link appears in normal font.
{{rlp|page|title (optional)}} - makes a link to a page relative to the parent page. The link appears in normal font.
{{rlp|/|title}} - makes a link to the parent page. The link appears in normal font.
{{rlt|page|title (optional)}} - makes a link to a page relative to this page. The link appears in teletype font.
{{rlpt|page|title (optional)}} - makes a link to a page relative to the parent page. The link appears in teletype font.
{{rlpt|/|title}} - makes a link to the parent page. The link appears in teletype font.
{{rlpf|page|title (optional)|args=arguments (optional)}} - makes a link to a page relative to the parent page. The link appears in teletype font. Parentheses indicating function are appended, which enclose the optional arguments.
{{ttt|identifier}} - makes a link to the current page (via the #top link). The identifier appears in teletype font.
| The above documentation is transcluded from Template:rl/doc. (edit | history) Subpages of this page. |
[edit] Links and information of standardization
[edit] wg21
Generates a link to a document of C++ Working Group (WG21), that is CWG/LWG page or a "proposal" file, respectively.
{{wg21|1=CWG or LWG or WG21 document-number|2=full (optional)}}
The (optional) argument full works only with "proposal" documents, and applying it results in the generation of an additional link to GitHub page (where the proposal is processed by WG21).
- Example: {{wg21|CWG613}} results in CWG613
- Example: {{wg21|LWG2844}} results in LWG2844
- Example: {{wg21|P1938R2}} results in P1938R2
- Example: (to make a link to the latest revision of the proposal) {{wg21|P1938}} results in P1938
- Example: {{wg21|P1938|full}} results in P1938 (github)
[edit] stddoc
Used to generate a link to a document of WG14/WG21.
The language/WG is determined by {{get lang}}, unless the optional parameter lang is given (if supported).
{{stddoc|1=document number|2=link title (optional)|lang=cpp or c (optional)}}
Generate a link to a WG14/WG21 document with the given document number. A custom link title can be provided, it is the capitalized document number by default. In C mode, document number can contain a file extension, e.g. n2081.htm. In C++ mode, there is no need to know/pass the extension due to wg21.link service automation.
- Example:
{{stddoc|p2443r1}}results in: P2443R1 - Example:
{{stddoc|P2443R1|views::chunk_by}}results in: views::chunk_by - Example:
{{stddoc|n2731|C23 draft|lang=c}}results in: C23 draft - Example:
{{stddoc|n2081.htm|n2081|lang=c}}results in: n2081
{{stddoc latest draft|1=link title (optional)}}
Generate a link to the latest draft of the next C/C++ standard.
- Presently,
{{stddoc latest draft}}results in: N4928 - Presently,
{{stddoc latest draft|Latest C++ draft}}results in: Latest C++ draft - Presently,
{{stddoc latest draft|Latest C draft}}results in: Latest C draft
[edit] stdinfo
Used to provide information of C/C++ standardization.
The language is determined by {{get lang}}, unless the optional parameter lang is given (if supported).
{{stdinfo latest draft docnum|lang=cpp or c (optional)}}
The document number of the latest draft of the C/C++ standard. Currently, results in: n3088 and n4928 for C/C++ respectively.
{{stdinfo latest draft docdate|lang=cpp or c (optional)}}
The document date of the latest draft of the C/C++ standard. Currently, results in 2023-01-24 and 2022-12-18 for C/C++ respectively.
{{stdinfo current version number}}
The version number of the current C/C++ standard. Currently, results in: 20
The version of the current C/C++ standard (with the prefix C or C++). Currently, results in: C++20
{{stdinfo next version number|lang=cpp or c (optional)}}
The version number of the next C/C++ standard. Currently, results in 23 and 23 for C/C++ respectively.
The version of the next C/C++ standard (with the prefix C or C++). Currently, results in: C++23
| The above documentation is transcluded from Template:stddoc/doc. (edit | history) Subpages of this page. |
[edit] Annotations
[edit] {{mark}} family of templates
Creates an annotation. Several annotations are already defined:
- Miscellaneous
{{mark deprecated}} results in (deprecated)
{{mark optional}} results in (optional)
{{mark implicit}} results in (implicitly declared)
{{mark concept}} results in (concept)
{{mark expos concept}} results in (exposition-only concept)
{{mark named req}} results in (named requirement)
{{mark typedef}} results in (typedef)
{{mark type alias}} results in (type alias)
{{mark enum}} results in (enum)
{{mark keyword}} results in (keyword)
{{mark macro keyword}} results in (keyword macro)
{{mark preprocessing directive}} results in (preprocessing directive)
{{mark macro opr}} results in (operator macro)
{{mark language}} results in (language)
- Standards
{{mark deprecated c++98}} results in (deprecated in C++98)
{{mark c++03}} results in (C++03)
{{mark since c++03}} results in (since C++03)
{{mark until c++03}} results in (until C++03)
{{mark c++11}} results in (C++11)
{{mark since c++11}} results in (since C++11)
{{mark deprecated c++11}} results in (deprecated in C++11)
{{mark until c++11}} results in (until C++11)
{{mark c++14}} results in (C++14)
{{mark since c++14}} results in (since C++14)
{{mark constexpr since c++14}} results in (constexpr since C++14)
{{mark deprecated c++14}} results in (deprecated in C++14)
{{mark until c++14}} results in (until C++14)
{{mark c++17}} results in (C++17)
{{mark since c++17}} results in (since C++17)
{{mark deprecated c++17}} results in (deprecated in C++17)
{{mark until c++17}} results in (until C++17)
{{mark c++20}} results in (C++20)
{{mark since c++20}} results in (since C++20)
{{mark constexpr since c++20}} results in (constexpr since C++20)
{{mark deprecated c++20}} results in (deprecated in C++20)
{{mark until c++20}} results in (until C++20)
{{mark c++23}} results in (C++23)
{{mark since c++23}} results in (since C++23)
{{mark deprecated c++23}} results in (deprecated in C++23)
{{mark updated c++23}} results in (updated in C++23)
{{mark until c++23}} results in (until C++23)
{{mark c++26}} results in (C++26)
{{mark since c++26}} results in (since C++26)
{{mark deprecated c++26}} results in (deprecated in C++26)
{{mark updated c++26}} results in (updated in C++26)
{{mark until c++26}} results in (until C++26)
{{mark c95}} results in (C95)
{{mark since c95}} results in (since C95)
{{mark until c95}} results in (until C95)
{{mark c99}} results in (C99)
{{mark since c99}} results in (since C99)
{{mark until c99}} results in (until C99)
{{mark c11}} results in (C11)
{{mark since c11}} results in (since C11)
{{mark until c11}} results in (until C11)
{{mark c17}} results in (C17)
{{mark since c17}} results in (since C17)
{{mark deprecated c17}} results in (deprecated in C17)
{{mark until c17}} results in (until C17)
{{mark c23}} results in (C23)
{{mark since c23}} results in (since C23)
{{mark until c23}} results in (until C23)
{{mark since none}} results in (since {std})
{{mark until none}} results in (until {std})
- Combinations
{{mark life|since=c++11|deprecated=c++17|removed=c++20}} results in
- (since C++11)(deprecated in C++17)(removed in C++20)
{{mark life|appear=c++11|until=c++20}} results in
- (C++11)(until C++20)
Optional parameter br can be set to yes to display each annotation in a separate line, e.g.
{{mark life|since=c++11|deprecated=c++17|removed=c++20|br=yes}} results in
- (since C++11)
(deprecated in C++17)
(removed in C++20)
{{mark optional syntax|std=c++11}} results in
(optional)
(C++11) (Note: arrangement is always vertical)
{{mark optional syntax|std=c++23}} results in
(optional)
(C++23)
- Technical specifications
{{mark since libfund ts}} results in (library fundamentals TS)
{{mark since libfund ts 2}} results in (library fundamentals TS v2)
{{mark since libfund ts 3}} results in (library fundamentals TS v3)
{{mark since fs ts}} results in (filesystem TS)
{{mark since parallelism ts}} results in (parallelism TS)
{{mark since parallelism ts 2}} results in (parallelism TS v2)
{{mark since concepts ts}} results in (concepts TS)
{{mark since concurrency ts}} results in (concurrency TS)
{{mark since concurrency ts 2}} results in (concurrency TS v2)
{{mark since tm ts}} results in (TM TS)
{{mark since special functions tr}} results in (special functions TR)
{{mark since modules ts}} results in (modules TS)
{{mark since coro ts}} results in (coroutines TS)
{{mark since reflection ts}} results in (reflection TS)
- Functions
{{mark fun}} results in (function)
{{mark tfun}} results in (function template)
{{mark mem fun}} results in (public member function)
{{mark mem sfun}} results in (public static member function)
{{mark mem vfun}} results in (virtual public member function)
{{mark priv mem fun}} results in (private member function)
{{mark prot mem fun}} results in (protected member function)
{{mark prot mem vfun}} results in (virtual protected member function)
{{mark expos mem fun}} results in (exposition-only member function)
{{mark macro fun}} results in (function macro)
- Classes
{{mark class}} results in (class)
{{mark tclass}} results in (class template)
{{mark talias}} results in (alias template)
{{mark ptclass}} results in (class template specialization)
{{mark mem class}} results in (public member class)
{{mark priv mem class}} results in (private member class)
{{mark prot mem class}} results in (protected member class)
{{mark priv mem tclass}} results in (private member class template)
{{mark expos mem class}} results in (exposition-only member class)
{{mark expos mem tclass}} results in (exposition-only member class template)
{{mark priv ntclass}} results in (private nested class template)
- Constants
{{mark macro const}} results in (macro constant)
{{mark const}} results in (constant)
{{mark mem const}} results in (public member constant)
{{mark mem sconst}} results in (public static member constant)
- Objects
{{mark mem obj}} results in (public member object)
{{mark priv mem obj}} results in (private member object)
{{mark prot mem obj}} results in (protected member object)
{{mark custpt}} result in (customization point object)
{{mark rao}} results in (range adaptor object)
{{mark niebloid}} result in (niebloid)
| The above documentation is transcluded from Template:mark/doc. (edit | history) Subpages of this page. |
[edit] {{cmark}} family of templates
Creates an annotation for a function. Several annotations are already defined:
{{cmark virtual}} results in [virtual]
{{cmark static}} results in [static]
{{cmark deleted}} results in [deleted]
| The above documentation is transcluded from Template:cmark/doc. (edit | history) Subpages of this page. |
[edit] Versioning
Used to declare that certain part of the description is valid to only specific revisions of the standard.
{{rev begin|noborder=true_if_noborder}}
- Begins the set of text snippets specific to a specific revision(s) of the standard. If the
noborderparameter is true then the table is displayed with no border and as little padding as possible.
{{rev|since=since-std (optional)|until=until-std (optional)|text}}
- Specifies that text is valid only for standard revisions since since-std until until-std (until-std is not inclusive).
{{rev end}}
- Ends the set of text snippets specific to a specific revision(s) of the standard.
{{rrev|noborder=true_if_noborder (optional)|since=since-std (optional)|until=until-std (optional)|text}}
{{rrev multi|noborder=true_if_noborder (optional)|sinceX=since-std (optional)|untilX=until-std (optional)|revX=text|...}}
- A combined {{rev begin}}/{{rev}}/{{rev end}}. Up to 7 snippets are supported. The default for
sinceXisuntilX-1and default foruntilXissinceX+1. Thus, it is most useful when the snippets are relatively short and the revision ranges consecutive. This template may be substituted.
{{rev inl|id=id (optional)|since=since-std (optional)|until=until-std (optional)|noborder=true_if_noborder|text}}
- Same as {{rev}}, just is displayed inline. {{rev begin}} and {{rev end}} must not be used. The text can be referenced with id.
Border is omitted if the noborder parameter is true.
| The above documentation is transcluded from Template:rev/doc. (edit | history) Subpages of this page. |
[edit] Feature-test macros rendering
[edit] Feature-test macros support
Used to generate the links to the pages/tables that describe given feature-test macro.
[edit] One-row form
{{feature test macro|1=feature-test-macro-name|2=comment (optional)|value=date (optional)|std=C++XX (optional)}}
Example: {{feature test macro|__cpp_constexpr}} results in
| Feature-test macro |
|---|
__cpp_constexpr
|
Example: {{feature test macro|__cpp_lib_ranges}} results in
| Feature-test macro |
|---|
__cpp_lib_ranges
|
Example: {{feature test macro|__cpp_lib_ranges|your comment}} results in
| Feature-test macro | Comment |
|---|---|
__cpp_lib_ranges |
your comment |
Example: {{feature test macro|__cpp_lib_iota|my comment|std=C++23}} results in
| Feature-test macro | Std | Comment |
|---|---|---|
__cpp_lib_iota |
(C++23) | my comment |
Example: {{feature test macro|__cpp_lib_iota|my comment|value=202202L}} results in
| Feature-test macro | Value | Comment |
|---|---|---|
__cpp_lib_iota |
202202L | my comment |
Example: {{feature test macro|__cpp_lib_iota|my comment|value=202202L|std=C++23}} results in
| Feature-test macro | Value | Std | Comment |
|---|---|---|---|
__cpp_lib_iota |
202202L | (C++23) | my comment |
[edit] Multi-row form
If there is more than one feature-test macro on a page then they should be combined in a table using these templates:
{{ftm begin|params}}
{{ftm|params}}
...
{{ftm end}}
[edit] Syntax
{{ftm begin|core=yes (optional)|std=yes (optional)|comment=yes (optional)|sort=yes (optional)}}
Describes the table and defined which columns will be present. By default, only one column is present: the feature-test macro name.
- if the named parameter core is assigned then link (in the title of the table) to the <version> page (for library features) will not be generated
- if the named parameter std is assigned then the columns "Value" and "Std" will be added
- if the named parameter comment is assigned then the column "Comment" will be added
- if the named parameter sort is assigned then the table will be the "sortable" wiki-table
{{ftm|1=macro name|2=your comment (optional)|value=value (optional)|std=C++XX (optional)|rowspan="R" (optional)|dr=yes (optional)}}
- macro name is obligatory positional parameter #1, the feature-test macro name, e.g.
__cpp_lib_constexpr - your comment is optional positional parameter #2, meant to be the commenting string for the macro
- value is an optional feature-test value, e.g. 202202L
- std is an optional feature-test C++ revision string, e.g. C++23
- rowspan is an optional parameter (e.g.,
rowspan="3") with the same meaning as in ordinary wiki-tables; the effect is the vertical merging ofRcells into one, with only 1 feature-test macro name inside. The followingR-1{{ftm}}s should go with - char instead of current feature-test macro name (see examples below). - dr is an optional parameter that adds a (DR) mark under C++ revision (e.g., under (C++77)).
Note: the columns described in {{ftm begin}} and the parameters passed to {{ftm}} should suit each other, that is, if the intention is to create a table with all supported columns, then all parameters should be defined for both templates. Else, the parameters for columns not described in the {{ftm begin}} should not be passed to {{ftm}}.
[edit] Examples
The sequence
{{ftm begin}}
{{ftm|__cpp_lib_x}}
{{ftm|__cpp_lib_y}}
{{ftm end}}
results in:
| Feature-test macro |
|---|
__cpp_lib_x
|
__cpp_lib_y
|
The sequence
{{ftm begin|comment=yes}}
{{ftm|__cpp_lib_1|test comment 1}}
{{ftm|__cpp_lib_2|test comment 2}}
{{ftm|__cpp_lib_3|test comment 3}}
{{ftm end}}
results in:
| Feature-test macro | Comment |
|---|---|
__cpp_lib_1 |
test comment 1 |
__cpp_lib_2 |
test comment 2 |
__cpp_lib_3 |
test comment 3 |
The sequence
{{ftm begin|std=yes|sort=yes}}
{{ftm|std=C++23|value=202207L|__cpp_lib_find_last}}
{{ftm|std=C++23|value=202207L|__cpp_lib_fold}}
{{ftm|std=C++20|value=201911L|__cpp_lib_ranges}}
{{ftm|std=C++20|value=202106L|__cpp_lib_ranges}}
{{ftm|std=C++20|value=202110L|__cpp_lib_ranges}}
{{ftm|std=C++23|value=202202L|__cpp_lib_ranges}}
{{ftm|std=C++23|value=202207L|__cpp_lib_ranges_contains}}
{{ftm|std=C++23|value=202202L|__cpp_lib_ranges_iota}}
{{ftm|std=C++23|value=202106L|__cpp_lib_ranges_starts_ends_with}}
{{ftm|std=C++20|value=201806L|__cpp_lib_shift}}
{{ftm|std=C++23|value=202202L|__cpp_lib_shift}}
{{ftm end}}
results in:
| Feature-test macro | Value | Std |
|---|---|---|
__cpp_lib_find_last |
202207L | (C++23) |
__cpp_lib_fold |
202207L | (C++23) |
__cpp_lib_ranges |
201911L | (C++20) |
__cpp_lib_ranges |
202106L | (C++20) |
__cpp_lib_ranges |
202110L | (C++20) |
__cpp_lib_ranges |
202202L | (C++23) |
__cpp_lib_ranges_contains |
202207L | (C++23) |
__cpp_lib_ranges_iota |
202202L | (C++23) |
__cpp_lib_ranges_starts_ends_with |
202106L | (C++23) |
__cpp_lib_shift |
201806L | (C++20) |
__cpp_lib_shift |
202202L | (C++23) |
The sequence
{{ftm begin|std=yes|sort=yes}}
{{ftm|std=C++23|value=202207L|__cpp_lib_find_last}}
{{ftm|std=C++23|value=202207L|__cpp_lib_fold}}
{{ftm|std=C++20|value=201911L|__cpp_lib_ranges|rowspan="4"}}
{{ftm|std=C++20|value=202106L|-}}
{{ftm|std=C++20|value=202110L|-}}
{{ftm|std=C++23|value=202202L|-}}
{{ftm|std=C++23|value=202207L|__cpp_lib_ranges_contains}}
{{ftm|std=C++23|value=202202L|__cpp_lib_ranges_iota}}
{{ftm|std=C++23|value=202106L|__cpp_lib_ranges_starts_ends_with}}
{{ftm|std=C++20|value=201806L|__cpp_lib_shift|rowspan="2"}}
{{ftm|std=C++23|value=202202L|-}}
{{ftm end}}
results in:
| Feature-test macro | Value | Std |
|---|---|---|
__cpp_lib_find_last |
202207L | (C++23) |
__cpp_lib_fold |
202207L | (C++23) |
__cpp_lib_ranges |
201911L | (C++20) |
| 202106L | (C++20) | |
| 202110L | (C++20) | |
| 202202L | (C++23) | |
__cpp_lib_ranges_contains |
202207L | (C++23) |
__cpp_lib_ranges_iota |
202202L | (C++23) |
__cpp_lib_ranges_starts_ends_with |
202106L | (C++23) |
__cpp_lib_shift |
201806L | (C++20) |
| 202202L | (C++23) |
| The above documentation is transcluded from Template:ftm/doc. (edit | history) Subpages of this page. |
[edit]
{{navbar
| style =
| heading1 =
| content1 =
| heading2 =
| content2 =
| heading3 =
| content3 =
...
| heading8 =
| content8 =
}}
| The above documentation is transcluded from Template:navbar/doc. (edit | history) Subpages of this page. |
[edit] Miscellaneous
[edit] Spaces
Handles space characters.
{{space|number}} - outputs number of space characters
{{space as|text}} - outputs as many space characters as there are characters in text. Useful for indentation of templatized code.
{{trim|text}} - trims both leading and trailing whitespace
{{sep}} - inserts a tiny non-breaking space between characters to avoid overlapping of e.g. italicized characters. Example: II vs I I.
{{nbsp|number (optional)}} - generates number of non-breaking space characters (HTML: ). Default is 1, maximum is 8.
{{void}} - as-if inserts an empty space which might be necessary to prevent HTML generation when wiki-media processor should act. One example is foo<Ref> in which the <Ref> part provokes an HTML engine to generate a references list. To suppress that, this code could be written as {{c|foo<{{void}}Ref>}}.
| The above documentation is transcluded from Template:space/doc. (edit | history) Subpages of this page. |
[edit] Headers
Used to create a link to C or C++ header description page.
{{header|name|lang=cpp or c (optional)}}, where name is a header name (without triangle brackets).
- On C++ pages {{header|iostream}} results in <iostream>
| The above documentation is transcluded from Template:header/doc. (edit | history) Subpages of this page. |
[edit] Utility templates (intended to be used only by other templates)
[edit] Cast requirements
This is one of the templates used to specify that some type must be convertible to another. All these templates can emit either of the requirements that it must be possible to convert an object of particular type to another type or it must be possible to dereference an object of particular type and then convert it to another type. This behavior depends an the supplied parameters (t means plain type, p - type that must be dereferenced first).
{{cast rreq| base_type| rt=type or rp=pointer_type}} - base_type must be convertible to rt or *rp.
{{cast req1| base_type| t1=type or p1=pointer_type}} - t1 or *p1 must be convertible to base_type.
{{cast req2| base_type1| base_type2| t1=type or p1=pointer_type| t2=type or p2=pointer_type (optional)}} - t1 or *p1 must be convertible to base_type1 or t2 or *p2 must be convertible to base_type2. If neither t2 nor p2 is supplied, it is assumed that t1 or *p1 must be convertible to both base_type1 or base_type2.
| The above documentation is transcluded from Template:cast rreq/doc. (edit | history) Subpages of this page. |

