Created on 2023-12-07.00:00:00 last changed 1 month ago
Proposed resolution:
This wording is relative to N4964.
Modify [mdspan.mdspan.overview], class template mdspan synopsis, as indicated:
[…]
static constexpr bool is_always_unique() noexcept
{ return mapping_type::is_always_unique(); }
static constexpr bool is_always_exhaustive() noexcept
{ return mapping_type::is_always_exhaustive(); }
static constexpr bool is_always_strided() noexcept
{ return mapping_type::is_always_strided(); }
[…]
[ 2025-10-21; Reflector poll. ]
Set priority to 3 after reflector poll.
Use if consteval may lead to exception thrown from invocation of is_always_meow, when evaluated at runtime.
Design intent was for is_always_meow functions to always produce value at compile time. Layout requirements may need to be updated.
Separately, [structure.specifications] says that Result: is just the type and value category; not "constant expression" - this matters because we need to require a prvalue constant expression here.
It can easily be proven that mdspan::is_always_meow() is preconditionless and can never throw exceptions. microsoft/STL has already shipped a noexcept-strengthened implementation, libc++ would like to (see llvm/llvm-project#74254), and together we believe that the Standard should simply mandate noexcept so users can rely on this. The proof is:
N4964 [mdspan.mdspan.overview]/3:
LayoutPolicy shall meet the layout mapping policy requirements ([mdspan.layout.policy.reqmts]) […]
[mdspan.layout.policy.reqmts]/1:
A type MP meets the layout mapping policy requirements if for a type E that is a specialization of extents, MP::mapping<E> is valid and denotes a type X that meets the layout mapping requirements ([mdspan.layout.reqmts]) […]
[mdspan.layout.reqmts]/1, /1.5, /22, /24, /26:
A type M meets the layout mapping requirements if
[…]
— the following types and expressions are well-formed and have the specified semantics.
[…] M::is_always_unique() Result: A constant expression ([expr.const]) of type bool. […] M::is_always_exhaustive() Result: A constant expression ([expr.const]) of type bool. […] M::is_always_strided() Result: A constant expression ([expr.const]) of type bool.
Constant expressions can surely be obtained without throwing exceptions.
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2025-10-21 09:46:25 | admin | set | messages: + msg15293 |
| 2023-12-09 15:42:07 | admin | set | messages: + msg13884 |
| 2023-12-07 00:00:00 | admin | create | |