Date: Thu, 23 May 2024 20:35:27 +0300
On Thu, 23 May 2024 at 20:25, Barry Revzin via Std-Proposals
<std-proposals_at_[hidden]> wrote:
>
>
>
> On Thu, May 23, 2024, 11:39 AM Hewill Kang via Std-Proposals <std-proposals_at_[hidden]> wrote:
>>
>> The standard specifies a legal case for `std::array` where `N` is `0`. It seems to me that `array<T, 0>` always meets the semantic requirements of `ranges::view`.
>> I'm wondering if there is value in making it a `view` since it behaves very similarly to `views::empty<T>`? For example:
>>
>> template<class T>
>> constexpr bool ranges::enable_view<array<T, 0>> = true;
>> template<class T>
>> constexpr bool ranges::enable_borrowed_range<array<T, 0>> = true;
>>
>> Is this reasonable or is this just a bad idea?
>>
>> Hewill
>
>
> This also gets into like... well should array<T, 1> be a view? single is a view.
>
> And then array<T, 2> is like concat with two singles, and that is a view. etc.
>
> Plus what does O(1) copyable even mean on a type that doesn't have variable size? Is array<T, N> always O(1) copyable?
std::array isn't O(1) copyable, it's O(N). Its specializations are
completely unrelated types that themselves have O(1) copy,
but that doesn't change that std::array doesn't.
single is an engineering exception to fit that particular case into
the generic model, and it would be unwise to generalize
such exceptions into the general model.
That's the way I squint at it, and I'm sticking to it.
<std-proposals_at_[hidden]> wrote:
>
>
>
> On Thu, May 23, 2024, 11:39 AM Hewill Kang via Std-Proposals <std-proposals_at_[hidden]> wrote:
>>
>> The standard specifies a legal case for `std::array` where `N` is `0`. It seems to me that `array<T, 0>` always meets the semantic requirements of `ranges::view`.
>> I'm wondering if there is value in making it a `view` since it behaves very similarly to `views::empty<T>`? For example:
>>
>> template<class T>
>> constexpr bool ranges::enable_view<array<T, 0>> = true;
>> template<class T>
>> constexpr bool ranges::enable_borrowed_range<array<T, 0>> = true;
>>
>> Is this reasonable or is this just a bad idea?
>>
>> Hewill
>
>
> This also gets into like... well should array<T, 1> be a view? single is a view.
>
> And then array<T, 2> is like concat with two singles, and that is a view. etc.
>
> Plus what does O(1) copyable even mean on a type that doesn't have variable size? Is array<T, N> always O(1) copyable?
std::array isn't O(1) copyable, it's O(N). Its specializations are
completely unrelated types that themselves have O(1) copy,
but that doesn't change that std::array doesn't.
single is an engineering exception to fit that particular case into
the generic model, and it would be unwise to generalize
such exceptions into the general model.
That's the way I squint at it, and I'm sticking to it.
Received on 2024-05-23 17:35:42