This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of Ready status.

4397. Improve span(R&& r)

Section: 23.7.2.2.2 [span.cons] Status: Ready Submitter: Hewill Kang Opened: 2025-10-02 Last modified: 2026-06-09

Priority: 3

View all other issues in [span.cons].

View all issues with Ready status.

Discussion:

It is preferable to reject span<int, 42>(views::empty<int>) at compile-time after P2280R4, since applying ranges::size on those ranges is a constant expression now.

[2025-10-20; Reflector poll.]

Set priority to 3 after reflector poll.

The opinions on reflector discussion where split regarding, if this should be considered LEWG matter.

Question was raised, if ranges::size(r) == N is required to be usable at compile-time for integer-class types.

Previous resolution [SUPERSEDED]

This wording is relative to N5014.

  1. Modify 23.7.2.2.2 [span.cons] as indicated:

    template<class R> constexpr explicit(extent != dynamic_extent) span(R&& r);
    

    -?- Mandates: If extent is not equal to dynamic_extent and ranges::size(r) is a constant expression, then ranges::size(r) == extent is true.

    -16- Constraints: Let U be remove_reference_t<ranges::range_reference_t<R>>. […]

[2026-06-09; Jonathan provides new wording]

Move Mandates: after Constraints: and add more context.

[Brno 2026-06-09; Change status New → Ready]

Proposed resolution:

This wording is relative to N5046.

  1. Modify 23.7.2.2.2 [span.cons] as indicated:

    template<class R> constexpr explicit(extent != dynamic_extent) span(R&& r);
    

    -16- Constraints: Let U be remove_reference_t<ranges::range_reference_t<R>>. […]

    -?- Mandates: If extent is not equal to dynamic_extent and ranges::size(r) is a constant expression, then ranges::size(r) == extent is true.

    -17- Preconditions: […]

    -18- Hardened preconditions: If extent is not equal to dynamic_extent, then ranges::size(r) == extent is true.