# Static reflection

> C++26 lets a program ask the compiler about its own declarations at compile time. The `^^` operator turns a construct into a `std::meta::info` value, `<meta>` functions query and transform those values, and a splice `[: r :]` turns a value back into code.

- **Source:** C++ Atlas (https://cppatlas.com/topics/reflection)
- **Track:** C++26
- **Estimated reading time:** 15 minutes
- **ISO C++ clauses:** [expr.reflect] (https://eel.is/c++draft/expr.reflect), [basic.splice] (https://eel.is/c++draft/basic.splice), [basic.types.general] (https://eel.is/c++draft/basic.types.general), [expr.const.imm] (https://eel.is/c++draft/expr.const.imm), [expr.const.reflect] (https://eel.is/c++draft/expr.const.reflect), [stmt.expand] (https://eel.is/c++draft/stmt.expand), [dcl.attr.annotation] (https://eel.is/c++draft/dcl.attr.annotation), [meta.syn] (https://eel.is/c++draft/meta.syn), [meta.reflection.access.context] (https://eel.is/c++draft/meta.reflection.access.context), [meta.reflection.member.queries] (https://eel.is/c++draft/meta.reflection.member.queries), [meta.reflection.define.aggregate] (https://eel.is/c++draft/meta.reflection.define.aggregate)
- **cppreference links:** [Reflection TS (the earlier, type-based design)](https://en.cppreference.com/w/cpp/experimental/reflect), [consteval specifier](https://en.cppreference.com/w/cpp/language/consteval), [Constant expressions](https://en.cppreference.com/w/cpp/language/constant_expression)
- **Prerequisites:** constant-expressions, type-traits-and-metaprogramming, template-instantiation-and-specialization, constexpr-in-cpp26

## The one idea

Reflection gives you a value that stands for a piece of your program: a type, a variable, a data member, an enumerator, a function, a namespace. You can store that value, pass it to functions, put it in a `std::vector`, and compare it. When you are done computing, you **splice** it back, and the compiler treats the splice as if you had written the name of the thing it stands for.

All of this happens during constant evaluation. A reflection value never exists at run time, so reflection costs nothing at run time and cannot leak compiler internals into a binary.

This is C++26. The core paper is P2996R13, adopted in June 2025, together with P3394R4 (annotations), P3293R3 (splicing base class subobjects), P3096R12 (reflecting function parameters), P3491R3 (`define_static_array` and friends), P3560R2 (errors as exceptions), P3289R1 (`consteval` blocks) and P1306R5 (expansion statements). Everything here follows N5050, the final C++26 draft sent to the international ballot. That ballot closed in October 2026 and was reported as not approved, so check the status before you quote this as published ISO C++. GCC 16 lists every one of these papers except P3289 as implemented, and `consteval` blocks work as well. Reflection itself needs `-std=c++26 -freflection`. Expansion statements work with `-std=c++26` alone. Clang 21 has no reflection support. Every example below was compiled with GCC 16.2.

> **Mental model.** `^^` lifts a construct into a value of type `std::meta::info`. Ordinary `consteval` code computes with those values. `[: :]` lowers a value back into a construct. Between the lift and the lower, reflection is just constant-expression programming.

## Lifting and lowering

The reflection operator accepts `^^::` for the global namespace, a namespace or template name, a type-id, or an id-expression naming a variable, function, enumerator, structured binding, or non-static data member. Its result is a prvalue of type `std::meta::info`, a scalar type whose values can be compared with `==` and `!=` but not ordered. A value-initialized `info` holds the unique **null reflection**.

```cpp
#include <meta>

constexpr std::meta::info t = ^^int;     // a reflection of the type int
typename [:t:] answer = 42;              // splice it back: declares an int

struct Point { int x; int y; };
constexpr std::meta::info ry = ^^Point::y;          // reflects the data member y
int read_y(const Point& p) { return p.[:ry:]; }     // member access through a splice

static_assert(std::meta::is_type(t));
static_assert(std::meta::identifier_of(ry) == "y");
static_assert(std::meta::type_of(ry) == ^^int);
static_assert(^^Point::x != ^^Point::y);            // reflections compare by identity
```

A splice `[: r :]` requires `r` to be a constant expression. Where the grammar cannot tell what kind of thing the splice produces, you disambiguate as you do with dependent names: write `typename [:r:]` for a type and `template [:r:]` for a template. `obj.[:m:]` accesses a member, and `[:r:]` alone is an expression when `r` reflects a variable, function, or enumerator.

Reflections keep aliases apart. With `using Int = int;`, `^^Int` reflects the type alias and is not equal to `^^int`. `std::meta::dealias(^^Int)` gives `^^int`.

> **Pitfall.** `^^` takes the longest token sequence that forms a type-id. So `r == ^^int && ok` parses as `r == ^^(int&&) ok` and does not compile. The draft's own example shows this, and also `^^int & true`. Write `(^^int) && ok`.

## Why it is compile-time only

N5050 introduces **consteval-only types** in [basic.types.general]. `std::meta::info` is one, and so is any pointer, reference, array, or class that contains one, including `std::vector<std::meta::info>`. Every object of such a type must be a `constexpr` variable, a template parameter object, or an object whose lifetime begins and ends inside one constant evaluation. A function whose type mentions a consteval-only type must be an immediate function.

```cpp
#include <meta>

consteval std::size_t field_count(std::meta::info type) {
  return std::meta::nonstatic_data_members_of(
      type, std::meta::access_context::unchecked()).size();
}

struct P { int a; double b; };
static_assert(field_count(^^P) == 2);

int main() {
  // std::meta::info bad = ^^P;          // error: a run-time object of consteval-only type
  constexpr std::meta::info r = ^^P;     // OK: a constexpr variable
  return field_count(r) == 2 ? 0 : 1;    // OK: the call is folded to a constant
}
```

A plain `constexpr` function with an `info` parameter is ill-formed, because it is not immediate. A `constexpr` function *template*, or a lambda, escalates to an immediate function automatically when it touches a reflection.

> **Standardese.** [expr.const.imm] defines an immediate function as one declared `consteval`, or an immediate-escalating function whose type is consteval-only or whose body uses an immediate-escalating expression. Only lambdas, defaulted special members, and specializations of `constexpr` templates are immediate-escalating. That is why `constexpr bool f(std::meta::info)` is an error while `template<class T> constexpr bool f(T)` is fine.

## Querying with `<meta>`

`<meta>` declares more than two hundred `consteval` functions in `std::meta`. They fall into a few families:

- **names**: `identifier_of`, `has_identifier`, `display_string_of`, `source_location_of`;
- **queries**: `type_of`, `parent_of`, `is_public`, `is_static_member`, `is_noexcept`, `has_default_member_initializer`, and many more;
- **members**: `members_of`, `bases_of`, `nonstatic_data_members_of`, `static_data_members_of`, `enumerators_of`, `parameters_of`;
- **layout**: `offset_of`, `size_of`, `alignment_of`, `bit_size_of`;
- **templates**: `template_of`, `template_arguments_of`, `can_substitute`, `substitute`;
- **values**: `reflect_constant`, `reflect_object`, `extract`, `constant_of`;
- **type traits**: an `info`-based twin for every standard trait, such as `is_class_type`, `remove_cvref`, and `is_constructible_type`.

When a function cannot produce a meaningful result, it throws `std::meta::exception` (P3560). If the exception escapes a constant evaluation, the expression is not constant and the program is ill-formed. Inside your own `consteval` code you can catch it.

```cpp
#include <meta>
#include <vector>

constexpr std::meta::info vi = std::meta::substitute(^^std::vector, {^^int});
static_assert(vi == ^^std::vector<int>);
typename [:vi:] numbers{1, 2, 3};        // a std::vector<int>

constexpr std::meta::info c = std::meta::reflect_constant(42);
static_assert(std::meta::extract<int>(c) == 42);
static_assert(std::meta::type_of(c) == ^^int);

consteval bool has_name(std::meta::info r) {
  try {
    (void)std::meta::identifier_of(r);
    return true;
  } catch (const std::meta::exception&) {
    return false;                        // identifier_of throws for unnamed constructs
  }
}
static_assert(has_name(^^numbers));
static_assert(!has_name(^^int));
```

`int` has no identifier in this sense: for a type, `has_identifier` is true only for an unqualified class or enumeration type without template arguments, or one with a typedef name for linkage purposes. Use `display_string_of` when you just want something printable. Its text is implementation-defined.

### Access is an explicit argument

Every member query takes a `std::meta::access_context`. `access_context::current()` checks access as if from the point where you wrote the call. `unprivileged()` checks from the global namespace, and `unchecked()` ignores access entirely. A reflection library cannot quietly read private members. The caller has to opt in, and a code reviewer can see where they did.

## From metadata back to code

Iterating over members needs a loop whose body is instantiated once per element, because each member has a different type. That loop is the **expansion statement**, `template for`. An enumerating expansion statement walks a braced list of expressions. A destructuring expansion statement walks anything that structured bindings accept, such as a tuple or an aggregate. An iterating expansion statement walks a range whose size is a constant. `break` and `continue` work as in a normal loop.

A `std::vector<std::meta::info>` cannot outlive the constant evaluation that created it, so it cannot serve as a `constexpr` range for `template for`. `std::define_static_array` copies the elements into a static array and returns a `span` over it, which can.

```cpp
#include <meta>
#include <string_view>
#include <cstdio>

template <class E>
  requires std::is_enum_v<E>
constexpr std::string_view enum_name(E value) {
  template for (constexpr std::meta::info e :
                std::define_static_array(std::meta::enumerators_of(^^E))) {
    if (value == [:e:]) return std::meta::identifier_of(e);
  }
  return "<unnamed>";
}

enum class Color { red, green, blue };

int main() {
  Color c = Color::blue;                 // a run-time value
  std::puts(enum_name(c).data());        // prints blue
  static_assert(enum_name(Color::red) == "red");
}
```

`enum_name` takes a run-time value, yet it is still a `constexpr` function. The reflections are used only inside the constant initializer of the loop variable `e`, and what survives into run time is a chain of comparisons against enumerator constants and pointers to static strings. The returned `string_view` is null-terminated, because the standard guarantees that every name string from `std::meta` is.

The same pattern prints a struct generically. Because the context is `current()` inside a function template, private members of the argument are skipped.

```cpp
#include <meta>
#include <iostream>

template <class T>
void print_fields(const T& obj) {
  constexpr auto ctx = std::meta::access_context::current();
  template for (constexpr auto m :
                std::define_static_array(std::meta::nonstatic_data_members_of(^^T, ctx))) {
    std::cout << std::meta::identifier_of(m) << " = " << obj.[:m:] << '\n';
  }
}

struct Order {
  int id = 7;
  double price = 9.5;
private:
  int secret = 42;                       // not visible from print_fields
};

int main() { print_fields(Order{}); }    // prints id = 7, then price = 9.5
```

### Annotations

P3394 adds **annotations**, written `[[=expr]]`, where `expr` is any constant expression of structural type. Unlike attributes, the compiler does not interpret them. They exist so that reflection code can read them. Each annotation is a distinct entity, so `[[=1, =1]]` attaches two annotations. Annotations accumulate across redeclarations, and `annotations_of` returns them all.

```cpp
#include <meta>
#include <iostream>

struct Skip {};
struct Width { int chars; };

struct Config {
  [[=Width{6}]] int port = 8080;
  [[=Skip{}]] int cache_handle = 0;
  int max_connections = 64;
};

template <class T>
void dump(const T& obj) {
  constexpr auto ctx = std::meta::access_context::current();
  template for (constexpr auto m :
                std::define_static_array(std::meta::nonstatic_data_members_of(^^T, ctx))) {
    if constexpr (std::meta::annotations_of_with_type(m, ^^Skip).empty()) {
      constexpr auto w = std::define_static_array(
          std::meta::annotations_of_with_type(m, ^^Width));
      std::cout << std::meta::identifier_of(m) << ": ";
      if constexpr (!w.empty())
        std::cout.width(std::meta::extract<Width>(w[0]).chars);
      std::cout << obj.[:m:] << '\n';
    }
  }
}

int main() { dump(Config{}); }  // prints port, padded to 6 columns, then max_connections
```

The annotation value must be usable as a template argument. `Rename{"name"}` with a `const char*` member fails, because a pointer to a string literal is not a permitted constant. Wrap the text with `std::define_static_string` instead.

## Generating types with `define_aggregate`

C++26 reflection can create one kind of declaration: the definition of a previously incomplete class as a plain aggregate. `data_member_spec` describes a member (type, name, alignment, bit-width, `no_unique_address`, annotations). `define_aggregate` takes an incomplete class and a list of member descriptions, and produces an **injected declaration** that completes the class.

An injected declaration is a side effect on the program. It may come only from the evaluation of a `consteval` block, a declaration of the form `consteval { ... }`. Calling `define_aggregate` from a `constexpr` variable's initializer is not a constant expression. A `consteval` block also may not sit inside the class it defines.

```cpp
#include <meta>
#include <array>
#include <vector>
#include <cstdio>

template <class T, std::size_t N>
struct SoA {
  struct Columns;
  consteval {
    std::vector<std::meta::info> specs;
    for (std::meta::info m : std::meta::nonstatic_data_members_of(
             ^^T, std::meta::access_context::unchecked())) {
      std::meta::info column = std::meta::substitute(
          ^^std::array, {std::meta::type_of(m), std::meta::reflect_constant(N)});
      specs.push_back(std::meta::data_member_spec(
          column, {.name = std::meta::identifier_of(m)}));
    }
    std::meta::define_aggregate(^^Columns, specs);
  }
  Columns data;
};

struct Particle { float x; float y; int id; };

int main() {
  SoA<Particle, 1024> ps{};
  ps.data.x[3] = 1.5f;                   // x is std::array<float, 1024>
  ps.data.id[3] = 9;                     // id is std::array<int, 1024>
  std::printf("%zu\n", ps.data.y.size()); // prints 1024
}
```

That is a struct-of-arrays transform in about fifteen lines, with member names preserved. Inside the `consteval` block, an ordinary `for` loop over a `std::vector` is fine, because the whole block is one constant evaluation.

## Limits worth knowing

- C++26 reflection reads declarations, but the only code it writes is aggregate definitions. It cannot inject functions, statements, or arbitrary members. Token-sequence injection is proposed for a later standard.
- `members_of` sees only declarations that precede the point of evaluation. Inside a class's own definition, the class is incomplete, and asking for its members throws.
- Function bodies and expressions cannot be reflected. Only declarations and the entities they introduce can.
- Because `members_of` depends on which declarations precede the evaluation, the same query can answer differently in two translation units. An inline function or template that depends on the answer then violates the ODR.
- `display_string_of` and `source_location_of` are only loosely specified. Do not compare their output across compilers.

## What to remember

- `^^x` gives a `std::meta::info`. `[: r :]` turns it back into code, with `typename` or `template` to disambiguate.
- `info` is a consteval-only type, so every object of it is `constexpr` or lives inside one constant evaluation. A non-template `constexpr` function cannot take one.
- `<meta>` functions are `consteval` and report failure by throwing `std::meta::exception`. An uncaught exception makes the expression non-constant.
- Member queries take an `access_context`: `current()`, `unprivileged()`, or the explicit escape hatch `unchecked()`.
- `template for` instantiates its body once per element. Use `std::define_static_array` to turn a `vector<info>` into something it can walk.
- `define_aggregate` completes an incomplete class, and only from inside a `consteval { }` block.
- `[[=v]]` annotations are user data for reflection. Every annotation counts separately.
- GCC 16 implements all of it behind `-std=c++26 -freflection`. Clang 21 does not implement it yet.

## Concept Map Outline

- **Static reflection (C++26):** P2996 and companions: compile-time values that represent program constructs, queried with <meta> and spliced back into code.
  - **Lift and lower:** ^^ turns a construct into a std::meta::info; [: r :] turns a constant info back into code.
    - **^^ operator:** Accepts ::, namespaces, templates, type-ids and id-expressions; parses the longest possible type-id.
    - **Splicers:** [:r:] needs a constant expression; add typename or template to disambiguate, obj.[:m:] for members.
    - **Aliases stay distinct:** ^^Int != ^^int for using Int = int; dealias gives the underlying type.
  - **Compile time only:** Reflection values never exist at run time, so they cost nothing there.
    - **Consteval-only types:** info and anything containing it may only be constexpr, a template parameter object, or live inside one evaluation.
    - **Immediate functions:** A function with an info in its type must be consteval or immediate-escalating, such as a constexpr template.
    - **meta::exception:** Metafunctions throw on bad input; an uncaught throw makes the expression non-constant (P3560).
  - **Querying <meta>:** Over two hundred consteval functions in std::meta.
    - **Names:** identifier_of throws without has_identifier; display_string_of text is implementation-defined.
    - **Members:** members_of, nonstatic_data_members_of, enumerators_of, bases_of return vector<info> in declaration order.
    - **access_context:** current(), unprivileged() or unchecked(): private members appear only if the caller opts in.
    - **Values and templates:** reflect_constant and extract convert values; substitute builds template specializations.
  - **Writing code:** Turning computed reflections into declarations and statements.
    - **template for:** P1306 expansion statement: body instantiated per element; break and continue are allowed.
    - **define_static_array:** Copies a vector<info> into static storage so template for can iterate it.
    - **define_aggregate:** Completes an incomplete class from data_member_spec descriptions, only inside a consteval block.
    - **consteval blocks:** consteval { ... } runs code at namespace or class scope; the only place injected declarations may come from.
  - **Annotations:** P3394: [[=expr]] attaches structural constants that only reflection reads.
    - **Every one counts:** [[=1, =1]] gives two annotations; redeclarations add more to the same entity.
    - **Reading them:** annotations_of and annotations_of_with_type, then extract<T> to get the value.
  - **Limits and support:** What C++26 reflection does not do, and where it compiles.
    - **No general injection:** Only aggregate definitions can be generated; no functions, statements or expression reflection.
    - **Order matters:** Queries see only preceding declarations, so results can differ by translation unit.
    - **GCC 16:** Implemented behind -std=c++26 -freflection; expansion statements need only -std=c++26. Clang 21 lacks it.

## Standardese Quiz Questions

### Question 1 [warmup] ([basic.types.general], [expr.const.imm])

Under the C++26 draft, what happens with this program?

```cpp
#include <meta>

int main() {
  std::meta::info r = ^^int;
  (void)r;
}
```

A. It is ill-formed: `std::meta::info` is a consteval-only type, so `r` must be a `constexpr` variable
B. It compiles and `r` holds a reflection of `int` at run time
C. It compiles, but `r` holds the null reflection at run time
D. Undefined behavior: reflections are only valid during compilation

**Answer (A):** It is ill-formed: `std::meta::info` is a consteval-only type, so `r` must be a `constexpr` variable

**Why:** [basic.types.general] makes `std::meta::info` a consteval-only type. Every object of such a type must belong to a `constexpr` variable, be a template parameter object, or live entirely within one constant evaluation. `r` is an ordinary automatic variable in `main`, so the program is ill-formed, and GCC 16 rejects it. Writing `constexpr std::meta::info r = ^^int;` fixes it. There is no run-time representation of a reflection at all, which is why the "holds a reflection at run time" answer is wrong.

### Question 2 [warmup] ([stmt.expand], [stmt.cont])

What does this C++26 program print?

```cpp
#include <cstdio>
#include <tuple>
#include <type_traits>

int main() {
  template for (auto x : std::tuple{1, 2.5, 'c'}) {
    if constexpr (std::is_same_v<decltype(x), double>) continue;
    std::printf("%d ", static_cast<int>(x));
  }
  std::puts("");
}
```

A. `1 2 99`
B. `1 99`
C. Nothing; it is ill-formed because `continue` cannot appear in an expansion statement
D. Nothing; it is ill-formed because `x` would need a single type for all elements

**Answer (B):** `1 99`

**Why:** `std::tuple` has no `begin` or `end`, so this is a destructuring expansion statement. The body is instantiated once per element, with `x` of type `int`, then `double`, then `char`. In the `double` copy the `if constexpr` branch is taken, and `continue` skips to the next instantiation, which [stmt.cont] allows inside an expansion statement. The output is `1 99 `, with 99 the value of `'c'`. The "single type" answer describes an ordinary range-for, which is exactly what `template for` exists to avoid.

### Question 3 [warmup] ([meta.reflection.access.context], [meta.reflection.member.queries], [meta.reflection.access.queries])

What does this program print? Compile it with `-std=c++26 -freflection` on GCC 16.

```cpp
#include <meta>
#include <cstdio>

struct S {
  int a;
private:
  int b;
public:
  int c;
};

int main() {
  constexpr auto n = std::meta::nonstatic_data_members_of(
      ^^S, std::meta::access_context::current()).size();
  constexpr auto m = std::meta::nonstatic_data_members_of(
      ^^S, std::meta::access_context::unchecked()).size();
  std::printf("%zu %zu\n", n, m);
}
```

A. `3 3`
B. `2 2`
C. `2 3`
D. Nothing; reading private members through reflection is ill-formed

**Answer (C):** `2 3`

**Why:** Member queries return only the members that are accessible from the given `access_context`. `current()` checks access from `main`, which cannot see the private `b`, so only `a` and `c` are returned. `unchecked()` skips access checking entirely, so all three members are returned. Reflection does not forbid seeing private members, but it makes the caller ask for that explicitly, which is why `3 3` is wrong.

### Question 4 [tricky] ([meta.reflection.names], [meta.reflection.exception], [expr.const])

Under the C++26 draft, what is the result of this declaration?

```cpp
#include <meta>

constexpr auto s = std::meta::identifier_of(^^int);
```

A. `s` is a `std::string_view` equal to `"int"`
B. `s` is an empty `std::string_view`
C. The text of `s` is implementation-defined
D. It is ill-formed: `identifier_of` throws `std::meta::exception`, so the initializer is not a constant expression

**Answer (D):** It is ill-formed: `identifier_of` throws `std::meta::exception`, so the initializer is not a constant expression

**Why:** `identifier_of(r)` throws `std::meta::exception` unless `has_identifier(r)` is true. For a type, `has_identifier` is true only for an unqualified class or enumeration type without template arguments, or a type with a typedef name for linkage purposes. `int` is a keyword, not an identifier, so the call throws, the exception escapes the constant evaluation, and the `constexpr` initializer is ill-formed. The implementation-defined answer describes `display_string_of`, which is the function to use for printable names.

### Question 5 [tricky] ([expr.reflect], [meta.reflection.queries])

Under the C++26 draft, what happens with this code?

```cpp
#include <meta>

using Int = int;
constexpr std::meta::info r = ^^Int;
static_assert(r != ^^int && std::meta::is_type_alias(r));
```

A. It is ill-formed: `^^int &&` is parsed as a reflection of the type `int&&`
B. It compiles: `^^Int` reflects the alias, which is a different reflection from `^^int`
C. The `static_assert` fails, because `^^Int` and `^^int` are equal
D. It is ill-formed: a type alias cannot be the operand of `^^`

**Answer (A):** It is ill-formed: `^^int &&` is parsed as a reflection of the type `int&&`

**Why:** [expr.reflect] parses a reflect-expression as the longest token sequence that could form one. `^^int &&` is a valid reflect-expression of the type-id `int&&`, so the condition becomes `r != ^^int&& std::meta::is_type_alias(r)`, which is a syntax error. Parenthesizing as `(r != ^^int) && ...` makes it compile. The tempting "It compiles" answer has the right semantics: `^^Int` does represent the alias and compares unequal to `^^int`, and `dealias(^^Int) == ^^int`.

### Question 6 [tricky] ([expr.const], [expr.const.reflect], [meta.reflection.define.aggregate], [dcl.pre])

Under the C++26 draft, is this translation unit well-formed?

```cpp
#include <meta>

struct S;
constexpr auto r = std::meta::define_aggregate(^^S, {
    std::meta::data_member_spec(^^int, {.name = "x"})});
```

A. Yes: `S` becomes an aggregate with one `int` member `x`
B. Yes, but `S` remains incomplete until the end of the translation unit
C. No: `data_member_spec` requires the name as a `std::u8string`
D. No: `define_aggregate` may produce its injected declaration only while evaluating a `consteval` block

**Answer (D):** No: `define_aggregate` may produce its injected declaration only while evaluating a `consteval` block

**Why:** An expression that would produce an injected declaration is not a core constant expression unless it is the expression of a `consteval` block. So the initializer of `r` is not constant, and the declaration is ill-formed. Writing `consteval { std::meta::define_aggregate(^^S, {...}); }` at namespace scope works. The name may be any ordinary or UTF-8 string, so the `u8string` option is wrong. GCC 16 reports "define_aggregate not evaluated from consteval block".

### Question 7 [standardese] ([basic.types.general], [expr.const.imm])

Under the C++26 draft, which of these declarations is ill-formed?

```cpp
#include <meta>

consteval bool a(std::meta::info r) { return r == ^^int; }

constexpr bool b(std::meta::info r) { return r == ^^int; }

template <class T>
constexpr bool c(T r) { return r == ^^int; }

constexpr auto d = [](std::meta::info r) { return r == ^^int; };
```

A. `a`
B. `b`
C. `c`
D. `d`

**Answer (B):** `b`

**Why:** A function whose type mentions a consteval-only type must be an immediate function. `a` is declared `consteval`. A specialization of the `constexpr` template `c` and the lambda's call operator in `d` are immediate-escalating, so they become immediate functions automatically. `b` is a plain non-template `constexpr` function, which is never immediate-escalating, so it is ill-formed. GCC 16 says "function of consteval-only type must be declared consteval".

### Question 8 [standardese] ([dcl.attr.annotation], [meta.reflection.annotation])

Under the C++26 draft, what does this program print?

```cpp
#include <meta>
#include <cstdio>

[[=1, =2, =1]] void g();
void g [[=3]] ();

int main() {
  constexpr auto n = std::meta::annotations_of(^^g).size();
  std::printf("%zu\n", n);
}
```

A. `2`
B. `3`
C. `4`
D. Nothing; it is ill-formed because `g` is declared twice with different annotations

**Answer (C):** `4`

**Why:** Each annotation, and each instantiation of one, produces a unique annotation, so the repeated `=1` counts twice. For a function, `annotations_of` collects the annotations from every reachable declaration, so the redeclaration adds `=3`. That makes four. The answer `2` assumes annotations deduplicate by value like a set, and `3` forgets one of the two sources. The draft's own example in [dcl.attr.annotation] makes the same point with five annotations.
