Namespaces
Variants
Views
Actions

Help:Templates

From cppreference.com

This page describes the templates used in this wiki.

Templates provide means to achieve the following objectives:

  1. Quality. It becomes easy to modify the content and hence to fix errors. Duplicated content needs to be edited only once.
  2. Consistency. Templates make the right way to do things implicit.
  3. 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

[edit] [{{purge}}] Documentation

This is one of the templates used to output special symbols:

{{!}} - outputs |

{{!!}} - outputs ||

{{=}} - outputs =

{{==}} - outputs ==

{{!=}} - outputs |=

{{(!}} - outputs {|

{{!)}} - outputs |}

[edit] Formatting

[edit] [{{purge}}] Documentation

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
{{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 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
{{p|text}} text in a new paragraph <p>text</p>

text

[edit] Syntax highlighting

[edit] [{{purge}}] Documentation

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 [beginend)), 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 1=/2=/3=/4=/5= is necessary if an equal sign = is present somewhere in the corresponding line.


{{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:
{{box|{{co|"C++";}} {{ltt std|cpp/algorithm/swap}}{{tt|''<int>''}}{{c/core|(x, y); /*.*/}}}}
results in "C++"; std::swap<int>(x, y); /*.*/


{{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 to true 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++

[edit] Links

[edit] [{{purge}}] Documentation

[edit] This is one of templates used to make links

[edit] Absolute links

{{lt|path |title (optional)}} - creates a 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.

{{ls|path#section }} - makes a link to a section on a page given by absolute path. The section text is also used as the title. The link appears in normal font.

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. Note that the path can be omitted. In such a case the link to a section inside current page is generated.

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

{{ltt|path |title (optional)}} - creates a 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).

{{lti|path |title (optional)}} - creates a link to a page using absolute path. The default title is only the last part of the path. Link font is teletype in italic.

Example: {{lti|cpp/concepts/boolean-testable}} results in the link: boolean-testable.

{{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. 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).

{{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. Link font is teletype. 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>.

{{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. Link font is teletype, and the template name is in italic. 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>.

{{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. Link font is teletype. 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).

{{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. 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)}} - 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. 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 (i.e. to a sub-page). The link appears in normal font.

{{rlt|page |title (optional)}} - makes a link to a page relative to this page (i.e. to a sub-page). The link appears in teletype font.

{{rli|page |title (optional)}} - makes a link to a page relative to this page (i.e. to a sub-page). The link appears in teletype font in italic.

{{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.

{{rlps|page#section }} - makes a link to a section on a page relative to the parent page. The link appears in normal font. The title of the generated link is the section name.

{{rlpsd|page#Section }} - makes a link to a section on a page relative to the parent page. The link appears in normal font. The title of the generated link is the section name with the first letter de-capitalized.

{{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.

{{rlpi|page |title (optional)}} - makes a link to a page relative to the parent page. The link appears in teletype font in italic.

{{rlpi|/ |title }} - makes a link to the parent page. The link appears in teletype font in italic.

{{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.

Example: {{ttt|this_page}} results in this_page.

[edit] Decorated links

{{attr|attribute |title (optional)|additional title (optional)|lang=language (optional)}}

Used to create a link to C/C++ language attribute specifier description. Parameters:
  • 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")]].

[edit] Links and information of standardization

[edit] [{{purge}}] Documentation

[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 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).
  • 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 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

{{stddoc latest draft|link title (optional)}}

Generate a link to the latest draft of the next C/C++ standard.
  • Presently, {{stddoc latest draft}} results in: N4971
  • 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 (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|1=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 23

doc document number {{stdinfo latest draft|doc}} results in n4971

{{stdinfo latest draft|doc|lang=c}} results in n3220

date document date {{stdinfo latest draft|date}} results in 2023-12-18

{{stdinfo latest draft|date|lang=c}} results in 2024-02-22

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. Results in: n4971 for C and n4971 for C++.

{{stdinfo latest draft docdate|lang=lang (optional)}}

The document date of the latest draft of the C/C++ standard. Results in 2023-12-18 for C and 2023-12-18 for C++.

{{stdinfo next version number|lang=lang (optional)}}

The version number of the next C/C++ standard. Results in 26 for C and 26 for C++.

{{stdinfo next version}}

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

{{stdinfo current version}}

The version of the current C/C++ standard (with the prefix C or C++). Results in: C++20

[edit] Current language

Returns the programming language to use for a page by default. The output value depends on the title of the page this template is included in.

{{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++".

[edit] Annotations

[edit] {{mark}} family of templates

[edit] [{{purge}}] Documentation

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 implicit}} (implicitly declared)
{{mark concept}} (concept)
{{mark expos}} (exposition only*)
{{mark expos concept}} (exposition-only concept*)
{{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 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 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 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 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 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 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 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 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 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 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)
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 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)

[edit] {{cmark}} family of templates

[edit] [{{purge}}] Documentation

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]

[edit] Versioning

[edit] [{{purge}}] Documentation

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 }}

A combined {{rev begin}}/{{rev}}/{{rev end}}, for when only a single {{rev}} is needed.

{{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 is untilX-1 and default for untilX is sinceX+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.

[edit] Feature-test macros rendering

[edit] [{{purge}}] Documentation

[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 (optional)}}

Example:

{{feature test macro|__cpp_lib_ranges_iota|{{tt|std::ranges::iota}}|value=202202L|std=C++23}}
results in
Feature-test macro Value Std Feature
__cpp_lib_ranges_iota 202202L (C++23) std::ranges::iota

Example:

{{feature test macro|__cpp_inheriting_constructors|Rewording|value=201511L|std=C++11|dr=yes}}
results in
Feature-test macro Value Std Feature
__cpp_inheriting_constructors 201511L (C++11)
(DR)
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 <version> 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 (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 of R 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, adds a (DR) 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}}
{{ftm|std=C++23|value=202202L|-|comment #6}}
{{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) comment #5
202202L (C++23) 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 form

{{ftml|feature-test-macro-name |since-rev (optional)|updated-in-rev-list (optional)}}

Generates a simple link with revision mark(s), designed to be used in pages such as Macro Symbol Index.

  • feature-test-macro-name - macro 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|C++11}} 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)

[edit] Navigation bars

[edit] [{{purge}}] Documentation
{{navbar
| style =

| heading1 = 
| content1 = 

| heading2 = 
| content2 = 

| heading3 = 
| content3 = 

...

| heading8 = 
| content8 = 

}}

[edit] Miscellaneous

[edit] Spaces

[edit] [{{purge}}] Documentation

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: &nbsp;). 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

[edit] Headers

[edit] [{{purge}}] Documentation

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>
On C pages {{header|stdio.h}} results in <stdio.h>

[edit] Utility templates (intended to be used only by other templates)

[edit] Cast requirements

[edit] [{{purge}}] Documentation

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.

[edit] Standard containers classification

[edit] [{{purge}}] Documentation

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
  • array, vector, deque, list, forward_list
if assoc
  • set, multiset, map, multimap
  • unordered_set, unordered_multiset, unordered_map, unordered_multimap
  • flat_set, flat_multiset, flat_map, flat_multimap
if ord
  • set, multiset, map, multimap
  • flat_set, flat_multiset, flat_map, flat_multimap
if unord
  • unordered_set, unordered_multiset, unordered_map, unordered_multimap
if uniq
  • set, map
  • unordered_set, unordered_map
  • flat_set, flat_map
if eq
  • multiset, multimap
  • unordered_multiset, unordered_multimap
  • flat_multiset, flat_multimap
if set
  • set, multiset
  • unordered_set, unordered_multiset
  • flat_set, flat_multiset
if map
  • map, multimap
  • unordered_map, unordered_multimap
  • flat_map, flat_multimap
if ad
  • stack, queue, priority_queue
  • flat_set, flat_multiset, flat_map, flat_multimap
if flat
  • flat_set, flat_multiset, flat_map, flat_multimap
if c++98
  • vector, list, set, multiset, map, multimap
  • stack, queue, priority_queue
if c++11
  • array, forward_list
  • unordered_set, unordered_multiset, unordered_map, unordered_multimap
  • span
  • flat_set, flat_multiset, flat_map, flat_multimap

[edit] Examples

{{cpp/container/if set|multiset|Yes|No}} results in Yes.

{{cpp/container/if seq|multiset|Yes|No}} results in No.