Date: Thu, 5 Oct 2023 15:21:19 +0800

Hi fellow experts

I initially thought that

mdspan ms(ptr, integral_constant<size_t, 2>{}, integral_constant<size_t, 6>{});

would be deduced into mdspan<int, extents<size_t, 2, 6>>. However, as the

current wording ([mdspan.mdspan.overview]

<https://eel.is/c++draft/mdspan.mdspan.overview>), it is just mdspan<int,

extents<size_t, dynamic_extent, dynamic_extent>>

template<class ElementType, class... Integrals>

requires((is_convertible_v<Integrals, size_t> && ...) &&

sizeof...(Integrals) > 0)

explicit mdspan(ElementType*, Integrals...)

-> mdspan<ElementType, dextents<size_t, sizeof...(Integrals)>>;

I wonder, is it a more appropriate choice to set the corresponding extents's

static values based on whether Integrals... is integral_constant? For

example

mdspan ms(ptr, integral_constant<size_t, 2>{},

integral_constant<size_t, 3>{},

4,

integral_constant<size_t, 5>{});

which will be deduced as mdspan<int, extents<size_t, 2, 3, dynamic_extent,

5>>.

What do you guys think? Could this be considered an improvement?

Hewill

I initially thought that

mdspan ms(ptr, integral_constant<size_t, 2>{}, integral_constant<size_t, 6>{});

would be deduced into mdspan<int, extents<size_t, 2, 6>>. However, as the

current wording ([mdspan.mdspan.overview]

<https://eel.is/c++draft/mdspan.mdspan.overview>), it is just mdspan<int,

extents<size_t, dynamic_extent, dynamic_extent>>

template<class ElementType, class... Integrals>

requires((is_convertible_v<Integrals, size_t> && ...) &&

sizeof...(Integrals) > 0)

explicit mdspan(ElementType*, Integrals...)

-> mdspan<ElementType, dextents<size_t, sizeof...(Integrals)>>;

I wonder, is it a more appropriate choice to set the corresponding extents's

static values based on whether Integrals... is integral_constant? For

example

mdspan ms(ptr, integral_constant<size_t, 2>{},

integral_constant<size_t, 3>{},

4,

integral_constant<size_t, 5>{});

which will be deduced as mdspan<int, extents<size_t, 2, 3, dynamic_extent,

5>>.

What do you guys think? Could this be considered an improvement?

Hewill

Received on 2023-10-05 07:21:31