Date: Tue, 17 Oct 2023 22:41:47 +0200

wt., 17 paź 2023 o 05:41 Hewill Kang via Std-Proposals

<std-proposals_at_[hidden]> napisał(a):

>

> 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]), 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

Would be better that instead of type alias use template variable?

Then code will look more clean:

```

//paper version:

mdspan ms(p, integral_c<3>{}, 42, integral_c<5>{});

//bit streamlined version:

template<auto I>

std::integral_constant<decltype(I), I> integral_c = {};

mdspan ms(p, integral_c<3>, 42, integral_c<5>);

```

probably name could be even shortened like:

```

std::mdspan ms(p, std::c<3>, 42, std::c<5>);

```

another option is user defined literals but there

is problem for good suffix as many are already

used or could conflict with hex numbers (like suffix `c`).

>

> --

> Std-Proposals mailing list

> Std-Proposals_at_[hidden]

> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals

<std-proposals_at_[hidden]> napisał(a):

>

> 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]), 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

Would be better that instead of type alias use template variable?

Then code will look more clean:

```

//paper version:

mdspan ms(p, integral_c<3>{}, 42, integral_c<5>{});

//bit streamlined version:

template<auto I>

std::integral_constant<decltype(I), I> integral_c = {};

mdspan ms(p, integral_c<3>, 42, integral_c<5>);

```

probably name could be even shortened like:

```

std::mdspan ms(p, std::c<3>, 42, std::c<5>);

```

another option is user defined literals but there

is problem for good suffix as many are already

used or could conflict with hex numbers (like suffix `c`).

>

> --

> Std-Proposals mailing list

> Std-Proposals_at_[hidden]

> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals

Received on 2023-10-17 20:41:59