This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of New status.

4496. Precedes vs Reachable in [meta.reflection]

Section: 21.4 [meta.reflection] Status: New Submitter: Daniel Katz Opened: 2025-12-11 Last modified: 2025-12-20

Priority: Not Prioritized

View all issues with New status.

Discussion:

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

Proposed resolution:

This wording is relative to N5032.

  1. Modify 21.4.6 [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 21.4.7 [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 9.8.1 [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 21.4.18 [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 (7.7 [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. […]