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.

[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

{{tt|text}} - monospace font (<code> html attribute)

{{ttb|text}} - bold monospace font (<code><b> html attributes)

{{small|text}} - small font (<small> html attribute)

{{smalltt|text}} - small monospace font (<small><code> html attributes)

[edit] Syntax highlighting

[edit] [{{purge}}] Documentation

This is one of the templates used for syntax highlighting.

{{c| 1=code| lang=language(optional)}}

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.

{{c/core| 1=code| lang=language(optional)}}

Same as {{c}} just no background is applied. Intended to be used in other templates only.

{{cc| 1=code| lang=language(optional)}}

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.

{{source| 1=code| lang=language(optional)}}

Base template that is intended to highlight large amounts of code. lang is optional; value returned by {{get_lang}} is used by default.

{{eq fun| lang=language|code1|code2(optional)|...|code4(optional)}} - where code1, code2, etc. are code for each version of the described template function. If no code is supplied at all, the template results in {{todo}}. lang is optional; value returned by {{get_lang}} is used by default.

{{example|description(optional)|lang=language(optional)| code=code_to_display| p=true_if_nondeterministic(optional)}}

Base template for 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 can be set to true to indicate this (Possible output is shown instead of just Output).

[edit] Links

[edit] [{{purge}}] Documentation

This is one of templates used to make links.

Absolute links:

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

{{ltf|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. Parentheses indicating function are appended.

{{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. :: is inserted between them. Each of these parts can be overridden by title1 and title2. Link font is teletype.

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.

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

[edit] Annotations

[edit] {{mark}} family of templates

[edit] [{{purge}}] Documentation

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 typedef}} results in (typedef)

{{mark enum}} results in (enum)

{{mark keyword}} results in (keyword)

{{mark language}} results in (language)

Standards

{{mark c++11}} results in (C++11)

{{mark since c++11}} results in (since 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 until c++14}} results in (until C++14)

{{mark c99}} results in (C99)

{{mark since c99}} results in (since C99)

{{mark c11}} results in (C11)

{{mark until c11}} results in (until C11)

{{mark since c11}} results in (since C11)

{{mark since none}} results in (since {std})

{{mark until none}} results in (until {std})

Technical specifications

{{mark since libfund ts}} results in (library fundamentals TS)

{{mark since fs ts}} results in (filesystem 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 macro fun}} results in (function macro)

Classes

{{mark class}} results in (class)

{{mark tclass}} results in (class 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)

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)

[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 in valid to only specific revisions of the standard.

{{rev begin}}

Begins the set of text snippets specific to a specific revision(s) of the standard.

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

{{rev inl|since=since-std(optional)|until=until-std(optional)|text}}

Same as {{rev}}, just is displayed inline. {{rev begin}} and {{rev end}} must not be used.

[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

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