On Tue, 17 Mar 2026, 08:44 Tomasz Kamiński, <[email protected]> wrote:
> The condition was checking if extents<int, ...> is convertible to
> index_type,
> and not the reverse. We test implicit conversion from braced initializer
> list
> (to cover multiple arguments) and is_convertible in case of single
> index.
>
> libstdc++-v3/ChangeLog:
>
> * testsuite/23_containers/mdspan/extents/ctor_ints.cc: Updated
> is_explicit, and added more test cases.
> ---
> Fixed out issue that Tim pointed out on mattermost. I have checked
> other usages, and this seem to be only place affected.
>
> Tested *mdspan* test locally with all standard modes. OK for trunk?
OK
>
>
> .../23_containers/mdspan/extents/ctor_ints.cc | 20 +++++++++++++++----
> 1 file changed, 16 insertions(+), 4 deletions(-)
>
> diff --git
> a/libstdc++-v3/testsuite/23_containers/mdspan/extents/ctor_ints.cc
> b/libstdc++-v3/testsuite/23_containers/mdspan/extents/ctor_ints.cc
> index fdbcb707bbe..eefeab0e6a0 100644
> --- a/libstdc++-v3/testsuite/23_containers/mdspan/extents/ctor_ints.cc
> +++ b/libstdc++-v3/testsuite/23_containers/mdspan/extents/ctor_ints.cc
> @@ -24,18 +24,30 @@
> static_assert(std::is_constructible_v<std::extents<unsigned __int128, 1, 2>,
> #endif
>
> // No implicit conversion from integer-like objects.
> -template<typename Extent, typename... OExtents>
> - constexpr bool
> +template<typename ExtentsType, typename OIndex, typename... RIndicies>
> + consteval bool
> is_explicit()
> {
> - return std::is_nothrow_constructible_v<Extent, OExtents...>
> - && !std::is_convertible_v<Extent, OExtents...>;
> + if (!std::is_nothrow_constructible_v<ExtentsType, OIndex,
> RIndicies...>)
> + return false;
> + if constexpr (sizeof...(RIndicies) == 0)
> + if (std::is_convertible_v<OIndex, ExtentsType>)
> + return false;
> +
> + extern void testConv(ExtentsType);
> + return !requires (OIndex index, RIndicies... rindicies)
> + { testConv({index, rindicies...}); };
> }
>
> static_assert(is_explicit<std::extents<int, 1>, int>());
> static_assert(is_explicit<std::extents<int, 1>, unsigned int>());
> static_assert(is_explicit<std::extents<unsigned int, 1>, int>());
>
> +static_assert(is_explicit<std::dextents<int, 1>, int>());
> +static_assert(is_explicit<std::dextents<int, 2>, int, int>());
> +static_assert(is_explicit<std::dextents<int, 3>, int, int, int>());
> +
> +
> constexpr bool
> test_all()
> {
> --
> 2.53.0
>
>