Files
cppdraft_translate/cppdraft/dcl/attr/annotation.md
2025-10-25 03:02:53 +03:00

2.2 KiB
Raw Permalink Blame History

[dcl.attr.annotation]

9 Declarations [dcl]

9.13 Attributes [dcl.attr]

9.13.12 Annotations [dcl.attr.annotation]

1

#

An annotation may be applied to any declaration of a type, type alias, variable, function, namespace, enumerator,base-specifier, or non-static data member.

2

#

Let E be the expressionstd::meta::reflect_constant(constant-expression).

E shall be a constant expression; the result of E is the underlying constant of the annotation.

3

#

Each annotation produces a unique annotation.

4

#

Substituting into an annotation is not in the immediate context.

[Example 1:

void f(); void g();void g ();f has one annotation and g has five annotations.

These can be queried with metafunctions such as std::meta::annotations_of ([meta.reflection.annotation]).

— end example]

[Example 2: template void f(T t);

void f(int);

void g() { f(0); // OK f('0'); // error, substituting into the annotation results in an invalid expression} — end example]