Namespaces
Variants

std::meta::reflect_constant_string

From cppreference.com
< cpp | meta
 
 
Metaprogramming library
Type traits
Type categories
(C++11)
(C++11)(DR*)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11) 
(C++11)
(C++11)
Type properties
(C++11)
(C++11)
(C++14)
(C++11)(deprecated in C++26)
(C++11)(until C++20*)
(C++11)(deprecated in C++20)
(C++11)
Type trait constants
Metafunctions
(C++17)
Supported operations
Relationships and property queries
Type modifications
(C++11)(C++11)(C++11)
Type transformations
(C++11)(deprecated in C++23)
(C++11)(deprecated in C++23)
(C++11)
(C++11)(until C++20*)(C++17)

(C++11)
(C++17)
Compile-time rational arithmetic
Compile-time integer sequences
 
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

promotes compile-time string to static storage, returning a pointer to the first character of the static string
(function template) [edit]
promotes compile-time array into static storage, returning a reflection representing the static array
(function template) [edit]
returns a reflection representing a value or template parameter object, suitable for use as a constant template argument
(function template) [edit]