21 Metaprogramming library [meta]

21.4 Reflection [meta.reflection]

21.4.3 Promoting to static storage [meta.define.static]

The functions in this subclause promote compile-time storage into static storage.
template<ranges::input_range R> consteval info reflect_constant_string(R&& r);
Let CharT be ranges​::​range_value_t<R>.
Mandates: CharT is one of char, wchar_t, char8_t, char16_t, char32_t.
Let V be the pack of values of type CharT whose elements are the corresponding elements of r, except that if r is a reference to a string literal object, then V does not include the terminating U+0000 null character of r.
Let P be the template parameter object ([temp.param]) of type const CharT[sizeof...(V) + 1] initialized with {V..., CharT()}.
Returns: ^^P.
[Note 1: 
P is a potentially non-unique object ([intro.object]).
— end note]
template<ranges::input_range R> consteval info reflect_constant_array(R&& r);
Let U be ranges​::​range_value_t<R> and T be remove_all_extents_t<U>.
Mandates:
Let V be the pack of values of type info of the same size as r, where the element is
  • reflect_constant_array(*) if U is an array type,
  • reflect_constant(static_cast<T>(*)) otherwise,
and is an iterator to the element of r.
Let P be
  • the template parameter object ([temp.param]) of type const T[sizeof...(V)], such that P[I] is template-argument-equivalent ([temp.type]) to the object represented by V...[I] for all I in the range [0, sizeof...(V)) if sizeof...(V) > 0 is true, otherwise
  • the template parameter object of type const array<T, 0> initialized with {}.
Returns: ^^P.
Throws: Any of
  • an exception thrown by any operation on r or on iterators and sentinels referring to r,
  • an exception thrown by the evaluation of any argument of reflect_constant or by any evaluation of reflect_constant_array, or
  • meta​::​exception if any invocation of reflect_constant would exit via an exception.
[Note 2: 
P is a potentially non-unique object ([intro.object]).
— end note]
template<ranges::input_range R> consteval const ranges::range_value_t<R>* define_static_string(R&& r);
Effects: Equivalent to: return meta::extract<const ranges::range_value_t<R>*>(meta::reflect_constant_string(r));
template<ranges::input_range R> consteval span<const ranges::range_value_t<R>> define_static_array(R&& r);
Effects: Equivalent to: using T = ranges::range_value_t<R>; meta::info array = meta::reflect_constant_array(r); if (meta::is_array_type(meta::type_of(array))) { return span<const T>(meta::extract<const T*>(array), meta::extent(meta::type_of(array))); } else { return span<const T>(); }
template<class T> consteval const remove_cvref_t<T>* define_static_object(T&& t);
Effects: Equivalent to: using U = remove_cvref_t<T>; if constexpr (meta::is_class_type(^^U) || meta::is_union_type(^^U)) { return addressof(meta::extract<const U&>( meta::reflect_constant(std::forward<T>(t)))); } else if constexpr (meta::is_array_type(^^U)) { return addressof(meta::extract<const U&>( meta::reflect_constant_array(std::forward<T>(t)))); } else { return define_static_array(span(addressof(t), 1)).data(); }
[Note 3: 
For class types, define_static_object provides the address of the template parameter object ([temp.param]) that is template-argument equivalent to t.
— end note]