std::meta::reflect_constant_array
| Defined in header <meta>
|
||
template< ranges::input_range R >
consteval std::meta::info reflect_constant_array( R&& r );
|
(since C++26) | |
Returns a reflection that represents an array object whose elements are corresponding elements of r.
The resulting object is a template parameter object: it has static storage duration, and ranges with template-argument-equivalent contents correspond to the same object.
If the size of r is not zero, the resulting array object is a potentially non-unique object.
Let U be ranges::range_value_t<R> and T be std::remove_all_extents_t<U>.
The program is ill-formed if any of the following is true:
Tis not a structural type.Tdoes not satisfy copy_constructible.Uis not an array type, andstd::is_constructible_v<T, ranges::range_reference_t<R>>is false.
Parameters
| r | - | an input_range |
Return value
If the size of r is not zero, a reflection that represents a template parameter object of type const T[N] (where N is the size of r). Each element of the template parameter object is template-argument-equivalent to:
std::meta::reflect_constant_array(*it)ifUis an array type;std::meta::reflect_constant(static_cast<T>(*it))otherwise;
where it is an iterator to the corresponding element of r.
Otherwise (the size of r is zero), a reflection that represents the template parameter object of type const std::array<T, 0> initialized with {}.
Exceptions
Throws any exception thrown by:
- an operation on
ror on iterators or sentinels ofr; - any argument of
std::meta::reflect_constantor any call ofstd::meta::reflect_constant_arraydescribed above.
Throws std::meta::exception if any invocation of std::meta::reflect_constant would exit via an exception.
Notes
The result of std::meta::reflect_constant_array is suitable for use with std::meta::substitute. If the caller wants a std::span of a static array, as opposite to a reflection value, std::define_static_array is usually more suitable.
Example
| This section is incomplete Reason: no example |
See also
(C++26) |
promotes compile-time array into static storage, returning a span of the static array (function template) |
(C++26) |
promotes a compile-time string to static storage, returning a reflection representing the static string (function template) |
(C++26) |
returns a reflection representing a value or template parameter object, suitable for use as a constant template argument (function template) |