Title
Precedes vs Reachable in [meta.reflection]
Status
new
Section
[meta.reflection]
Submitter
Daniel Katz

Created on 2025-12-11.00:00:00 last changed 1 week ago

Messages

Date: 2025-12-20.17:37:44

Proposed resolution:

This wording is relative to N5032.

  1. Modify [meta.reflection.names] as indicated:

    consteval bool has_identifier(info r);
    

    -1- Returns:

    • (1.1) — […]

    • […]

    • (1.8) — Otherwise, if `r` represents the parameter P of a function F, then let S be the set of declarations, ignoring any explicit instantiations, that precede someare reachable from a point in the evaluation context and that declare either F or a templated function of which F is a specialization; […]

    • […]

    consteval string_view identifier_of(info r);
    consteval u8string_view u8identifier_of(info r);
    

    -2- Let E be UTF-8 for `u8identifier_of`, and otherwise the ordinary literal encoding.

    -3- Returns: An ntmbs, encoded with E, determined as follows:

    • (3.1) — […]

    • (3.2) — […]

    • (3.3) — Otherwise, if `r` represents the parameter P of a function F, then let S be the set of declarations, ignoring any explicit instantiations, that precede someare reachable from a point in the evaluation context and that declare either F or a templated function of which F is a specialization; the name that was introduced by a declaration in S for the parameter corresponding to P.

    • […]

  2. Modify [meta.reflection.queries] as indicated:

    consteval info type_of(info r);
    

    -2- Returns:

    • (2.1) — […]

    • […]

    • (2.4) — Otherwise, if `r` represents an enumerator N of an enumeration E, then:

      • (2.4.1) — If E is defined by a declaration D that precedesis reachable from a point P in the evaluation context and P does not occur within an enum-specifier of D, then a reflection of E.

      • (2.4.2) — Otherwise, a reflection of the type of N prior to the closing brace of the enum-specifier as specified in [dcl.enum].

    • […]

    […]
    consteval bool has_default_argument(info r);
    

    -41- Returns: If `r` represents a parameter P of a function F, then:

    • (41.1) — If F is a specialization of a templated function T, then `true` if there exists a declaration D of T that precedes someis reachable from a point in the evaluation context and D specifies a default argument for the parameter of T corresponding to P. Otherwise, `false`.

    • (41.2) — Otherwise, if there exists a declaration D of F that precedes someis reachable from a point in the evaluation context and D specifies a default argument for P, then `true`.

  3. Modify [meta.reflection.annotation] as indicated:

    consteval vector<info> annotations_of(info item);
    

    -1- Let E be […]

    -2- Returns: A `vector` containing all of the reflections R representing each annotation applying to each declaration of E that precedesis reachable from either somea 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. […]

Date: 2025-12-11.00:00:00

Discussion on the Core mailing list surfaced a handful of places in [meta.reflection] that use the "precedes" relation (defined in [basic.lookup] and primarily used for name lookup) when the "reachable" relation (defined in [module.reach]) is really what we want.

History
Date User Action Args
2025-12-20 17:37:44adminsetmessages: + msg15840
2025-12-11 00:00:00admincreate