C++ Logo

std-proposals

Advanced search

Re: [std-proposals] `mdspan` CTAD specialization for `integral_constant`?

From: Hewill Kang <hewillk_at_[hidden]>
Date: Tue, 17 Oct 2023 11:41:08 +0800
Hi fellow experts,

I wrote a paper based on this thread:

https://htmlpreview.github.io/?https://github.com/hewillk/mdspan-ctad/blob/main/mdspan-ctad.html

It is still in the draft stage so there may be parts that need to be
considered. Any comments are welcome.

Hewill

Hewill Kang <hewillk_at_[hidden]> 於 2023年10月5日 週四 下午3:21寫道:

> 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
>

Received on 2023-10-17 03:41:21