◐ Shell
clean mode source ↗

std::meta::reflect_constant_string - cppreference.com

From cppreference.com

template< ranges::input_range R >
consteval std::meta::info reflect_constant_string( R&& r );
(since C++26)

Returns a reflection that represents a character array object whose elements are corresponding elements of r, with a null character appended if r is not a string literal object.

The resulting character array object is a template parameter object: it has static storage duration, and strings with the same contents correspond to the same object.

The resulting character array object is also a potentially non-unique object.

Formally, let:

  • CharT be ranges::range_value_t<R>, which must be one of char, wchar_t, char8_t, char16_t, or char32_t.
  • V be the pack of values of type CharT, whose elements are corresponding elements of r, except that if r is a string literal object, V does not include the terminating null character of r.
  • P be the template parameter object of type const CharT[sizeof...(V) + 1], initialized with {V..., CharT()}.

This function returns a reflection that represents the object P.

Parameters

Return value

A reflection that represents a character array object, as described above.

Notes

The result of std::meta::reflect_constant_string is suitable for use with std::meta::substitute. If the caller wants a pointer to a static string, as opposite to a reflection value, std::define_static_string is usually more suitable.

Example

See also