Namespaces
Variants
Actions

User:Mgkrupa

From cppreference.com


Contents

Code

Inline code

Template:c - "intended to highlight code inline."

  • {{c|1=code|lang=language(optional)}}
  • 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};

Blocks of code

Template:source - "intended to highlight large amounts of code."

  • {{source|1=code|lang=language(optional)}}
  • Example: {{source|1= int main() { __builtin_printf("Hello, C++\n"); } }}
    results in
    int main()
    {
        __builtin_printf("Hello, C++\n");
    }


Links

Relative path

Template:rl (Relative path) "link to a page relative to this page" (append t to the end for teletype font)

  • {{rl|page|title (optional)}} - makes a link to a page relative to this page. The link appears in normal font.
    • {{rlt|page|title (optional)}} - teletype font
  • {{rlp|page|title (optional)}} - makes a link to a page relative to the parent page. The link appears in normal font.
    • {{rlpt|page|title (optional)}} - teletype font
  • {{rlp|/|title}} - makes a link to the parent page. The link appears in normal font.
    • {{rlpt|/|title}} - teletype font


Absolute path

"makes a link to a page using absolute path."

{{lt|path|title (optional)}} - normal font - The default title is only the last part of the path.

  • {{ltt|path|title (optional)}} - teletype font version of {{lt}}
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.
Example: {{ltt|cpp/language/switch}} results in the link: switch.
Example: {{ltt|cpp/language/switch|switch(expr)}} results in the link: switch(expr).

Links to functions

{{ltf|path|title (optional)|args=arguments (optional)}} - teletype font

{{ltf}} = {{lt}} for functions
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).

{{l2tf|page|title1 (optional)|title2 (optional)|args=arguments (optional)|suffix=suffix (optional)}} - teletype font - 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().