C++ Logo

std-proposals

Advanced search

Re: [span] Value of dynamic_extent

From: Jorg Brown <jorg.brown_at_[hidden]>
Date: Tue, 2 Jul 2019 19:11:55 -0700
On Tue, Jul 2, 2019 at 3:13 PM Jorg Brown <jorg.brown_at_[hidden]> wrote:

> On Tue, Jul 2, 2019 at 1:59 AM Bjorn Reese <breese_at_[hidden]> wrote:
>
>> On 7/1/19 11:47 PM, Jorg Brown wrote:
>> > A vector can be empty; a string can be empty; a string_view can be
>> > empty; even a std::array can be empty. So why block a std::span from
>> > being empty, just because its extent isn't dynamic? I think this would
>> > end up blocking some compile-time programming cases.
>>
>> A span with dynamic extent can be empty.
>>
>> > Speaking of which, it's annoying that this doesn't currently work, due
>> > to data()'s implemenetation within std::array:
>> >
>> > constexpr const std::array<int, 0> ar0{};
>> > constexpr auto spanned_empty_array = std::span<const int, 0>{ar0};
>> >
>> > See https://godbolt.org/z/L4-9r8
>>
>> It does not seem to work for begin/end (or cbegin/cend) either when
>> N = 0.
>>
>
> Sorry, I sent the wrong link; the inclusion of "constexpr" in that program
> triggers a bug that needs to be fixed in libc++'s implementation of
> std::array. (Specifically, the bug is that std::array::data() isn't always
> constexpr) If you delete the constexpr on the second line, it will compile
> just fine.
>

And even more specifically, http://llvm.org/PR40124

-- Jorg

Received on 2019-07-02 21:14:00