close
Namespaces
Variants

std::meta::reflect_constant_array

From cppreference.com
< cpp | meta
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:

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) if U is 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 r or on iterators or sentinels of r;
  • any argument of std::meta::reflect_constant or any call of std::meta::reflect_constant_array described 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

See also

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