[meta.reflection.array]

# 21 Metaprogramming library [[meta]](./#meta)

## 21.4 Reflection [[meta.reflection]](meta.reflection#array)

### 21.4.15 Promoting to static storage arrays [meta.reflection.array]

[1](#1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L6201)

The functions in this subclause promote compile-time storage into static storage[.](#1.sentence-1)

[ð](#lib:reflect_constant_string)

`template<ranges::[input_range](range.refinements#concept:input_range "25.4.6 Other range refinements [range.refinements]") R>
  consteval info reflect_constant_string(R&& r);
`

[2](#2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L6211)

Let CharT be ranges​::​range_value_t<R>[.](#2.sentence-1)

[3](#3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L6214)

*Mandates*: CharT is one ofchar,wchar_t,char8_t,char16_t,char32_t[.](#3.sentence-1)

[4](#4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L6223)

Let V be the pack of values of type CharT whose elements are the corresponding elements of r,
except that if r refers to a string literal object,
then V does not include the trailing null terminator of r[.](#4.sentence-1)

[5](#5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L6229)

Let P be the template parameter object ([[temp.param]](temp.param "13.2 Template parameters"))
of type const CharT[sizeof...(V) + 1] initialized with {V..., CharT()}[.](#5.sentence-1)

[6](#6)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L6234)

*Returns*: ^^P[.](#6.sentence-1)

[7](#7)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L6238)

[*Note [1](#note-1)*:

P is a potentially non-unique object ([[intro.object]](intro.object "6.8.2 Object model"))[.](#7.sentence-1)

â *end note*]

[ð](#lib:reflect_constant_array)

`template<ranges::[input_range](range.refinements#concept:input_range "25.4.6 Other range refinements [range.refinements]") R>
  consteval info reflect_constant_array(R&& r);
`

[8](#8)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L6251)

Let T be ranges​::​range_value_t<R>[.](#8.sentence-1)

[9](#9)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L6254)

*Mandates*: T is a structural type ([[temp.param]](temp.param "13.2 Template parameters")),is_constructible_v<T, ranges​::​range_reference_t<R>> is true, andis_copy_constructible_v<T> is true[.](#9.sentence-1)

[10](#10)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L6260)

Let V be the pack of values of type info of the same size as r,
where the ith element is reflect_constant(ei),
where ei is the ith element of r[.](#10.sentence-1)

[11](#11)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L6266)

Let P be

- [(11.1)](#11.1)

  If sizeof...(V) > 0 is true,
 then the template parameter object ([[temp.param]](temp.param "13.2 Template parameters"))
 of type const T[​sizeof...(​V)] initialized with {[:V:]...}[.](#11.1.sentence-1)

- [(11.2)](#11.2)

  Otherwise, the template parameter object
 of type array<T, 0> initialized with {}[.](#11.2.sentence-1)

[12](#12)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L6280)

*Returns*: ^^P[.](#12.sentence-1)

[13](#13)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L6284)

*Throws*: meta​::​exception unlessreflect_constant(e) is a constant subexpression
for every element e of r[.](#13.sentence-1)

[14](#14)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L6290)

[*Note [2](#note-2)*:

P is a potentially non-unique object ([[intro.object]](intro.object "6.8.2 Object model"))[.](#14.sentence-1)

â *end note*]
