P3385R7 — Attributes reflection
(16 items)
EWG, LEWG
This paper proposes extending C++ reflection to support attributes by introducing a reflect-expression of the form ^^[[attribute]] and new metafunctions including attributes_of, has_attribute, and is_attribute in the header. It enables generic code to introspect attributes appertaining to entities, compare attribute reflections for equality, and use attribute reflections to attach attributes to synthesized data members via define_aggregate. The proposal scopes support to standard attributes with simple argument clauses and optionally vendor-specific attributes, while leaving unsupported or unknown attributes ill-formed to reflect.
- Section 4.2.4, code block cb12, first line — The == comparison is placed inside the identifier_of(...) call; the closing parenthesis for identifier_of should appear immediately after the reflected attribute, not after the string literal. [1]
- Section 4.2.4, code block cb12, second line — Same misparenthesization as the first line: == is inside the identifier_of() call. [2]
- Section 4.2.1, paragraph after cb5/cb6 — attribute_of (without trailing s) is not declared anywhere; the function is named attributes_of throughout the paper and synopsis. [3]
- Section 5.2, under [meta.reflection.names] — The baseline text shows string_view as the return type of u8identifier_of, but the working draft specifies u8string_view. [4]
- Section 5.1, proposed paragraph (11.3) under [expr.reflect] — "non described" is ungrammatical; should be "not described." [5]
- Section 5.1, proposed paragraph (11.1) under [expr.reflect] — "for attribute described" is missing the article "an" before "attribute." [6]
- Section 5.1, proposed paragraph 9+ under [dcl.attr.grammar] — "their attribute-token are identical" has number disagreement; either pluralize attribute-tokens or use a singular verb. [7]
- Section 4.2.1, paragraph after cb5/cb6 — "attribute_of return" uses a bare verb with a third-person singular subject; should be "returns." [8]
- Section 3.2, paragraph after the numbered list — "Diagnostic ... are" has number disagreement; singular subject requires "is" or the subject should be "Diagnostics." [9]
- Section 2, first paragraph — "there is new attributes" — subject-verb disagreement; should be "there are." [10]
- Section 3.2, second bullet — Double opening parenthesis "((" and missing period after "e.g" produce malformed text. [11]
- Section 2.1, paragraph after cb2 — "no_unique_adress" is missing a d; the standard attribute is no_unique_address. [12]
- Section 3.2, paragraph after the numbered list — "cicrumstances" is misspelled; should be "circumstances." [13]
References — Anthropic Citations API
[1]
"Here we have 2 attributes showing up in `alignas` and `[[no_unique_adress]]`."
"Here we have 2 attributes showing up in `alignas` and `[[no_unique_adress]]`."
[2]
"there is new attributes being added to the language somewhat regularly."
"there is new attributes being added to the language somewhat regularly."
[3]
"Standard attributes with `conditional-expression` argument are **unsupported** ((e.g, `[[assume]]`)."
"Standard attributes with `conditional-expression` argument are **unsupported** ((e.g, `[[assume]]`)."
[4]
chars 43143–44958
"The current practice around creating reflection of problematic constructs (such as
"The current practice around creating reflection of problematic constructs (such as
using-declarator)
is to be..."
[4]
chars 43143–44958
"The current practice around creating reflection of problematic constructs (such as
"The current practice around creating reflection of problematic constructs (such as
using-declarator)
is to be..."
[5]
chars 43143–44958
"The current practice around creating reflection of problematic constructs (such as
"The current practice around creating reflection of problematic constructs (such as
using-declarator)
is to be..."
[5]
chars 43143–44958
"The current practice around creating reflection of problematic constructs (such as
"The current practice around creating reflection of problematic constructs (such as
using-declarator)
is to be..."
[6]
"In the case where an entity is legally redeclared with different attribute arguments, `attribute_of` return one of those."
"In the case where an entity is legally redeclared with different attribute arguments, `attribute_of` return one of those."
[7]
"In the case where an entity is legally redeclared with different attribute arguments, `attribute_of` return one of those."
"In the case where an entity is legally redeclared with different attribute arguments, `attribute_of` return one of those."
[8]
"static_assert(identifier_of(^^[[clang::warn_unused_result("message")]] == "clang::warn_unused_result")); // true"
"static_assert(identifier_of(^^[[clang::warn_unused_result("message")]] == "clang::warn_unused_result")); // true"
[9]
"static_assert(identifier_of(^^[[nodiscard("message")]] == "nodiscard")); // true"
"static_assert(identifier_of(^^[[nodiscard("message")]] == "nodiscard")); // true"
[10]
"consteval string_view u8identifier_of(info r);"
"consteval string_view u8identifier_of(info r);"
[11]
"For an attribute `r` non described in this document, computing the reflection of `r` is ill-formed"
"For an attribute `r` non described in this document, computing the reflection of `r` is ill-formed"
[12]
"A `reflect-expression` of the form `^^[[ attribute ]]` for attribute described in this document [dcl.attr], represents said attribute."
"A `reflect-expression` of the form `^^[[ attribute ]]` for attribute described in this document [dcl.attr], represents said attribute."
[13]
"r₁ and r₂ are identical if their `attribute-token` are identical"
"r₁ and r₂ are identical if their `attribute-token` are identical"
Summary: P3385R7 proposes extending the P2996 reflection framework to cover C++ attributes, introducing attributes_of, identifier_of, and related metafunctions that let users reflect on standard and vendor attributes at compile time. Thirteen findings were identified spanning misparenthesized code examples, identifier misspellings, grammar errors in proposed normative wording, and a wrong return type in the wording diff base.
Pipeline: Discovery (Anthropic Opus + Citations API) → Verification Gate (OpenRouter Opus) → Report Writer (OpenRouter Opus)
Provenance: All references are machine-verified character positions from the Anthropic Citations API — deterministic, exact substrings, not model-generated quotes.
Provenance: All references are machine-verified character positions from the Anthropic Citations API — deterministic, exact substrings, not model-generated quotes.