Content deleted Content added
→Reflection: example from the proposal paper |
Tags: Mobile edit Mobile web edit |
||
(6 intermediate revisions by 4 users not shown) | |||
Line 38:
* <code>alignas</code>
* <code>alignof</code>
* <code>and</code>▼
* <code>and_eq</code>▼
* <code>asm</code>
* <code>auto</code>
* <code>bitand</code>▼
* <code>bitor</code>▼
* <code>bool</code>
* <code>break</code>
Line 53 ⟶ 49:
* <code>char32_t</code>
* <code>class</code>
* <code>compl</code>▼
* <code>concept</code>
* <code>const</code>
Line 90 ⟶ 85:
* <code>new</code>
* <code>noexcept</code>
* <code>not</code>▼
* <code>not_eq</code>▼
* <code>nullptr</code>
* <code>operator</code>
* <code>or</code>▼
* <code>or_eq</code>▼
* <code>private</code>
* <code>protected</code>
Line 128 ⟶ 119:
* <code>wchar_t</code>
* <code>while</code>
* <code>xor</code>▼
* <code>xor_eq</code>▼
{{div col end}}
The keyword [[restrict|<code>restrict</code>]], though present in C, is not standard in C++, though some compilers may support it. The keyword <code>fortran</code>, a conditionally supported keyword in C which denotes linkage for the [[Fortran]] programming language, is conditionally supported in C++.
=== Alternative operator keywords ===
The following words are reserved keywords, but are used as alternative spellings for operators and tokens that use non-ISO646 characters.
{{div col|colwidth=15em}}
▲* <code>and</code>
▲* <code>and_eq</code>
▲* <code>bitand</code>
▲* <code>bitor</code>
▲* <code>compl</code>
▲* <code>not</code>
▲* <code>not_eq</code>
▲* <code>or</code>
▲* <code>or_eq</code>
▲* <code>xor</code>
▲* <code>xor_eq</code>
{{div col end}}
=== Identifiers with special meaning ===
Line 570 ⟶ 575:
class MyObject {
private:
[[no_unique_address]]
int x; public:
[[nodiscard]]
Line 647 ⟶ 653:
=== Annotations ===
Most declarations can have annotations attached, which are just values associated with that declaration. Like [[Java annotation]]s, annotations can be accessed using reflection. Annotations are different from attributes as attributes are primarily a means to communicate information to the compiler, while annotations are a feature of reflection and allow arbitrary constants and metadata to be attached, making them customisable to programs, unlike attributes. This allows for bridging the communication between the library API and the user.
<syntaxhighlight lang="cpp">
using custom::Debug;
Line 669 ⟶ 675:
Creating an annotation to generate a specialisation for <code>std::formatter<T></code> is as follows:
<syntaxhighlight lang="cpp">
template <auto V>
struct Derived { template <auto V> inline constexpr Derived<V> Derive;▼
template <auto V>
inline constexpr struct {} Debug;
Line 693 ⟶ 702:
== See also ==
* [[C++ standard library]]
* [[C syntax]]
* [[Java syntax]]
* [[C Sharp syntax|C# syntax]]
* [[Rust syntax]]
|