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.

4484. std::meta::reflect_constant_{string,array} talks about template parameter objects of built-in array types

Section: 21.4.3 [meta.define.static] Status: New Submitter: Jiang An Opened: 2025-11-25 Last modified: 2025-11-27

Priority: Not Prioritized

View other active issues in [meta.define.static].

View all other issues in [meta.define.static].

View all issues with New status.

Discussion:

Currently, 21.4.3 [meta.define.static] is talking about template parameter objects of built-in array types, but per 13.2 [temp.param]/13, a template parameter object must be of a class type. So std::meta::reflect_constant_{string,array} are perhaps mis-specified.

[2025-11-27; Tomasz comments]

The template argument object defintion was extended to cover objects of array types by CWG 3111. The usage of the term "template parameter object" is intentional here, as it guarantees that reflect_constant_string produces the same objects, where their content is the same.

Proposed resolution:

This wording is relative to N5014.

  1. Modify 21.4.3 [meta.define.static] as indicated:

    template<ranges::input_range R>
      consteval info reflect_constant_string(R&& r);
    

    -2- Let CharT be ranges::range_value_t<R>.

    -3- Mandates: CharT is one of char, wchar_t, char8_t, char16_t, char32_t.

    -4- Let V be the pack of values of type CharT whose elements are the corresponding elements of r, except that if r refers to a string literal object, then V does not include the trailing null terminator of r.

    -5- Let P be the template parameter object (13.2 [temp.param])a constexpr object with static storage duration (6.8.6.1 [basic.stc.general]) of type const CharT[sizeof...(V) + 1] initialized with {V ..., CharT()}.

    […]

    template<ranges::input_range R>
      consteval info reflect_constant_array(R&& r);
    

    -8- Let T be ranges::range_value_t<R>.

    -9- Mandates: T is a structural type (13.2 [temp.param]), […].

    -10- Let V be the pack of values […].

    -11- Let P be

    • (11.1) — If sizeof...(V) > 0 is true, then the template parameter object (13.2 [temp.param])a constexpr object with static storage duration (6.8.6.1 [basic.stc.general]) of type const T[sizeof...(V)] initialized with {[:V:]...}.
    • (11.2) — Otherwise, the template parameter object of type array<T, 0> initialized with {}.

    […]