This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of Immediate status.
define_static_arraySection: 21.4.3 [meta.define.static] Status: Immediate Submitter: Hewill Kang Opened: 2026-03-09 Last modified: 2026-03-27
Priority: 2
View other active issues in [meta.define.static].
View all other issues in [meta.define.static].
View all issues with Immediate status.
Discussion:
define_static_array can transform any input range, even a non-contiguous one, into a span.
span always has a dynamic extent. If the size of the input range is known at
compile time, returning a static span seems reasonable and may offer slight runtime efficiency.
[2026-03-25; Reflector poll.]
Set priority to 2 after reflector poll.
[Croydon 2026-03-25; move to Immediate.]
Previous resolution [SUPERSEDED]:
This wording is relative to N5032.
Modify 21.4.1 [meta.syn], header
<meta>synopsis, as indicated:#include <compare> // see 17.12.1 [compare.syn] #include <initializer_list> // see 17.11.2 [initializer.list.syn] namespace std { […] // 21.4.3 [meta.define.static], promoting to static storage […] template<ranges::input_range R> consteval span<const ranges::range_value_t<R>, see below> define_static_array(R&& r); […] }Modify 21.4.3 [meta.define.static] as indicated:
template<ranges::input_range R> consteval span<const ranges::range_value_t<R>, see below> define_static_array(R&& r);-16- 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, see below>(meta::extract<const T*>(array), meta::extent(meta::type_of(array))); } else { return span<const T, see below>(); }-?- Remarks: The second template argument of the returned
spantype isstatic_cast<size_t>(ranges::size(r))ifranges::size(r)is a constant expression, anddynamic_extentotherwise.
[2026-03-26; Tim reopens and provides revised wording]
The else branch is ill-formed when the returned has non-zero static extent.
[Croydon 2026-03-27; move to Immediate.]
Proposed resolution:
This wording is relative to N5032.
Modify 21.4.1 [meta.syn], header <meta> synopsis, as indicated:
#include <compare> // see 17.12.1 [compare.syn] #include <initializer_list> // see 17.11.2 [initializer.list.syn] namespace std { […] // 21.4.3 [meta.define.static], promoting to static storage […] template<ranges::input_range R> consteval span<const ranges::range_value_t<R>, see below> define_static_array(R&& r); […] }
Modify 21.4.3 [meta.define.static] as indicated:
template<ranges::input_range R> consteval span<const ranges::range_value_t<R>, see below> define_static_array(R&& r);-16- 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, see below>(meta::extract<const T*>(array), meta::extent(meta::type_of(array))); } else { return span<const T, see below>(static_cast<const T*>(nullptr), 0); }-?- Remarks: The second template argument of the returned
spantype isstatic_cast<size_t>(ranges::size(r))ifranges::size(r)is a constant expression, anddynamic_extentotherwise.