Difference between revisions of "Help:Templates"
m (→Feature-test macros rendering: Add section.) |
m (→Standard containers classification: +) |
||
Line 70: | Line 70: | ||
{{documentation|Template:cast rreq/doc}} | {{documentation|Template:cast rreq/doc}} | ||
+ | |||
+ | ====Standard containers classification==== | ||
+ | |||
+ | {{documentation|Template:cpp/container/if_assoc/doc}} | ||
{{langlinks|zh}} | {{langlinks|zh}} |
Latest revision as of 03:40, 20 December 2023
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.
[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/MediaWiki elements | Preview |
---|---|---|---|
{{tt|text}} | text in monospace font | <code>
|
text
|
{{ttb|text}} | text in bold monospace font | <code><b>
|
text
|
{{tti|text}} | text in italic monospace font | <code><i>
|
text
|
{{normal|text}} | text in normal font weight | ... font-weight: normal; ...
|
text |
{{ttn|text}} | text in monospace font of normal weight | {{normal|<code> text</code>}}
|
text
|
{{ttni|text}} | text in italic monospace font of normal weight | {{normal|<code><i> text</i></code>}}
|
text
|
{{petty|text}} | small-ish text | <small>
|
text |
{{small|text}} | small text | ... font-size: 0.7em; line-height: 130%; ...
|
text |
{{smalltt|text}} | small text in monospace font | {{small|<code> text</code>}}
|
text
|
{{sub|text}} | subscripted text in normal font | <sub>
|
text |
{{sup|text}} | superscripted text in normal font | <sup>
|
text |
{{p|text}} | text in a new paragraph | <p>text</p>
|
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|code |lang=language (optional)}}
- A base template that is intended to highlight code inline.
lang
is 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 an equal sign = is present somewhere in the expression.
- For code snippets in ranges (such as
[
begin,
end)
), the {{range}} template family is preferred.
{{c multi|line1 |line2 (optional)|... |line8 (optional)|lang=language (optional)}}
- Alike {{c}}, supports multi-line code snippets (up to 8 lines).
lang
is optional; value returned by {{get lang}} is used by default. Code highlighting does not span across lines: avoid splitting string literals ("") and multi-line comments (/* */). - Example (note the padding spaces):
{{c multi|std::max(std::numeric_limits<int>::max(),| std::numeric_limits<int>::min())}}
- or (note the convenient indentation):
-
{{c multi
|std::max(std::numeric_limits<int>::max(),
| std::numeric_limits<int>::min())}} - results in
- std::max(std::numeric_limits<int>::max(),
std::numeric_limits<int>::min()).
- Note that if an equal sign = is present somewhere in the corresponding line, the leading |1=/|2=/|3=/.../|8= are necessary, e.g.
{{c multi
|1=std::any = 42;
|2=std::any = 3.14;}} - results in
- std::any = 42;
std::any = 3.14;.
{{cc multi|line1 |line2 (optional)|... |line8 (optional)|lang=language (optional)}}
- Same as {{c multi}} just no background (e.g. the bounding box) is applied.
- Example (note the padding spaces):
-
{{cc multi|std::max(std::numeric_limits<int>::max(),| std::numeric_limits<int>::min())}}
- or
-
{{cc multi|std::max(std::numeric_limits<int>::max(),|{{nbsp|9}}std::numeric_limits<int>::min())}}
- or (note the convenient indentation):
-
{{cc multi
|std::max(std::numeric_limits<int>::max(),
| std::numeric_limits<int>::min())}} - results in
- std::max(std::numeric_limits<int>::max(),
std::numeric_limits<int>::min()).
{{c/core|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|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|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:
{{ltt std|cpp/algorithm/swap}}{{tt|''<int>''}}{{c/core|(x, y);}}}}
results in std::swap<int>
(x, y);
{{box/core|tags }}
- Same as {{box}} just no background (e.g. the bounding box) is applied.
- Example:
-
{{box/core|{{c/core|std::common_reference_t<ranges::range_reference_t<R1>,}}<br>{{nbspt|24}}{{c/core|ranges::range_reference_t<R2>>}}}}
- results in
- std::common_reference_t<ranges::range_reference_t<R1>,
{{cc|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.
lang
is 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|code |lang=language (optional)}}
- A base template that is intended to highlight large amounts of code.
lang
is 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|code1 |code2 (optional)|... |code4 (optional)|lang=language (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}}.lang
is 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|code1 |code2 (optional)|... |code4 (optional)|title1 (optional)|... |title4 (optional)|lang=language (optional)}}
Additional params:
{{eq impl|ver1=link1 |... |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
verN
is 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)|std=language standard (optional)|code=code to display |p=true if nondeterministic (optional)|output=sample output (optional)}}
- A base template to represent examples. If
code
is not present, the template results in {{todo}}.lang
defaults to a value returned by {{get lang}}.output
specifies the output which is displayed by the code. If the output is not deterministic,p
should be set totrue
to 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
This is one of templates used to make links.
[edit] Absolute links
[edit] Normal font
{{lt|path |title (optional)}} - creates a link to a page using absolute path. The default title is only the last part of the path.
- 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.
{{ls|path#section }} - makes a link to a section (anchor) on a page given by absolute path. The section text is also used as the title. To create a link on the same page the path part should be empty.
- Example:
{{ls|cpp/language/lambda#Syntax}}
results in the link: Syntax. - To create a link to a section/anchor within the current page the path part should be omitted.
- Example:
{{ls|#Relative links}}
results in the link: Relative links (i.e. a link to the section in this page).
{{lsd|path#Section }} ("lsd" stands for "Link to Section De-capitalized") - almost the same as {{ls}} except it de-capitalizes the first letter of displayed section name. To create a link on the same page the path part should be empty.
- Example:
{{lsd|cpp/language/array#Arrays of unknown bound}}
results in the link: arrays of unknown bound. - Example:
{{lsd|#Relative links}}
results in the link: relative links (i.e. a link to the section in this page).
[edit] Teletype font
{{ltt|path |title (optional)}} - creates a link to a page using absolute path. The default title is only the last part of the path.
- 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)}} - creates a link to a page using absolute path. The default title is only the last part of the path. 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).
{{ltp|path |title (optional)|targs=template arguments (optional)}} - creates a link to a page using absolute path. The default title is only the last part of the path. Angle brackets indicating template are appended, which enclose the optional template arguments.
- Example:
{{ltp|cpp/container/vector}}
results in the link: vector<>. - Example:
{{ltp|cpp/container/vector|targs=int}}
results in the link: vector<int>. - Example:
{{ltp|cpp/container/vector|targs=std::size_t}}
results in the link: vector<std::size_t>.
{{ltpf|path |title (optional)|targs=template arguments (optional)|args=arguments (optional)}} - creates a link to a page using absolute path. The default title is only the last part of the path. Angle brackets indicating template are appended, which enclose the optional template arguments. After that, parentheses indicating function are appended, which enclose the optional arguments.
- Example:
{{ltpf|cpp/container/vector/vector|targs=int|args=5}}
results in the link: vector<int>(5). - Example:
{{ltpf|cpp/locale/use_facet|targs=Facet|args=loc}}
results in the link: use_facet<Facet>(loc).
{{lst|path#section }} - makes a link to a section (anchor) on a page given by absolute path. The section text is also used as the title. To create a link on the same page the path part should be empty.
- Example:
{{lst|cpp/ranges#maybe-const}}
results in the link:maybe-const
. - Example:
{{lst|#top}}
results in the link:top
. - Example:
{{lst|#top_}}
results in the link:top_
(note that the trailing underscore character of the link is automatically trimmed).
{{l2tt|page |title1 (optional)|title2 (optional)}} - creates 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.
- 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)}} - creates 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. 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] Italic teletype font
{{lti|path |title (optional)}} - creates a link to a page using absolute path. The default title is only the last part of the path.
- Example:
{{lti|cpp/concepts/boolean-testable}}
results in the link: boolean-testable.
{{ltpi|path |title (optional)|targs=template arguments (optional)}} - creates a link to a page using absolute path. The default title is only the last part of the path. Angle brackets indicating template are appended, which enclose the optional template arguments.
- Example:
{{ltpi|cpp/concepts/boolean-testable}}
results in the link: boolean-testable <>. - Example:
{{ltpi|cpp/concepts/boolean-testable|targs=int}}
results in the link: boolean-testable <int>.
{{lsi|path#section }} - makes a link to a section (anchor) on a page given by absolute path. The section text is also used as the title. To create a link on the same page the path part should be empty.
- Example:
{{lsi|cpp/ranges#maybe-const}}
results in the link:maybe-const
. - Example:
{{lsi|#top}}
results in the link:top
. - Example:
{{lsi|#top_}}
results in the link:top_
(note that the trailing underscore character of the link is automatically trimmed).
[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. All links appear in teletype font.
{{ltt std|path }} - link to a page using absolute path. The title is std::
followed by the last part of the path.
- 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.
- 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 ::
.
- 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.
- Example:
{{l2tf std|cpp/utility/expected/value}}
results in the link: std::expected::value().
[edit] Relative links
[edit] Normal font
{{rl|page |title (optional)}} - makes a link to a page relative to this page (i.e. to a sub-page).
{{rlp|page |title (optional)}} - makes a link to a page relative to the parent page.
{{rlp|/ |title }} - makes a link to the parent page.
{{rlps|page#section }} - makes a link to a section (anchor) on a page relative to the parent page. The title of the generated link is the section name.
{{rlpsd|page#Section }} - makes a link to a section (anchor) on a page relative to the parent page. The title of the generated link is the section name with the first letter de-capitalized.
[edit] Teletype font
{{rlt|page |title (optional)}} - makes a link to a page relative to this page (i.e. to a sub-page).
{{rlpt|page |title (optional)}} - makes a link to a page relative to the parent page.
{{rlpt|/ |title }} - makes a link to the parent page.
{{rlpf|page |title (optional)|args=arguments (optional)}} - makes a link to a page relative to the parent page. Parentheses indicating function are appended, which enclose the optional arguments.
{{rlpst|page#section }} - makes a link to a section (anchor) on a page relative to the parent page. The title of the generated link is the section name.
{{ttt|identifier }} - makes a link to the current page (via the #top link).
[edit] Italic teletype font
{{rli|page |title (optional)}} - makes a link to a page relative to this page (i.e. to a sub-page).
{{rlpi|page |title (optional)}} - makes a link to a page relative to the parent page.
{{rlpi|/ |title }} - makes a link to the parent page.
{{rlpsi|page#section }} - makes a link to a section (anchor) on a page relative to the parent page. The title of the generated link is the section name.
[edit] Decorated links
{{attr|attribute |title (optional)|additional title (optional)|lang=language (optional)}}
- attribute - an attribute specifier name.
- title - an attribute specifier title.
- additional title - additional elements after the title.
- language - cpp or c. If language is not given, {{get lang}} is used.
- Example:
{{attr|assume}}
results in[[assume]]
. - Example:
{{attr|noreturn|_Noreturn|lang=c}}
results in[[_Noreturn]]
. - Example:
{{attr|deprecated|3=("because")}}
results in[[deprecated("because")]]
.
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|CWG or LWG or WG21 document-number |full (optional)}}
- The full (optional) argument 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).
[edit] stddoc
Used to generate a link to a document of WG14/WG21.
The WG/language (C or C++) is determined by {{get lang}}, unless the lang (optional) argument with a value c or cpp is provided (if supported).
{{stddoc|document number |link title (optional)|lang=lang (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
- Example:
{{stddoc latest draft|link title (optional)|lang=lang (optional)}}
- Generate a link to the latest draft of the next C/C++ standard.
- Presently,
{{stddoc latest draft}}
results in: N4993 - Presently,
{{stddoc latest draft|Latest C++ draft}}
results in: Latest C++ draft - Presently,
{{stddoc latest draft|Latest C draft|lang=c}}
results in: Latest C draft
- Presently,
[edit] stdinfo
Used to provide information of C/C++ standardization.
- The language (C or C++) is determined by {{get lang}}, unless the lang (optional) argument with a value c or cpp is provided (if supported).
{{stdinfo latest draft|rev or doc or date |lang=lang (optional)}}
- Is a hub for C/C++ standard draft information. Depending on the value of the first argument, the returned info is:
value info Example rev version number {{stdinfo latest draft|rev}}
results in 26{{stdinfo latest draft|rev|lang=c}}
results in 2ydoc document number {{stdinfo latest draft|doc}}
results in n4993{{stdinfo latest draft|doc|lang=c}}
results in n3301date document date {{stdinfo latest draft|date}}
results in 2024-10-16{{stdinfo latest draft|date|lang=c}}
results in 2024-07-28
- Is used inside the following higher-level templates:
- {{stdinfo latest draft docnum}}, {{stdinfo latest draft docdate}}, {{stdinfo next version number}}, {{stdinfo next version}}.
{{stdinfo latest draft docnum|lang=lang (optional)}}
- The document number of the latest draft of the C/C++ standard.
- For C results in n3301.
- For C++ results in n4993.
{{stdinfo latest draft docdate|lang=lang (optional)}}
- The document date of the latest draft of the C/C++ standard.
- For C results in 2024-07-28.
- For C++ results in 2024-10-16.
{{stdinfo next version number|lang=lang (optional)}}
- The version number of the next C/C++ standard.
- For C results in 2y.
- For C++ results in 26.
- The version of the next C/C++ standard (with the prefix C or C++). Results in: C++
{{stdinfo current version number}}
- The version number of the current C/C++ standard. Results in: 20
- The version of the current C/C++ standard (with the prefix C or C++). Results in: C++20
[edit] Current language
{{get lang}}
- If the page title begins with "c/", then the output value is "c", if the page title begins with "cpp/", then the output value is "cpp". Otherwise the output value is "cpp".
{{get lang formal}}
- If the page title begins with "c/", then the output value is "C", if the page title begins with "cpp/", then the output value is "C++". Otherwise the output value is "C++".
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.
- General
{{mark|text |class=classes (optional)}} - creates an annotation containing the given text, extra classes can be provided for styling.
- Example:
{{mark|text}}
results in (text).
{{mark rev|text |class=classes (optional)}} - creates an annotation containing the given text, extra classes can be provided for styling.
- Example:
{{mark rev|since C++1998}}
results in (since C++1998).
{{mark tooltip|text |tooltip |class=classes (optional)}} - creates an annotation containing the given text with tooltip, extra classes can be provided for styling.
- Example:
{{mark tooltip|99% complete|XXX not supported}}
results in (99% complete*).
- Miscellaneous
Template | Annotation |
---|---|
{{mark attribute}} | (attribute specifier) |
{{mark deprecated}} | (deprecated) |
{{mark optional}} | (optional) |
{{mark cond present}} | (conditionally present) |
{{mark implicit}} | (implicitly declared) |
{{mark concept}} | (concept) |
{{mark expos}} | (exposition only*) |
{{mark expos concept}} | (exposition-only concept*) |
{{mark tag}} | (tag) |
{{mark expos mem type}} | (exposition-only member type*) |
{{mark named req}} | (named requirement) |
{{mark typedef}} | (typedef) |
{{mark type alias}} | (type alias) |
{{mark enum}} | (enum) |
{{mark mem enum}} | (public member enum) |
{{mark keyword}} | (keyword) |
{{mark macro keyword}} | (keyword macro) |
{{mark preprocessing directive}} | (preprocessing directive) |
{{mark macro opr}} | (operator macro) |
{{mark language}} | (language) |
- C++ Standards
Template | Annotation |
---|---|
{{mark deprecated c++98}} | (deprecated in C++98) |
{{mark c++03}} | (C++03) |
{{mark since c++03}} | (since C++03) |
{{mark until c++03}} | (until C++03) |
{{mark c++11}} | (C++11) |
{{mark since c++11}} | (since C++11) |
{{mark constexpr since c++11}} | (constexpr since C++11) |
{{mark noexcept since c++11}} | (noexcept since C++11) |
{{mark deprecated c++11}} | (deprecated in C++11) |
{{mark until c++11}} | (until C++11) |
{{mark c++14}} | (C++14) |
{{mark since c++14}} | (since C++14) |
{{mark constexpr since c++14}} | (constexpr since C++14) |
{{mark noexcept since c++14}} | (noexcept since C++14) |
{{mark deprecated c++14}} | (deprecated in C++14) |
{{mark until c++14}} | (until C++14) |
{{mark c++17}} | (C++17) |
{{mark since c++17}} | (since C++17) |
{{mark constexpr since c++17}} | (constexpr since C++17) |
{{mark noexcept since c++17}} | (noexcept since C++17) |
{{mark deprecated c++17}} | (deprecated in C++17) |
{{mark until c++17}} | (until C++17) |
{{mark c++20}} | (C++20) |
{{mark since c++20}} | (since C++20) |
{{mark constexpr since c++20}} | (constexpr since C++20) |
{{mark noexcept since c++20}} | (noexcept since C++20) |
{{mark deprecated c++20}} | (deprecated in C++20) |
{{mark until c++20}} | (until C++20) |
{{mark c++23}} | (C++23) |
{{mark since c++23}} | (since C++23) |
{{mark constexpr since c++23}} | (constexpr since C++23) |
{{mark noexcept since c++23}} | (noexcept since C++23) |
{{mark deprecated c++23}} | (deprecated in C++23) |
{{mark updated c++23}} | (updated in C++23) |
{{mark until c++23}} | (until C++23) |
{{mark c++26}} | (C++26) |
{{mark since c++26}} | (since C++26) |
{{mark constexpr since c++26}} | (constexpr since C++26) |
{{mark noexcept since c++26}} | (noexcept since C++26) |
{{mark deprecated c++26}} | (deprecated in C++26) |
{{mark updated c++26}} | (updated in C++26) |
{{mark until c++26}} | (until C++26) |
- C Standards
Template | Annotation |
---|---|
{{mark c95}} | (C95) |
{{mark since c95}} | (since C95) |
{{mark until c95}} | (until C95) |
{{mark c99}} | (C99) |
{{mark since c99}} | (since C99) |
{{mark until c99}} | (until C99) |
{{mark c11}} | (C11) |
{{mark since c11}} | (since C11) |
{{mark until c11}} | (until C11) |
{{mark c17}} | (C17) |
{{mark since c17}} | (since C17) |
{{mark deprecated c17}} | (deprecated in C17) |
{{mark until c17}} | (until C17) |
{{mark c23}} | (C23) |
{{mark since c23}} | (since C23) |
{{mark deprecated c23}} | (deprecated in C23) |
{{mark until c23}} | (until C23) |
{{mark since none}} | (since {std}) |
{{mark until none}} | (until {std}) |
- Combinations
{{mark life|appear=c++xx (optional)|since=c++xx (optional)|deprecated=c++xx (optional)|until=c++xx (optional)|removed=c++xx (optional)|br=yes (optional)}}
- Example:
{{mark life|since=c++11|deprecated=c++17|removed=c++20}}
results in - (since C++11)(deprecated in C++17)(removed in C++20)
- Example:
{{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.
- Example:
{{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)
- Technical specifications
Template | Annotation |
---|---|
{{mark since libfund ts}} | (library fundamentals TS) |
{{mark since libfund ts 2}} | (library fundamentals TS v2) |
{{mark since libfund ts 3}} | (library fundamentals TS v3) |
{{mark since fs ts}} | (filesystem TS) |
{{mark since parallelism ts}} | (parallelism TS) |
{{mark since parallelism ts 2}} | (parallelism TS v2) |
{{mark since concepts ts}} | (concepts TS) |
{{mark since concurrency ts}} | (concurrency TS) |
{{mark since concurrency ts 2}} | (concurrency TS v2) |
{{mark since tm ts}} | (TM TS) |
{{mark since special functions tr}} | (special functions TR) |
{{mark since modules ts}} | (modules TS) |
{{mark since coro ts}} | (coroutines TS) |
{{mark since reflection ts}} | (reflection TS) |
- Functions
Template | Annotation |
---|---|
{{mark fun}} | (function) |
{{mark tfun}} | (function template) |
{{mark mem fun}} | (public member function) |
{{mark mem sfun}} | (public static member function) |
{{mark mem vfun}} | (virtual public member function) |
{{mark priv mem fun}} | (private member function) |
{{mark prot mem fun}} | (protected member function) |
{{mark prot mem vfun}} | (virtual protected member function) |
{{mark expos mem fun}} | (exposition-only member function*) |
{{mark expos mem sfun}} | (exposition-only static member function*) |
{{mark macro fun}} | (function macro) |
- Classes
Template | Annotation |
---|---|
{{mark class}} | (class) |
{{mark tclass}} | (class template) |
{{mark talias}} | (alias template) |
{{mark ptclass}} | (class template specialization) |
{{mark mem class}} | (public member class) |
{{mark priv mem class}} | (private member class) |
{{mark prot mem class}} | (protected member class) |
{{mark mem tclass}} | (public member class template) |
{{mark priv mem tclass}} | (private member class template) |
{{mark expos mem class}} | (exposition-only member class*) |
{{mark expos mem tclass}} | (exposition-only member class template*) |
{{mark priv ntclass}} | (private nested class template) |
- Constants
Template | Annotation |
---|---|
{{mark macro const}} | (macro constant) |
{{mark const}} | (constant) |
{{mark mem const}} | (public member constant) |
{{mark mem sconst}} | (public static member constant) |
{{mark expos mem sconst}} | (exposition-only static member constant*) |
- Objects
Template | Annotation |
---|---|
{{mark mem obj}} | (public member object) |
{{mark priv mem obj}} | (private member object) |
{{mark prot mem obj}} | (protected member object) |
{{mark expos mem obj}} | (exposition-only member object*) |
{{mark expos mem var}} | (exposition-only variant member object*) |
{{mark custpt}} | (customization point object) |
{{mark rao}} | (range adaptor object) |
{{mark niebloid}} | (niebloid) |
- Container marks support
{{cpp/container/mark std|container}} - outputs (C++11), (C++20), (C++23) etc., according to the revision of given standard container. The output is empty for pre-C++11 containers.
[edit] Example
-
{{cpp/container/mark std|vector}}
results in (nothing) -
{{cpp/container/mark std|array}}
results in (C++11) -
{{cpp/container/mark std|unordered_set}}
results in (C++11) -
{{cpp/container/mark std|span}}
results in (C++20) -
{{cpp/container/mark std|flat_set}}
results in (C++23)
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 (optional)}}
- Begins the set of text snippets specific to a specific revision(s) of the standard. If the
noborder
parameter 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
sinceX
isuntilX-1
and default foruntilX
issinceX+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 (optional)|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-testing macros support
Used to generate links and tables that describe given feature-testing macros.
[edit] One-row form
{{feature test macro|feature-test-macro-name |feature |value=date |std=C++XY |dr=yes or NN (optional)}}
Example:
-
{{feature test macro|__cpp_lib_string_view|{{lc|std::string_view}}|value=201606L|std=C++17}}
- results in
Feature-test macro | Value | Std | Feature |
---|---|---|---|
__cpp_lib_string_view |
201606L | (C++17) | std::string_view |
Example:
-
{{feature test macro|__cpp_inheriting_constructors|Rewording|value=201511L|std=C++11|dr=98}}
- results in
Feature-test macro | Value | Std | Feature |
---|---|---|---|
__cpp_inheriting_constructors |
201511L | (C++11) (DR98) |
Rewording |
[edit] Multi-row form
If there is more than one feature-testing macro on a page then they should be combined in a table using the following templates:
{{ftm begin|params (optional)}}
{{ftm|params }}
...
{{ftm end}}
[edit] Syntax
{{ftm begin|core=yes (optional)|sort=yes (optional)}}
Determines the table's properties.
- If the named parameter core is provided then a link (in the title of the table) to the library features page will not be generated.
- If the named parameter sort is provided then the table will be a "sortable" wiki-table.
- Note: Previously, two additional (optional) parameters were supported: std and comment (both are ignored now), used to conditionally add/hide columns. Std, Value, and Feature columns are always present.
{{ftm|cpp-macro |feature |value=value |std=C++XX |rowspan=R (optional)|dr=yes or XZ (optional)}}
- cpp-macro provides the feature-test macro name, e.g.
__cpp_lib_constexpr
- feature provides the feature description
- value provides the feature-test value (a date), e.g. 202202L
- std provides revision string, e.g. (C++23)
- rowspan is an optional parameter (e.g.,
rowspan="3"
) which has the same meaning as in standard wiki-tables, i.e., if provided, it results in a vertical merging ofR
adjacent cells (in Feature-test macro column) into one, with a single feature-test macro name rendered inside. The following R - 1 {{ftm}}s should go with - char instead of the macro name. - dr, if provided with argument "yes", adds a (DR) mark below the C++ revision.
- dr, if provided with argument other than "yes", e.g. revision number 98, adds a (DR98) mark below the C++ revision.
[edit] Example
The sequence
{{ftm begin|sort=yes}} {{ftm|std=C++23|value=202207L|__cpp_lib_find_last|comment #1}} {{ftm|std=C++23|value=202207L|__cpp_lib_fold|comment #2}} {{ftm|std=C++20|value=201911L|__cpp_lib_ranges|rowspan="4"|comment #3}} {{ftm|std=C++20|value=202106L|-|comment #4}} {{ftm|std=C++20|value=202110L|-|comment #5|dr=yes}} {{ftm|std=C++23|value=202202L|-|comment #6|dr=20}} {{ftm|std=C++23|value=202207L|__cpp_lib_ranges_contains|comment #7}} {{ftm|std=C++23|value=202202L|__cpp_lib_ranges_iota|comment #8}} {{ftm|std=C++23|value=202106L|__cpp_lib_ranges_starts_ends_with|comment #9}} {{ftm|std=C++20|value=201806L|__cpp_lib_shift|rowspan="2"|comment #10}} {{ftm|std=C++23|value=202202L|-|comment #11}} {{ftm end}}
results in:
Feature-test macro | Value | Std | Feature |
---|---|---|---|
__cpp_lib_find_last |
202207L | (C++23) | comment #1 |
__cpp_lib_fold |
202207L | (C++23) | comment #2 |
__cpp_lib_ranges |
201911L | (C++20) | comment #3 |
202106L | (C++20) | comment #4 | |
202110L | (C++20) (DR) |
comment #5 | |
202202L | (C++23) (DR20) |
comment #6 | |
__cpp_lib_ranges_contains |
202207L | (C++23) | comment #7 |
__cpp_lib_ranges_iota |
202202L | (C++23) | comment #8 |
__cpp_lib_ranges_starts_ends_with |
202106L | (C++23) | comment #9 |
__cpp_lib_shift |
201806L | (C++20) | comment #10 |
202202L | (C++23) | comment #11 |
[edit] Inline forms
{{ftm link|feature-test-macro-name }}
Produces a simple link to cpp/feature test tables.
- feature-test-macro-name - a FTM name, e.g.
__cpp_constexpr
or__cpp_lib_ratio
Example:
-
{{ftm link|__cpp_constexpr}}
results in__cpp_constexpr
-
{{ftml|feature-test-macro-name |since-rev (optional)|updated-in-rev-list (optional)}}
Produces a simple link with revision mark(s), designed to be used in pages such as Macro Symbol Index.
- feature-test-macro-name - a FTM name, e.g.
__cpp_constexpr
or__cpp_lib_ratio
- since-rev - C++ revision in the form
C++20
- update-in-rev-list - list of revisions where updates took place, in the form
C++17, C++20
[edit] Examples
-
{{ftml|__cpp_constexpr}}
results in__cpp_constexpr
-
{{ftml|__cpp_constexpr|C++11}}
results in__cpp_constexpr
(since C++11) -
{{ftml|__cpp_lib_format|C++20|C++23}}
results in__cpp_lib_format
(since C++20)(updated in C++23) -
{{ftml|__cpp_lib_format|C++20|C++23, C++26}}
results in__cpp_lib_format
(since C++20)(updated in C++23, C++26)
-
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)}} - inserts number of non-breaking space characters (HTML: ). Without the argument inserts one such space.
{{nbspt|number (optional)}} - same space characters generator as {{nbsp}} but in monospace
(teletype
) font.
{{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>}}
.
{{br}} - behaves similar to <br> HTML tag, except that the wrap occurs only if the string does not fit as one line in an enclosing box. Useful in tables to optionally split long identifiers.
Example. Let the identifier __cpp_lib_allocator_traits_is_always_equal
be tagged as
-
{{tt|__cpp_lib_allocator_}}{{br}}{{tt|traits_is_always_equal}}
.
Then the rendering of the boxes containing it may result in:
__cpp_lib_allocator_ traits_is_always_equal
|
__cpp_lib_allocator_ traits_is_always_equal
|
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. |
[edit] Standard containers classification
This is one of the group of the templates used to categorize containers.
The general form is:
{{cpp/container/TERM|container|if-true|if-false (optional)}}
:
- results in if-true if container is one in given container/adaptor group.
- results in if-false (if present), otherwise.
TERM | Containers/adaptors in the group |
---|---|
if seq |
|
if assoc |
|
if ord |
|
if unord |
|
if uniq |
|
if eq |
|
if set |
|
if map |
|
if ad |
|
if flat |
|
if c++98 |
|
if c++11 |
|
[edit] Examples
{{cpp/container/if set|multiset|Yes|No}}
results in Yes.
{{cpp/container/if seq|multiset|Yes|No}}
results in No.
The above documentation is transcluded from Template:cpp/container/if_assoc/doc. (edit | history) Subpages of this page. |