Operators in C and C++: Difference between revisions

Content deleted Content added
fix typo in represents
m fix common MOS:REFSPACE spacing errors, replaced: {{efn → {{efn (6)
Line 69:
| {{rh}} colspan="2" | Postfix increment
| align="center" | <code>a'''++'''</code>
| {{cpp|1=R K::operator ++(int);}} {{efn|name=dummy-int|The {{cpp|int}} is a dummy parameter to differentiate between prefix and postfix.}}
| {{cpp|1=R operator ++(K& a, int);}} {{efn|name=dummy-int}}
|-
| {{rh}} colspan="2" | Prefix [[Increment and decrement operators|decrement]]
Line 79:
| {{rh}} colspan="2" | Postfix decrement
| align="center" | <code>a'''--'''</code>
| {{cpp|1=R K::operator --(int);}} {{efn|name=dummy-int}}
| {{cpp|1=R operator --(K& a, int);}} {{efn|name=dummy-int}}
|}
 
Line 384:
| {{n/a}}
|-
| {{rh}} colspan="2" | [[type conversion|Conversion]] {{efn|Behaves like const_cast/static_cast/reinterpret_cast. In the last two cases, the <code>auto</code> specifier is replaced with the type of the invented variable x declared with <code>auto x(a);</code> (which is never interpreted as a function declaration) or <code>auto x{a};</code>, respectively.}}<ref>[https://en.cppreference.com/w/cpp/language/explicit_cast Explicit type conversion] in C++</ref>
| style="text-align:center;" | <code>R(a)</code><br><code>R{a}</code><ref name="sinceCXX11" group="lower-alpha" /><br><code>auto(a)</code><ref name="sinceCXX23" group="lower-alpha" /><br><code>auto{a}</code><ref name="sinceCXX23" group="lower-alpha" /> || {{no}} || {{no}}
| {{rh}} colspan="2" {{n/a}}
|-
| {{rh}} colspan="2" | [[static_cast]] conversion {{efn|For user-defined conversions, the return type implicitly and necessarily matches the operator name unless the type is inferred (e.g. {{cpp|1=operator auto()}}, {{cpp|1=operator decltype(auto)()}} etc.).}}
| style="text-align:center;" | <code>'''static_cast'''<R>(a)</code> || {{yes}} || {{no}}
| {{cpp|1=K::operator R();}}<br>{{cpp|1=explicit K::operator R();}}<ref name="sinceCXX11" group="lower-alpha" />