Returns: A
vector containing all of the reflections
R
representing each annotation applying to each declaration of
E that precedes either
some point in the evaluation context (
[expr.const]) or
a point immediately following the
class-specifier
of the outermost class for which such a point is in a complete-class context
. For any two reflections
R1 and
R2 in the returned
vector,
if the annotation represented by
R1 precedes the annotation represented by
R2,
then
R1 appears before
R2. If
R1 and
R2 represent annotations from the same translation unit
T,
any element in the returned
vector between
R1 and
R2
represents an annotation from
T. [
Note 1:
The order in which two annotations appear is otherwise unspecified
. —
end note]
[
Example 1:
[[=1]] void f();
[[=2, =3]] void g();
void g [[=4]] ();
static_assert(annotations_of(^^f).size() == 1);
static_assert(annotations_of(^^g).size() == 3);
static_assert([: constant_of(annotations_of(^^g)[0]) :] == 2);
static_assert(extract<int>(annotations_of(^^g)[1]) == 3);
static_assert(extract<int>(annotations_of(^^g)[2]) == 4);
struct Option { bool value; };
struct C {
[[=Option{true}]] int a;
[[=Option{false}]] int b;
};
static_assert(extract<Option>(annotations_of(^^C::a)[0]).value);
static_assert(!extract<Option>(annotations_of(^^C::b)[0]).value);
template<class T>
struct [[=42]] D { };
constexpr std::meta::info a1 = annotations_of(^^D<int>)[0];
constexpr std::meta::info a2 = annotations_of(^^D<char>)[0];
static_assert(a1 != a2);
static_assert(constant_of(a1) == constant_of(a2));
[[=1]] int x, y;
static_assert(annotations_of(^^x)[0] == annotations_of(^^y)[0]);
—
end example]