Namespaces
Variants

std::define_static_string

From cppreference.com
< cpp | meta
Revision as of 01:42, 1 May 2026 by D41D8CD98F (talk | contribs) (~)
 
 
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 const ranges::range_value_t<R>* define_static_string( R&& r );
(since C++26)

Promotes character array to static storage. A null character is appended if r is not a string literal object.

Equivalent to:

return std::meta::extract<const ranges::range_value_t<R>*>(std::meta::reflect_constant_string(r));

Parameters

r - a input_range of characters

Return value

A pointer to the first element of a character array object which is a template parameter object.

Notes

As a template parameter object, the resulting string object has static storage duration. Strings with the same contents correspond to the same object.

The resulting template parameter object is a potentially non-unique object.

Example

See also