Spec-Zone.ru › C++

std::meta::reflect_constant_string

Defined in header <meta>
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

r - a input_range of characters

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

define_static_string
(C++26)
promotes compile-time string to static storage, returning a pointer to the first character of the static string
(function template)
reflect_constant_array
(C++26)
promotes compile-time array into static storage, returning a reflection representing the static array
(function template)
reflect_constant
(C++26)
returns a reflection representing a value or template parameter object, suitable for use as a constant template argument
(function template)

© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
https://en.cppreference.com/cpp/meta/reflect_constant_string

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API