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.

4426. Clarify what meta::reflect_constant_string considers a string literal

Section: 21.4.15 [meta.reflection.array] Status: New Submitter: Jakub Jelinek Opened: 2025-10-21 Last modified: 2025-10-21

Priority: Not Prioritized

View all issues with New status.

Discussion:

meta::reflect_constant_string says:

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.
It's unclear how the implementation should decide whether r refers to a string literal. If R models contiguous_iterator, should it use meta::is_string_literal(ranges::data(r))? Should it omit the '\0' from string_view("abc", 3)?

Also, "null terminator" is only defined in 27.4.3.1 [basic.string.general] and not used for string literal objects (5.13.5 [lex.string]).

Proposed resolution:

This wording is relative to N5014.

  1. Modify 21.4.15 [meta.reflection.array] 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.

    Let V be the pack of values of type CharT whose elements are the corresponding elements of r, except that if r refers is a reference to a string literal object, then V does not include the trailing null terminator terminating u+0000 null character of r.