Namespaces
Variants

std::meta::reflect_constant_array

From cppreference.com
 
 
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_array( R&& r );
(since C++26)

Returns a reflection that represents an array object whose elements are corresponding elements of r.

Let T be ranges::range_value_t<R>.

The program is ill-formed if T is not a structural type, if std::is_constructible_v<T, ranges::range_reference_t<R>> is false, or if T does not satisfy copy_constructible.

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 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), a reflection that represents the template parameter object of type const std::array<T, 0> initialized with {}.

Exceptions

Throws any exception thrown by the evaluation of static_cast<T>(*it), or std::meta::exception if the evaluation of std::reflect_constant would exit via an exception.

Notes

As a template parameter object, the resulting object has static storage duration. Ranges with template-argument-equivalent contents correspond to the same object.

The resulting object is a potentially non-unique object.

The result of std::meta::reflect_constant_array is suitable for use with std::meta::substitute. If the caller wants a 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 object, suitable for use as a constant template argument
(function template) [edit]