std::define_static_array
From cppreference.com
| Defined in header <meta>
|
||
template< ranges::input_range R >
consteval std::span<const ranges::range_value_t<R>> define_static_array( R&& r );
|
(since C++26) | |
Promotes array to static storage.
Equivalent to:
using T = ranges::range_value_t<R>;
std::meta::info array = std::meta::reflect_constant_array(r);
std::meta::info type = std::meta::type_of(array);
if (std::meta::is_array_type(type)) {
return std::span<const T>(std::meta::extract<const T*>(array), std::meta::extent(type));
} else {
return std::span<const T>();
}
Parameters
| r | - | a input_range whose elements are copy-constructible and have structural type
|
Return value
If the size of r is not zero, a span constructed from an array of type const T[N] (where T is ranges::range_value_t<R> and N is the size of r). Each element of the array is initialized from the value or object represented by std::meta::reflect_constant(static_cast<T>(*it)), where it is an iterator to the corresponding element of r.
Otherwise (the size of r is zero), an empty span.
Notes
As a template parameter object, the resulting array object (if present) has static storage duration. Ranges with template-argument-equivalent contents correspond to the same array object.
The array object is a potentially non-unique object.
Example
| This section is incomplete Reason: no example |
See also
| |||