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:
-
CharTberanges::range_value_t<R>, which must be one ofchar,wchar_t,char8_t,char16_t, orchar32_t. -
Vbe the pack of values of typeCharT, whose elements are corresponding elements ofr, except that ifris a string literal object,Vdoes not include the terminating null character ofr. -
Pbe the template parameter object of typeconst 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
|
(C++26) | promotes compile-time string to static storage, returning a pointer to the first character of the static string (function template) |
|
(C++26) | promotes compile-time array into static storage, returning a reflection representing the static array (function template) |
|
(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