mdspan::is_always_meow()
should be noexcept
Section: 23.7.3.6.1 [mdspan.mdspan.overview] Status: New Submitter: Stephan T. Lavavej Opened: 2023-12-07 Last modified: 2023-12-10
Priority: Not Prioritized
View all issues with New status.
Discussion:
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 23.7.3.6.1 [mdspan.mdspan.overview]/3:
LayoutPolicy
shall meet the layout mapping policy requirements (23.7.3.4.3 [mdspan.layout.policy.reqmts]) […]
23.7.3.4.3 [mdspan.layout.policy.reqmts]/1:
A type
MP
meets the layout mapping policy requirements if for a typeE
that is a specialization ofextents
,MP::mapping<E>
is valid and denotes a typeX
that meets the layout mapping requirements (23.7.3.4.2 [mdspan.layout.reqmts]) […]
23.7.3.4.2 [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 (7.7 [expr.const]) of typebool
. […]M::is_always_exhaustive()
Result: A constant expression (7.7 [expr.const]) of typebool
. […]M::is_always_strided()
Result: A constant expression (7.7 [expr.const]) of typebool
.
Constant expressions can surely be obtained without throwing exceptions.
Proposed resolution:
This wording is relative to N4964.
Modify 23.7.3.6.1 [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(); } […]