Namespaces
Variants
Views
Actions

Template:cc multi

From cppreference.com
 
[edit] [{{purge}}] Template 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 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 {{