C++ Logo

std-proposals

Advanced search

Re: [span] Value of dynamic_extent

From: Nevin Liber <nevin_at_[hidden]>
Date: Wed, 3 Jul 2019 17:41:31 -0500
On Wed, Jul 3, 2019 at 12:46 AM Justin Bassett via Std-Proposals <
std-proposals_at_[hidden]> wrote:

>
>
> On Mon, Jul 1, 2019 at 4:21 PM Nevin Liber via Std-Proposals <
> std-proposals_at_[hidden]> wrote:
>
>>
>> - Why any value at all? Last I checked, we now have variadic
>> templates, where "now" is defined as since 2011...
>>
>> template <typename T, std::size_t Extent>
> void some_function(std::span<T, Extent> some_span) { ... }
>
> As currently specified, this function accepts any span of any extent,
> static or dynamic. Using a variadic template breaks this,
>
and there would be no easy way to write a function taking both kinds of
> span.
>

You mean other than:

template<typename T, std::size_t... Extent>
void some_function(std::span<T, Extent...> some_span) { ... }

Variadics also have the advantage that if I want code for just static
extent spans, I don't have to use concepts/SFINAE to take dynamic extent
spans out of the overload set.
-- 
 Nevin ":-)" Liber  <mailto:nevin_at_[hidden] <nevin_at_[hidden]>>
+1-847-691-1404

Received on 2019-07-03 17:44:00