Namespaces
Variants
Views
Actions

Difference between revisions of "Template:ftm"

From cppreference.com
(Undo revision 153500 by WhyDoesThisexist (talk))
m (Apply {{ftm link}}.)
 
(2 intermediate revisions by one user not shown)
Line 1: Line 1:
<noinclude>{{documentation|Template:ftm/doc}}</noinclude><includeonly>|-
+
<noinclude>{{documentation|Template:ftm/doc}}</noinclude><includeonly><!--
{{#if:{{{rowspan|}}}|{{!}}rowspan{{=}}{{{rowspan|}}}}}{{#ifeq:{{trim|{{{1|}}}}}|-||{{!}}[[cpp/feature_test#{{#ifeq:{{#pos:{{trim|{{{1|}}}}}|__cpp_lib_}}|0|Library|Language}} features|{{tt|{{{1|}}}}}]]}}{{#if:{{{std|}}}|{{#ifeq:{{trim|{{{1|}}}}}|-|{{!}}|{{!!}}}}{{c/core|{{{value|}}}}}{{!!}}{{mark|{{{std|}}}}}}}{{#if:{{{dr|}}}|<br>{{mark|DR}}}}{{#if:{{{2|}}}|{{!!}}{{{2|}}}}}</includeonly>
+
-->|-
 +
{{#if:{{{rowspan|}}}|{{!}}rowspan{{=}}{{{rowspan}}}}}<!--
 +
-->{{#ifeq:{{trim|{{{1|}}}}}|-||{{!}}{{ftm link|{{{1|}}}}}}}<!--
 +
-->{{!!}}{{c/core|{{{value|}}}}}<!--
 +
-->{{!!}}{{#if:{{{std|}}}|{{mark|{{{std|}}}}}}}{{#if:{{{dr|}}}|<br>{{mark|DR{{#ifeq:{{{dr|}}}|yes||{{{dr|}}}}}}}}}<!--
 +
-->{{!!}}{{trim|{{{2|}}}}}</includeonly>

Latest revision as of 10:10, 22 July 2024

[edit] [{{purge}}] Template documentation

Contents

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


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