C++ Logo

std-proposals

Advanced search

Re: [span] Value of dynamic_extent

From: Bjorn Reese <breese_at_[hidden]>
Date: Mon, 1 Jul 2019 21:43:50 +0200
On 7/1/19 8:21 PM, Tae Lim Kook via Std-Proposals wrote:

> I was thinking generic code that instantiates span with an
> extent that depends on some template parameter (as I mentioned
> in the previous reply), but I don't currently have any

That still works.

   template <typename T, std::size_t N>
   struct sparray {
     std::array<T, N> array;
     std::span<T, N> span;
     sparray() : span(array) {}
   };

When N is zero, sparray::span will have dynamic extent, but it will be
an empty span as expected.

Received on 2019-07-01 14:45:43